Recent

Author Topic: Telegram bots API Wrapper  (Read 31071 times)

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #30 on: August 28, 2019, 08:56:36 am »


Quote
Hi, If I comment it out it compiles and runs but when it runs I get SSL errors.

I tried the project on Windows and there it works 100%. I then tried it on The Raspbarian Desktop in a virtual machine. There I get the same error that the variable does not exist.

I then tried it on Debian Desktop. There it compiles but I get SSL error also.

On Raspberry Pi I use it on Raspbian Buster (Debian 10) and FPC is 3.3.1 and Lazarus is 2.0.1
Can You help us?
« Last Edit: February 13, 2020, 01:50:41 pm by Renat.Su »

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #31 on: August 28, 2019, 09:53:01 am »
I think that last commit (with OpenSSL in uses clause) is invalid for trunk FPC. Unit fpopenssl has many changes in trunk version of freepascal

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Telegram bots API Wrapper
« Reply #32 on: August 28, 2019, 10:58:54 am »
I think that last commit (with OpenSSL in uses clause) is invalid for trunk FPC. Unit fpopenssl has many changes in trunk version of freepascal
Well not too many: the only thing that is  affected is the protocol defaults. Must be tls 1.1 or higher.
I suppose telegram adheres to this too.
Specialize a type, not a var.

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #33 on: August 28, 2019, 01:09:37 pm »
I think that last commit (with OpenSSL in uses clause) is invalid for trunk FPC. Unit fpopenssl has many changes in trunk version of freepascal
Well not too many: the only thing that is  affected is the protocol defaults. Must be tls 1.1 or higher.
I suppose telegram adheres to this too.
Earlier it works without explicitly specifying of SSL type, and did not even need to specify fpopenssl unit in the uses block. As I understand works without this and OS itself defines that use. Maybe I'm wrong. Then one of the users of the library reported that the new Ubuntu 1.9 did not works with lib (SSL problem) and offered a commit https://github.com/Al-Muhandis/fp-telegram/commit/fafbe6dc7fd86756208ee17f1c87567da9a90165 with an explicit specifying of a secure connection

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #34 on: February 06, 2020, 02:53:31 pm »
Very important and very small commit: change TLS version for HTTPS request to telegram endpoint. TLSv1_1 is not supported now by telegram server.
Other news: I want to abstract HTTP client lib from the fp-telegram library so that you can connect different HTTP libraries in addition to native ones (Synapse, indy etc)

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Telegram bots API Wrapper
« Reply #35 on: February 06, 2020, 03:26:24 pm »
regarding flqueue (and possibly other places):

You can do this and remove all ifdef's regarding the 32/64 cpu tests.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. {$macro on}{$if defined(CPU64)}
  3. {$define interlockedCompareExchange:=interlockedCompareExchange64}
  4. {$define interlockedIncrement:=interlockedIncrement64}
  5. {$ifend}

That is, unless you want to keep Delphi compatibility of course, but your code is mode objpas and not mode delphi anyway.
« Last Edit: February 06, 2020, 03:28:49 pm by Thaddy »
Specialize a type, not a var.

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #36 on: February 06, 2020, 05:18:27 pm »
regarding flqueue (and possibly other places):

You can do this and remove all ifdef's regarding the 32/64 cpu tests.
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. {$macro on}{$if defined(CPU64)}
  3. {$define interlockedCompareExchange:=interlockedCompareExchange64}
  4. {$define interlockedIncrement:=interlockedIncrement64}
  5. {$ifend}

That is, unless you want to keep Delphi compatibility of course, but your code is mode objpas and not mode delphi anyway.
THanks, But flqueue unit is not used anywhere in the library now. It remained because of backward compatibility. I will probably delete this unit in the following commits
« Last Edit: February 06, 2020, 05:20:14 pm by Renat.Su »

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Telegram bots API Wrapper
« Reply #37 on: February 06, 2020, 07:41:08 pm »
Very important and very small commit: change TLS version for HTTPS request to telegram endpoint. TLSv1_1 is not supported now by telegram server.
Other news: I want to abstract HTTP client lib from the fp-telegram library so that you can connect different HTTP libraries in addition to native ones (Synapse, indy etc)

Thanks !!!

Hi, Mario

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #38 on: February 13, 2020, 08:12:09 am »
So, I separated the HTTP client implementation from the lib. By default, the native FPHTTPClient broker will also be used, but it is a good idea to specify the broker explicitly:
Code: Pascal  [Select][+][-]
  1. Uses ... tgfclhttpcientbroker... ;
Additionally, there is a broker for the synapse library. In this case, instead of tgfclhttpclientbroker, you should add tgsynapseclientbroker to the uses block and of course add laz_synapse to the project dependencies (for example, from the Online Package Manager).
An important consequence and the main reason why I introduced the HTTP client broker system is that it is now possible to use an HTTPS proxy (the native client, unfortunately, does not support) with synapse client broker.
For these purposes, properties have been added to the TTelegramSender:
Code: Pascal  [Select][+][-]
  1.     property HTTPProxyUser: String read FHTTPProxyUser write FHTTPProxyUser;
  2.     property HTTPProxyPassword: String read FHTTPProxyPassword write FHTTPProxyPassword;
  3.     property HTTPProxyHost: String read FHTTPProxyHost write FHTTPProxyHost;
  4.     property HTTProxyPort: Word read FHTTProxyPort write FHTTProxyPort;  

