本文整理汇总了Python中config.TOKEN属性的典型用法代码示例。如果您正苦于以下问题:Python config.TOKEN属性的具体用法?Python config.TOKEN怎么用?Python config.TOKEN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类config
的用法示例。
在下文中一共展示了config.TOKEN属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import config [as 别名]
# 或者: from config import TOKEN [as 别名]
def main():
# Create the Updater and pass it your bot's token.
updater = Updater(TOKEN, workers=10, use_context=True)
# Get the dispatcher to register handlers
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", help))
dp.add_handler(CommandHandler("help", help))
dp.add_handler(CommandHandler("welcome", set_welcome))
dp.add_handler(CommandHandler("goodbye", set_goodbye))
dp.add_handler(CommandHandler("disable_goodbye", disable_goodbye))
dp.add_handler(CommandHandler("lock", lock))
dp.add_handler(CommandHandler("unlock", unlock))
dp.add_handler(CommandHandler("quiet", quiet))
dp.add_handler(CommandHandler("unquiet", unquiet))
dp.add_handler(MessageHandler(Filters.status_update, empty_message))
dp.add_error_handler(error)
updater.start_polling(timeout=30, clean=True)
updater.idle()
示例2: main
# 需要导入模块: import config [as 别名]
# 或者: from config import TOKEN [as 别名]
def main():
updater = Updater(token=config.TOKEN,use_context=True)
dispatcher = updater.dispatcher
updater.dispatcher.add_handler(CommandHandler('start', start))
dispatcher.add_handler(MessageHandler(Filters.document,file_handler))
updater.start_polling()
示例3: track_express
# 需要导入模块: import config [as 别名]
# 或者: from config import TOKEN [as 别名]
def track_express(message):
"""
get_season_count text/voice message, all digits means express id. Otherwise sends Turing or refuse message
:param message: Telegram message sent by user.
:return: None
"""
if os.name == 'nt':
temp = os.environ.get('TMP')
else:
temp = '/tmp'
if message.voice:
bot.send_chat_action(message.chat.id, 'record_audio')
# download the file
file_info = bot.get_file(message.voice.file_id)
voice_file = requests.get('https://api.telegram.org/file/bot{0}/{1}'.format(TOKEN, file_info.file_path))
file_path = os.path.join(temp, message.voice.file_id + '.ogg')
with open(file_path, 'wb') as f:
f.write(voice_file.content)
message.text = utils.voice_to_text(file_path)
if u'4C7' in message.text:
bot.send_chat_action(message.chat.id, 'typing')
r = utils.reply_refuse()
bot.send_message(message.chat.id, r)
elif message.text.isdigit():
bot.send_chat_action(message.chat.id, 'typing')
r = kuaidi100.receiver(message.text, message.message_id, message.chat.id)
if u'单号不存在或者已经过期' in r:
bot.reply_to(message, '汝的单号可能刚刚生成,暂无信息,不如稍后试试?')
else:
bot.reply_to(message, r, parse_mode='Markdown')
# use turing bot
elif TURING_KEY == '':
bot.send_chat_action(message.chat.id, 'typing')
r = utils.reply_refuse()
bot.send_message(message.chat.id, r)
else:
bot.send_chat_action(message.chat.id, 'typing')
r = turing.send_turing(TURING_KEY, message.text, message.chat.id)
bot.send_message(message.chat.id, r)
return r