chat id, then bot sends a message to that chat id.
But if user enter a wrong chat id, or a chat id that doesn't exists at all, bot gets errors.
(Chat id not found)
How can I solve it?
Or how can I check if chat id exists, then try to send messages?
I can't figure out what's the problem, can u show the code snippet?
try: context.bot.send_photo(chat_id=to_text[0], photo=open(f'''{update.message.chat_id} - to user.jpg''', 'rb'), caption=update.message.caption) to_text.clear() update.message.reply_text('پیام شما برای کاربر ارسال شد') return ConversationHandler.END except: update.message.reply_text('ارسال پیام با خطا مواجه شد') return ConversationHandler.END caused error ====> Chat not found
try: context.bot.send_photo(chat_id=to_text[0], photo=open(f'''{update.message.chat_id} - to user.jpg''', 'rb'), caption=update.message.caption) to_text.clear() update.message.reply_text('پیام شما برای کاربر ارسال شد') return ConversationHandler.END except: update.message.reply_text('ارسال پیام با خطا مواجه شد') return ConversationHandler.END
im trying to send code bu group bot deletes it
Use something like pastebin
how does it help ?
The group bot won't delete it if you share a link to pastebin
aha... about that tnx
aha... about that tnx
Any reason you copy messages from other users?
Because you help me yesterday sir, one last question, if I store every update in db (big data analysis later) can I use update ID as key? Will it always be unique
https://core.telegram.org/bots/api#update
This does not answer question. Because update can be random but still unique, or not unique. And first sentence says "update unique identifier"
Random has never meant unique. They are unique as long as they traverse up, but not after they get randomized, is how I read that.
I never have a week of downtime, this means they can stay unique forever?
Why do you want to use the update_id anyway? Any particular reason?
I was playing with the idea of using it as a database key, so I got curious if it is actually unique, just curiosity really
But why exactly use the update_id as database key? Why not message_id?
Not every update has a message in it.
So you want to store each and every update in the database?
Yes, I've been doing that.
Обсуждают сегодня