telepot sendPhoto not wokring

138 views Asked by At

I use send photo and get the error global name 'chat_id is not defined. If i add a caption it says it is an invalid keywork even though it is in the docs

def on_chat_message(msg):
global chat_id
global disable_web_page_preview
content_type, chat_type, chat_id = telepot.glance(msg)




def on_callback_query(msg):
global chat_id
global disable_web_page_preview

query_id, from_id, query_data = telepot.glance(msg, flavor='callback_query')
print('Callback Query:', query_id, from_id, query_data)

if query_data == 'a':
        bot.sendMessage(chat_id,'Highest quality products', reply_markup =     InlineKeyboardMarkup(inline_keyboard=[
                                [InlineKeyboardButton(text="---",callback_data='c'),     InlineKeyboardButton(text="----",callback_data='d')]
                                
                            ]
                            ))



if query_data == 'd':
    bot.sendPhoto(chat_id, photo=open('/Pictures/---', 'c---.jpg'))


        
bot = telepot.Bot('----')
MessageLoop(bot, {'chat': on_chat_message,
              'callback_query': on_callback_query}).run_as_thread()
print('Listening ...')

while 1:
time.sleep(10)

My code runs in linux terminal and messages are sent fine but as soon as i try to send photo i get errors

1

There are 1 answers

1
javadfarah On

telepot not updating anymore and the code is archived in github. use python-telegram-bot instead