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


Python Updater.idle方法代码示例

本文整理汇总了Python中telegram.ext.Updater.idle方法的典型用法代码示例。如果您正苦于以下问题:Python Updater.idle方法的具体用法?Python Updater.idle怎么用?Python Updater.idle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.ext.Updater的用法示例。


在下文中一共展示了Updater.idle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater("198643176:AAExGlD7Msdj9i62E6x36Vlt3JU3IoaOBlQ")

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # Add conversation handler with the states GENDER, PHOTO, LOCATION and BIO
    dtRegHandler = dreamteam.register_handler()
    dtIdleHandler = dreamteam.idle_handler()
    dtHandler = dreamteam.DTHandler()

    dp.add_handler(dtRegHandler)
    dp.add_handler(dtIdleHandler)
    dp.add_handler(dtHandler)

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:juansele,项目名称:dt-bot,代码行数:28,代码来源:bot.py

示例2: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(secrets.bot_token)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.addHandler(CommandHandler("start", start))
    dp.addHandler(CommandHandler("help", help))
    dp.addHandler(CommandHandler("random", random))
    dp.addHandler(CommandHandler("suicide", suicide))
    dp.addHandler(CommandHandler("developer", developer))

    # inline query
    dp.addHandler(InlineQueryHandler(search))


    # on noncommand i.e message - echo the message on Telegram
    dp.addHandler(MessageHandler([Filters.text], echo))

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:celisflen-bers,项目名称:TelegramSGirlsBot,代码行数:33,代码来源:app.py

示例3: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(token="BOT_TOKEN")

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # simple start function
    dp.add_handler(CommandHandler("start", start_callback))

    # Add command handler to start the payment invoice
    dp.add_handler(CommandHandler("shipping", start_with_shipping_callback))
    dp.add_handler(CommandHandler("noshipping", start_without_shipping_callback))

    # Optional handler if your product requires shipping
    dp.add_handler(ShippingQueryHandler(shipping_callback))

    # Pre-checkout handler to final check
    dp.add_handler(PreCheckoutQueryHandler(precheckout_callback))

    # Success! Notify your user!
    dp.add_handler(MessageHandler(Filters.successful_payment, successful_payment_callback))

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until you press Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:KenOokamiHoro,项目名称:python-telegram-bot,代码行数:35,代码来源:paymentbot.py

示例4: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():

    # Read secret token from file
    with open('easy_python_bot_token', 'r') as easy_python_bot_token_file:
        easy_python_bot_token = easy_python_bot_token_file.readline()

    # Create the EventHandler and pass it your bot's token.
    updater = Updater(easy_python_bot_token)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler([Filters.text], text_message_handler))

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:karfly,项目名称:easy_python_bot,代码行数:31,代码来源:easy_python_bot.py

示例5: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    init()

    updater = Updater(TOKEN)

    dp = updater.dispatcher
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))
    dp.add_handler(CommandHandler("ping", ping))
    dp.add_handler(CommandHandler("nyang", nyang))
    dp.add_handler(CommandHandler("rand", rand))

    dp.add_handler(CommandHandler("sysstat", lambda x, y: stat(x, y, 'sys')))
    dp.add_handler(CommandHandler("cpustat", lambda x, y: stat(x, y, 'cpu')))
    dp.add_handler(CommandHandler("memstat", lambda x, y: stat(x, y, 'mem')))
    dp.add_handler(CommandHandler("webstat", lambda x, y: stat(x, y, 'web')))
    dp.add_handler(CommandHandler("diskstat", lambda x, y: stat(x, y, 'disk')))
    dp.add_handler(CommandHandler("procstat", lambda x, y: stat(x, y, 'proc')))
    dp.add_handler(CommandHandler("bakstat", lambda x, y: stat(x, y, 'bak')))
    dp.add_handler(MessageHandler([Filters.command], unknown))
    dp.add_handler(MessageHandler([Filters.text], echo))

    dp.add_error_handler(error)

    updater.start_polling()
    updater.idle()
开发者ID:a1sams1a,项目名称:telebot-sso,代码行数:28,代码来源:core.py

示例6: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    """Start the bot."""
    # Create the EventHandler and pass it your bot's token.
    updater = Updater("TOKEN")

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler(Filters.text, echo))

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until you press Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:ferisystem,项目名称:python-telegram-bot,代码行数:27,代码来源:echobot2.py

示例7: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and passs it your bot's token.
    updater = Updater(os.environ['LOGBOT'])

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.addHandler(CommandHandler("start", start))
    dp.addHandler(CommandHandler("help", help))

    # on noncommand i.e message - echo the message on Telegram
    dp.addHandler(MessageHandler([Filters.text],reply))

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling()

    print 'Bot Started!!\n'

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:ChatAI,项目名称:dumbots,代码行数:28,代码来源:LogBot.py

示例8: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater()

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", c.startGame))
    dp.add_handler(CommandHandler("stop", c.stop))
    dp.add_handler(CommandHandler("creategame", c.createGame))
    dp.add_handler(CommandHandler("join", c.joinGame))
    dp.add_handler(CommandHandler("game", c.getGame))
    dp.add_handler(CommandHandler("hello", c.hello))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler([Filters.text], c.checkPlays))

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:bruno-edo,项目名称:coupBot,代码行数:27,代码来源:CoupBot.py

