인공지능 공부/남박사의 파이썬 실전

(인프런) 파이썬 실전 텔레그램 봇 만들기 기초

import telepot 
TELEGRAM_TOKEN ="1773638001:AAEW1PwJjgrvZmSnS_SWq91tK3W-BkYGha0"

def handler(msg):
    content_type, chat_type, chat_id, msg_data, msg_id = telepot.glance(msg, long=True)

    print(msg)
    if content_type =="text":
        bot.sendMessage(chat_id, "[반사] {}".format(msg["text"]))

bot=telepot.Bot(TELEGRAM_TOKEN)
bot.message_loop(handler, run_forever=True)