B
B
Bexruz Sayfiddinov2021-01-13 21:55:08
Telegram
Bexruz Sayfiddinov, 2021-01-13 21:55:08

Need to take channel_id and post_text from the database?

code:
@bot.channel_post_handler(content_types=['video', 'photo', 'audio', 'document'])
def post_change(message):
# try:
con = sql.connect('user.db')
cur = con.cursor()
t = cur.execute("SELECT post_text FROM user WHERE user_id = (?)", (message.from_user.id,))
ch = cur.execute("SELECT channel_id FROM user WHERE user_id = (?) ", (message.from_user.id,))
post_text = t.fetchone()
channel = ch.fetchone()
con.commit()
con.close()

if message.caption:
bot.edit_message_caption(chat_id=channel, message_id= message.message_id,
caption=message.caption + '\n\n' + post_text)
else:
bot.edit_message_caption(chat_id=channel, message_id=message.message_id, caption='' + '\n\n' + post_text)
# except:
# bot.send_message(message.chat.id, '⚠️ Xatolik yuz berdi\nQayta urinib curing!')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question