Перейти в чат

BotAPITamTam Python-библиотека

1
from botapitamtam import BotHandler import urllib bot = BotHandler('ChRrqzD0j3cnn4usNAcL9hO-km6fyPL-vpJuPoX08xY') def url_encode(txt): return urllib.parse.quote(txt) def main(): res_len = 0 marker = None while True: update = bot.get_updates(marker) if update is None: # проверка на пустое событие, если пусто - возврат к началу цикла continue marker = bot.get_marker(update) updates = update['updates'] for last_update in list(updates): # формируем цикл на случай если updates вернул список из нескольких событий type_upd = bot.get_update_type(last_update) text = bot.get_text(last_update) chat_id = bot.get_chat_id(last_update) payload = bot.get_payload(last_update) if text != None: bot.send_message("Привет", chat_id) if _name_ == '_main_': try: main() except KeyboardInterrupt: exit()