Next, another very important note. There is a bug in laz_synapse that causes the https proxy not works in Linux OS. It is solved by a small hack in the synapse library https://forum.lazarus.freepascal.org/index.php/topic,43574.msg349074.html#msg349074

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: Telegram bots API Wrapper
« Reply #39 on: February 13, 2020, 09:04:53 am »
use an HTTPS proxy (the native client, unfortunately, does not support)
The trunk version does support it. It does not use new compiler features, so you may simply check out and use with 3.0.4.
Specialize a type, not a var.

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #40 on: February 13, 2020, 09:36:13 am »
use an HTTPS proxy (the native client, unfortunately, does not support)
The trunk version does support it. It does not use new compiler features, so you may simply check out and use with 3.0.4.
Thanks, I'll recheck it

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #41 on: February 13, 2020, 01:49:18 pm »
use an HTTPS proxy (the native client, unfortunately, does not support)
The trunk version does support it. It does not use new compiler features, so you may simply check out and use with 3.0.4.
No, FPHTTPClient with HTTP proxy to HTTPS url is not works, even in trunk version! You can check any case.
Please note, I meant HTTPS URL via HTTP proxy! This is the combination that doesn't work. Without HTTPS works (but almost all API endpoints and all sites are HTTPS only) or with HTTPS URL but without a proxy works (it was necessary to support HTTP proxy)

bonmario

  • Sr. Member
  • ****
  • Posts: 346
Re: Telegram bots API Wrapper
« Reply #42 on: July 11, 2020, 06:44:51 pm »
Hi,
today i have updated FPC to 3.2.0, on my Ubuntu 64 bit.

Compiling, i have this error:
Code: Pascal  [Select][+][-]
  1. fgl.pp(1152,5) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Add(const Item:TTelegramPhotoSize):LongInt;" marked as inline is not inlined
  2. fgl.pp(1152,18) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Get(Index:LongInt):TTelegramPhotoSize;" marked as inline is not inlined
  3. tgtypes.pas(571,19) Note: Call to subroutine "operator :=(const source:Variant):AnsiString;" marked as inline is not inlined
  4. tgtypes.pas(1036,7) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramMessageEntityObj>.Add(const Item:TTelegramMessageEntityObj):LongInt;" marked as inline is not inlined
  5. tgtypes.pas(1041,7) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Add(const Item:TTelegramPhotoSize):LongInt;" marked as inline is not inlined
  6. tgfclhttpclientbroker.pas(79,44) Error: Identifier not found "stTLSv1_2"
  7.  

Source tgfclhttpclientbroker:
Code: Pascal  [Select][+][-]
  1. TSSLSocketHandler(AHandler).SSLType:=stTLSv1_2;  // <--

It'ìs a bug?

Thanks in advance, Mario


P.S. Seems that adding uses of "sslbase" solve the problem
« Last Edit: July 11, 2020, 06:48:09 pm by bonmario »

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #43 on: July 11, 2020, 08:30:21 pm »
I compile it in the trunk version and in 2.0.8.

I will check in 2.0.10 soon

Renat.Su

  • Full Member
  • ***
  • Posts: 230
    • Renat.Su
Re: Telegram bots API Wrapper
« Reply #44 on: July 12, 2020, 12:06:00 am »
Hi,
today i have updated FPC to 3.2.0, on my Ubuntu 64 bit.

Compiling, i have this error:
Code: Pascal  [Select][+][-]
  1. fgl.pp(1152,5) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Add(const Item:TTelegramPhotoSize):LongInt;" marked as inline is not inlined
  2. fgl.pp(1152,18) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Get(Index:LongInt):TTelegramPhotoSize;" marked as inline is not inlined
  3. tgtypes.pas(571,19) Note: Call to subroutine "operator :=(const source:Variant):AnsiString;" marked as inline is not inlined
  4. tgtypes.pas(1036,7) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramMessageEntityObj>.Add(const Item:TTelegramMessageEntityObj):LongInt;" marked as inline is not inlined
  5. tgtypes.pas(1041,7) Note: Call to subroutine "function TFPGObjectList<tgtypes.TTelegramPhotoSize>.Add(const Item:TTelegramPhotoSize):LongInt;" marked as inline is not inlined
  6. tgfclhttpclientbroker.pas(79,44) Error: Identifier not found "stTLSv1_2"
  7.  

Source tgfclhttpclientbroker:
Code: Pascal  [Select][+][-]
  1. TSSLSocketHandler(AHandler).SSLType:=stTLSv1_2;  // <--

It'ìs a bug?

Thanks in advance, Mario


P.S. Seems that adding uses of "sslbase" solve the problem
Try last commit https://github.com/Al-Muhandis/fp-telegram

 

TinyPortal © 2005-2018