CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: Duke "Tape" Eiyeron on June 26, 2015, 07:01:53 PM

Title: [Bot][Python][Telegram] Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 26, 2015, 07:01:53 PM
Hello everyone, time for another project! This one is a bot/library project I went crazy about since yesterday late night : creating a bot for Telegram.

Some users among us are chatting in our own group, and the moment I saw that Telegram made their own API to make bot creation easier was like a revelation : we could have our own WalriiBot! I still don't know where it could be handy, so I started to code something to allow to be extended once we get some really useful uses to it.

This comes this repository (https://github.com/Eiyeron/telegram-bot-api). Basically, it's the core of the future bot. It allow the dev to get an access to the API and link plugins/handlers which will be notified when something that they expect occurs.

So yeah, we'll have soon our own fully fledged WalriiBot. Also some keep asking me to make this the Telegram<->IRC link. Why not? But I'll need some help on the IRC part, if something is brave enough to fight the Mighty Python at my sides!

Edit : Here goes the W-800 (previously WalriiBot) repository : https://github.com/Eiyeron/W-800
Title: Re: [Bot][Python][Telegram] Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Snektron on June 26, 2015, 07:09:44 PM
(http://vignette3.wikia.nocookie.net/shipoffools/images/8/85/Ball-Python-photos_(8).jpg/revision/latest?cb=20140522200456)
Python approves

Anyway, cool idea :D Though im not much on telegram. I was getting annoyed by all the notifications so i disabled them :P
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 26, 2015, 07:11:17 PM
Well, it'd be a good reason for ya to come back among us and program some fun functions to us!
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Dream of Omnimaga on June 27, 2015, 04:52:28 AM
Yeah I have notifications disabled for the NSFW group. I have them enabled for the main group, but it depends if I am trying to sleep and don't want my phone to vibrate every 3 second.

And yeah Eiyeron this project idea was why I brought up that topic http://codewalr.us/index.php?topic=562.0 . Of course, Street is against linking the current group up with IRC since it's meant to be private, but I guess we could have an alternate public group that is still invite-only, but with the chat being possible on both IRC and Telegram's ends. More importantly, though, new post notifications would be nice for new people who are not aware yet about the two post notifier softwares. But yeah for a Telegram <-> IRC link, there is already a software for that on Github in the other thread, if you don't feel like doing one from scratch. :P
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 27, 2015, 10:39:53 PM
For now, it replies when one says "/walrii" as a test for my command dispatcher I just created. Commands are strings treated as pattern mzatching the beginning of a received message. If the pattern for a callback matches, the callback will be sent. Nothing more complicated.
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Dream of Omnimaga on June 28, 2015, 02:40:14 AM
Does everyone see the replies?
Title: Re: [Bot][Python][Telegram] Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Snektron on June 28, 2015, 09:24:31 AM
I think so. If Eiyeron says /walrii a walrii appears :)
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 28, 2015, 07:55:11 PM
Actually it just "resends" the sticker we created. It doesn't upload anything. I have to test if the upload routines work.
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 30, 2015, 10:55:24 AM
Also update time : More error catches to avoid the bot going seppuku at the first bad request, splitting the update system form the API itself and testing file uploads.
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: novenary on June 30, 2015, 10:59:14 AM
Sounds fun. Do you use an asynchronous library to communicate with the server ?
Title: Re: Telegram Bot API / WalriiBot / Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on June 30, 2015, 11:02:33 AM
No. I wanted to get a webhook working (getting updates fro mTelegram's server by playing the role of a mini-server and couldn't do the job as I only get in loop the frigging same update (WalriiBot getting in the chat). So , I had to switch over a getUpdates loop to fetch the updates and pass them to the handlers. An async loop can be doable as the API is now independant from the update loop. Put your update in a thread and you should be able to send requests and to control the loop remotely. :D
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on July 02, 2015, 11:53:43 AM
Edit : here goes the source of the bot. It still needs to be commented or to be given a README but the thing is there. https://github.com/Eiyeron/W-800

Edit2 : /xkcd [comic_number] and /ddg search_term are added
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Dream of Omnimaga on July 06, 2015, 03:38:12 AM
Thanks for this bot. I wonder if it would be easy to implement post notifications?
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: bb010g on July 06, 2015, 03:41:32 AM
For everyone interested in Telegram bot development, there's a Telegram group that you can join at http://liberbot.meteor.com/.
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on July 20, 2015, 03:40:34 PM
Big big update time : Merged file_upload branch as it's checked as working, commented functions, got help from someone into making the Model functions less cty. Well, this project is getting more and more better.
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Dream of Omnimaga on July 21, 2015, 05:56:34 AM
What does file upload do? Does it take images that we post on Telegram then upload them on Imgur or something like that so that they are visible on IRC?
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on August 22, 2015, 10:37:12 AM
You are sending files on Telegram's server as you would on a normal client.

Also update : file uploading/resending works perfectly. Fixed a few quirks about replies and almost the whole API is covered. I only lack a simple function.
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Dream of Omnimaga on August 23, 2015, 01:16:38 AM
Cool to hear. :) I'm still hoping that one day it will be possible to make Telegram pictures visible in IRC (perhaps compressed to save bandwidth)

On a side note, there is a bug when an user quits IRC: It always shows I| quitting as well afterward, using the same quit message as the person:

QuoteYukiBot, [22.08.15 18:10]
<I|> 2 2* gbl08ma has quit #CodeWalrus (Ping timeout: 483 seconds)

YukiBot, [22.08.15 18:10]
* I| quit IRC (#CodeWalrus (Ping timeout: 483 seconds))

Do you know why that might be happening?
Title: Re: Telegram Bot API / W-800/ Telegram&IRC link?
Post by: Duke "Tape" Eiyeron on August 23, 2015, 07:02:06 AM
I'd say he's going out with said user to ho him/her going home. (I don't have a clue about Juju's bot. I should have access first to its source first)