Answer the question
In order to leave comments, you need to log in
How to normally run a python bot on heroku?
I wanted to create a "single-cell" bot for telegrams. I found an elementary simple solution on the Internet, successfully adjusted it to my needs and tested it thanks to PyCharm on my hardware. After all of the above, a logical question arose: how to make the bot work 24/7. Useful to look for free hosting and stumbled upon Heroku. After I figured it out, it's time to test my work. And here it is the moment of truth: there are no errors, no warnings, everything seems to be fine. But I did not take into account one factor: when the bot connects from a new device, it needs authorization (it asks for a phone number, then a confirmation code). And that's it! This is where I hung. I tried different ways to avoid authorization, but I can't think of anything.
(I tried to run through the Heroku bash console, but this starts a separate session)
So the question itself is: How can I start the bot so that I can manually log into the account, and it will continue to work on its own or how to log in to the bot running hosting?
from telethon import TelegramClient, events
api_id = '5555555'
api_hash = 'a1a1a1a1aa1a1a1a1a1a1a1a'
client = TelegramClient('anon', api_id, api_hash)
client.start()
@client.on(events.NewMessage(-111111111111))
async def main(event):
await client.send_message(-2222222222222, event.message)
client.run_until_disconnected()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question