send message without context/update #2428
Unanswered
yasuoiwakura
asked this question in
Q&A
Replies: 1 comment
-
You can (basically): You don't even need |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
hi there,
i'm running a bot to check the weather hourly and then post it to 1-2 channel if conditions meet (in my case: if the active Pokemon Go raidboss is boosted by the current weather then tell players)
But i have to start the bot manually using /set or something like that to
context.bot.send_message(chat_id=db['chats']['TestG']['chat_id'], text=text)
how to send messages without "context"? Just send a message to the given channel?
so how can i just send a message from a plain function without any given args?
`def msg():
text=f"my fancy text"
send_message(chat_id=-100123456, text=text)
return None
updater = Updater(TOKEN, persistence=persistence)
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("help", help))
if name == 'main':
main()`
The point is, i want to run hourly updates and THEN decide whom to send the messages.
i currently use the examples pollbot.py timerbot.py but they all use context to some user message HAS to trigger the timer to start running.
so why i just cannot just use updater.send_message() just want to use the bot and not any handler/context/update...
Beta Was this translation helpful? Give feedback.
All reactions