示例9: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    mybot = Updater("368736105:AAGLQaNZ_tWNOEg5kCQ4A0M8LEdgGFitKD8", request_kwargs=PROXY)
    dp = mybot.dispatcher
    dp.add_handler(CommandHandler("start", greet_user))
    dp.add_handler(MessageHandler(Filters.text, talk_to_me))
    mybot.start_polling()
    mybot.idle()
开发者ID:Guznin,项目名称:WhiteFox,代码行数:9,代码来源:bot.py

示例10: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main(): 
    # Create the Updater and pass it your bot's token.
    updater = Updater("181752127:AAFX10TTymBCbB4_0RKG5LxtoBJKgyYUulM")

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramCommandHandler("pay", pay)
    dp.addTelegramCommandHandler("fee", fee)
    dp.addTelegramCommandHandler("history", history)
    dp.addTelegramCommandHandler("confirm", confirm)

    # on noncommand i.e message - echo the message on Telegram
    dp.addTelegramInlineHandler(inlinequery)

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling()

    # Block until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:melnychukJS,项目名称:TWHack2016Finals,代码行数:30,代码来源:bot.py

示例11: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(telegram_token)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", helper))

    # on noncommand i.e message
    dp.add_handler(MessageHandler([Filters.text], chat))

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_webhook(listen='95.163.114.6', # 95.163.114.6
                      port=80,
                      url_path='MaraphonBot',
                      key='/home/user/cert/private.key',
                      cert='/home/user/cert/cert.pem',
                      webhook_url='https://95.163.114.6:80/MaraphonBot')
    updater.idle()
开发者ID:EremeykinS,项目名称:MaraphonBot,代码行数:27,代码来源:bot.py

示例12: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    print("memers default value:")
    print(memers)

    load_memers()

    print("loaded memers:")
    print(memers)

    updater = Updater(apikey)
    dp = updater.dispatcher
    jqueue = updater.job_queue

    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))
    dp.add_handler(CommandHandler("test", test))
    dp.add_handler(CommandHandler("ping", ping))
    dp.add_handler(CommandHandler("time", time))
    dp.add_handler(CommandHandler("boat", boat))
    dp.add_handler(CommandHandler("ebin", ebin))
    dp.add_handler(CommandHandler("stats", stats))
    dp.add_handler(CommandHandler("chatinfo", chatinfo))
    dp.add_handler(CommandHandler("drop", drop))
    dp.add_handler(CommandHandler("shop", shop))
    updater.dispatcher.add_handler(CallbackQueryHandler(shopbutton))

    dp.add_handler(MessageHandler([Filters.text], parse))

    dp.add_error_handler(error)

    updater.start_polling(timeout=5)

    # Run the bot until the user presses Ctrl-C or the process receives SIGINT, SIGTERM or SIGABRT
    updater.idle()
开发者ID:Epowerj,项目名称:CancerBot,代码行数:36,代码来源:bot.py

示例13: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(telegram_token)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", helper))

    # on noncommand i.e message
    dp.add_handler(MessageHandler([Filters.text], chat))

    # inline keyboard handler
    #dp.add_handler(telegram.ext.CallbackQueryHandler(scroll))
    # TODO: update messages with time information

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_webhook(listen='95.163.114.6',
                      port=88,
                      url_path='CroCodeBot',
                      key='/home/user/cert/private.key',
                      cert='/home/user/cert/cert.pem',
                      webhook_url='https://95.163.114.6:88/CroCodeBot')
    updater.idle()
开发者ID:EremeykinS,项目名称:CroCodeBot,代码行数:31,代码来源:bot.py

示例14: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(token=API_TOKEN)

    # Get the dispatcher to register handlers
    dispatcher = updater.dispatcher

    # on different commands - answer in Telegram
    dispatcher.addTelegramCommandHandler('start', start_command)
    dispatcher.addTelegramCommandHandler('help', help_command)
    dispatcher.addTelegramCommandHandler('download', download_command)
    dispatcher.addTelegramCommandHandler('status', status_command)

    # on noncommand i.e message - echo the message on Telegram
    dispatcher.addTelegramMessageHandler(echo_command)

    # log all errors
    dispatcher.addErrorHandler(error_handler)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:lorenzo-camaione,项目名称:Botty,代码行数:28,代码来源:main.py

示例15: main

# 需要导入模块: from telegram.ext import Updater [as 别名]
# 或者: from telegram.ext.Updater import idle [as 别名]
def main():
    config = configparser.ConfigParser()
    config.read('config.ini')
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(config['init']['token'])

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("add", add)
    dp.addTelegramCommandHandler("help", help)

    # on noncommand i.e message - echo the message on Telegram
    dp.addTelegramMessageHandler(message)

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
开发者ID:Virusmater,项目名称:StreetArtView-python-telegram-bot,代码行数:29,代码来源:StreetArtViewBot.py


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