本文整理匯總了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