Open witnessmenow opened 8 years ago
can you look at the work of Giancarlo on https://github.com/Gianbacchio/ESP8266-TelegramBot In the future maybe we can merge also the support for esp8266, but at the moment I don't have the chip for testing.
Thanks for that link, I took a quick look at it there and it works on my wemos
It is a little bit behind in terms of features (no keyboard for example) and it doesn't make use of the Json parsing library, but it can send and receive messages which is the main thing,
I'll have a play around with it, to try get my understanding of it better
It would be cool if they could be combined.
I started working on the linked library to try make it more generic to allow for multiple architectures to be able to use the same main telegram code. My approach Base telegramBot class with a virtual function for sendGetToTelegram (it only does get at the moment) and a derived class for the architecture which defines the sendGetToTelegram method. This should in theory allow for additional architectures to be configured pretty easily that uses the same base telegram code.
If you get a chance it would be great if you could take a look and let me know if you have any comments or suggestions. Here is my fork
I unfortunately don't have a chip that I can test the samd architecture with so I cant really fully prove out that this approach works well
Thanks
Thanks for the contribution, I like your idea to support more architectures, but I want to keep the code clear. Every class should be in a separated file and the use of a virtual function is not safe, I would prefer that all classes that extend the TelegramBot just override some methods and should maintain the same apis for the user, for example your sendGetToTelegram should simply be an overrider function of postMessage(). I hope I was clear!
This library actually works for ESP8266 using the Arduino IDE. I can't remember all adjustments I have done, but basically what you have to do is adding an SSL-secured connection to your sketch.
`
Then, you can declare and use the this labrary as we're used to.
WiFiClientSecure client; TelegramBot bot (BotToken, BotName, BotUsername, client);
Currently, I am facing two issues:
Every few minutes, the client received the least current message again (and again (and again...)). Let's say you have implemented a simple echo-bot, it will re-send the last message every few minutes to the user who last recently messeged to the bot.
I highly appreciate the work you and witnessmenow have done in your projects and am about to test also witnessmenows code.
Thanks :)
Talking about issues, I forgot to mention that this project doesn't check the fignerprint of the server which could be critical in some environments.
Thanks for your work, can you please make a PR with your example? The problem with the the SSL library could be caused by an overflow. I'll work to add the fingerprint check in the next days.
Thanks for your fast replay. The work I did is part of a bigger project, but I'l try do give a small example within the next few days
When I was looking at the code for this library I tried what @didgerihorn did, just passing reference to WifiClientSecure as client as it seemed to have contain all the method calls that were being used, but on my Wemos Mini V2 it crashed every time. Digging into it a little bit more it seems to be where the StaticJsonBuffer
I opened #13 , this causes the second issue you describe @didgerihorn
I continued doing a small bit of work on my fork from the ESP8266 library. I'm not sure if it useful to others but feel free to take a look
https://github.com/witnessmenow/Universal-Arduino-Telegram-Bot
One thing that is a little bit different is that I implemented a sendMessage method that takes a Json object as an input, so in theory means that you should be able to use all the different message options, event if the Telegram API adds new ones.
It would be great if the library could support the esp8266 architecture as there is a few really cheap boards with built in WiFi (wemos is $4 delivered on aliexpress)