franciscod / telegram-twitter-forwarder-bot

A Telegram bot that forwards Tweets
GNU Lesser General Public License v3.0
316 stars 117 forks source link

Migrate to PTB 20.0 #74

Open Ericktz opened 1 year ago

Ericktz commented 1 year ago

I have been trying to migrate the bot to Python Telegram Bot v20.0... but I have been having problems with not being able to pass the classes correctly... I would appreciate some help...

One of the problems is that in the functional version here uses PTB v5.0... the bot is initialized with

updater = Updater(bot=TwitterForwarderBot(token, twapi))
dispatcher = updater.dispatcher
# set commands
dispatcher.add_handler(CommandHandler('start', cmd_start))

and now (v20) the ApplicationBuilder() is used, and I don't know how to start the class that forwards with the new bot instance form

application = ApplicationBuilder().token(token).build()
application.add_handler(CommandHandler("start", start))
franciscod commented 1 year ago

Hmm... It might be easier to swap PTB 5.0 for something small like aiotg rather than the whole PTB 20.0.

This was written at a time where PTB was simple and fit in my head :)

Ericktz commented 1 year ago

I totally understand Fransisco, and I appreciate a lot that you shared the code... I have seen several bots on telegram using your code... which by the way is still working your instance of the bot, but with some lags, every so often it crashes... and all the tweets arrive late.

I've had to make some tinker modifications to make it functional in the new telegram topics....

I was able to make it functional... but I would have liked to have used the new PTB20 functions, such as running a message once a day.... Job_Queue.run_daily... but I have not been able to .... I hope to try again when I have more time!