Forum > Third party

Telegram bots API Wrapper

(1/10) > >>

Renat.Su:
I'm writing a class to work with telegram API as plugin to BrookFramework.
https://github.com/Al-Muhandis/brook-telegram
There is also depends from library fp-telegram that I am also actively developing now. The library functionality is still small, but it is working. In the examples folder you can find a working example of a Fast-cgi application HelloWorld. For those who have any online service or website, developed on the Brookframework then can add telegram bot TBrookAction to your website.
Please write if you find bugs, tips or want to join the development

Renat.Su:
fp-telegram: Added Long Polling to receive updates in addition to Webhook that I already use. Not much testing, because for me it is more convenient only webhook.
But for those who do not want to bother with writing web applications a good option is writing a desktop [or console or service] application to work with the Telegram Bot API. In this case, you can get updates with long polling (even short polling for testing). [Personally, I do not like this method, the only useful application when you do not want or can not install a webhook]
/ EXAMPLES /: Added simple ready-made examples for showing how longpolling works. A multithreaded version and example quite simple without threads (see getMe) https://github.com/Al-Muhandis/fp-telegram/tree/master/examples
brook-telegram: adapted the library to work with brookframework 3.9.9 ...
Also I hope that someone will join the project;)

Renat.Su:
Work on the library continues.
Recent changes: inline mode

Done:
   
* webhook getting updates
* longpolling getting udates via getUpdates API method
* Telegram bots API methods implemented:

* getMe
* sendMessage
* sendPhoto
* sendVideo
* getUpdates
* answerInlineQuery
* sendLocation
* Update events handling

* Message & message commands
* Callback query
* Inline queries
* Full json updates logging (without handling)
* Simple statistcs (csv-format)Todo:
* Extensive statistics (Quantitative data on requests and unique users)
* Botan statistics
* Other bots API methods
* Other update events handling
* exception classes
* delphi compatibility (Not sure about the need)
* more examples
* Please suggest me other functionalitiesI need recommendations and advice from more experienced programmers on the hierarchy of classes, adding methods for interfaces to work through other libraries, examples of implementing webhooks, for example, through built-in FCL classes for web servers (for brookframework already exist, as well as adaptation to BF4).

bonmario:
Hi, referring to this thread http://forum.lazarus.freepascal.org/index.php/topic,41716.0/topicseen.html i am the author of the last post in the italian forum.
What's wrong in my code?

Thanks in advance, Mario

Renat.Su:
Hi.
So
To begin with, I will describe what the code you provided does. Performs a getMe request to the telegram server. As a result, we get some data on the bot (for example, its name). Further, in the case of a positive response, the program in the long polling mode waits for any event (getUpdates). This can be a message sent to the bot by the user or any other event that can be sent by the telegram server to the bot. The bot waits for an update depending on the TimeOut parameter in the procedure. If the update comes, then apparently You do not have processing. Just move on to the next operation. As in case it doesn't wait.
Then the bot sends the message "/start". Why and who? Instead, commands are sent by users to the bot, not the other way around. The CurrentChatID property is useful inside event processing, for example, as a response to a user's message (for example, the same command) and this property will store the ChatID In which the message was sent to the bot. It is logical that the bot will send a response in the same chat to the user.
Perhaps, if there was some update of the bot in the form of a message from the user, the program will send a message to this user, although there is a lot depends on other factors.
In General, the behavior of the algorithm is difficult to predict. So if you formulate Your task, what you want to do I would suggest you the options of using this bot

Navigation

[0] Message Index

[#] Next page

Go to full version