[第21天]理财达人Mx. Ada-Telegram Bot-start测试

前言

本文说明使用Python建立Telegram Bot-start测试 。

程序实作

程序

from telegram.ext import Updater,CommandHandler

def start(bot, update): # 新增指令/start
    message = update.message
    chat = message['chat']
    update.message.reply_text(text='Hello  ' + str(chat['first_name']))    

def main() -> None:
	# 创建一个Updater,并填入所申请之API TOKEN
	updater = Updater("YOUR API TOKEN", use_context=False)
	# 定义一个dispatcher
	dispatcher = updater.dispatcher
	# 使用CommandHandler定义一个Handler
	start_handler = CommandHandler('start', start)
	# 让dispatcher注册一个 handlers
	dispatcher.add_handler(start_handler)
	# 启始Bot
	updater.start_polling()
    # 按Ctrl + C 进行终止Bot 
	updater.idle()

if __name__ == '__main__':
    main()

Telegran Bot 测试成果

https://ithelp.ithome.com.tw/upload/images/20211006/201071433m0UqXSq7M.png

小结

利用python-telegram-bot模组,使用Updater、CommandHandler套件进行建立一个Start Telegram Bot。


<<:  Day22 Vue 认识Porps(1)

>>:  网路渗透测试工具-Legion

Vue3 ( JsES6、this、指令、OptionAPI ) -1

1.v-mould写入、渲染 (1) (2) (3) (4) (5) (6) 重点: 1.阵列 与 ...

SSL凭证检测工具-SSL Lab

昨天讲完XSS的评估小工具後 接着是测试最最常见SSL凭证的漏洞 我们可以利用线上工具SSL Lab...

DAY15 - 处理/读取档案不可或缺的FileReader

前几天,我们已经认识了跟档案相关的物件,包含:Blob, File, FileList, arryB...

Day13 NiFi - Variables & Parameters

今天要来讲的主题是 - Variables & Parameters。如果读者们还记得 Fl...

【Day28】Git 版本控制 - GitBook 简介

今天来介绍一个酷东西:GitBook 图片取自 GitBook 官网 GitBook GitBook...