当前位置: 首页>>代码示例>>Python>>正文


Python config.TOKEN属性代码示例

本文整理汇总了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() 
开发者ID:jh0ker,项目名称:welcomebot,代码行数:25,代码来源:bot.py

示例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() 
开发者ID:zume2020,项目名称:Telegram-bot-Google-Drive,代码行数:8,代码来源:bot.py

示例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 
开发者ID:BennyThink,项目名称:ExpressBot,代码行数:45,代码来源:main.py


注:本文中的config.TOKEN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。