本文整理汇总了Python中telegram.Updater.idle方法的典型用法代码示例。如果您正苦于以下问题:Python Updater.idle方法的具体用法?Python Updater.idle怎么用?Python Updater.idle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telegram.Updater
的用法示例。
在下文中一共展示了Updater.idle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# 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.addTelegramCommandHandler("help", home)
dp.addTelegramCommandHandler("start", home)
dp.addTelegramCommandHandler("home", home)
dp.addTelegramCommandHandler("botinfo", botinfo)
dp.addTelegramCommandHandler("mensa", mensa)
dp.addTelegramCommandHandler("aulastudio", aulastudio)
dp.addTelegramCommandHandler("biblioteca", biblioteca)
for command in commands:
dp.addTelegramCommandHandler(command, replier)
dp.addTelegramMessageHandler(position)
dp.addErrorHandler(error)
updater.start_polling()
updater.idle()
示例2: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
global logger
# load the logging configuration
real_path = os.path.dirname(os.path.realpath(__file__))
logging.config.fileConfig(real_path + '/logging.ini')
logger = logging.getLogger(__name__)
# Get the dispatcher to register handlers
updater = Updater(token="TOKEN")
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("roll", Dice.roll)
# log all errors
dp.addErrorHandler(error)
logger.info('Starting new bot')
roll()
# Start the Bot
updater.start_polling()
# Block 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()
示例3: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# Create the EventHandler and pass it your bot's token.
updater = Updater("135342801:AAFaninNSzDkYU8UzonHeOhcu5fVaPlCC7Y")
# Get the dispatcher to register handlers
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("help", help)
# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(echo)
# log all errors
dp.addErrorHandler(error)
# Start the Bot
updater.start_polling()
runloop()
# 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()
示例4: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# 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.addTelegramCommandHandler("help", help)
dp.addTelegramCommandHandler("start", home)
dp.addTelegramCommandHandler("home", home)
dp.addTelegramCommandHandler("price", price)
dp.addTelegramCommandHandler("register", register)
dp.addTelegramCommandHandler("balances", balances)
dp.addTelegramCommandHandler("transactions", transactions)
dp.addTelegramCommandHandler("trades", trades)
dp.addTelegramCommandHandler("tickers", tickers)
dp.addTelegramCommandHandler("discounts", discounts)
dp.addTelegramCommandHandler("delete_keys", deleteKeys)
dp.addTelegramCommandHandler("bitcoin_data", bitcoinData)
dp.addTelegramCommandHandler("orders", orders)
for fund in FUNDS:
dp.addTelegramCommandHandler(('tr_' + fund), fundTrades)
dp.addTelegramCommandHandler(('tick_' + fund), ticker)
dp.addTelegramCommandHandler(('ord_'+fund), fundOrders)
for currency in CURRENCIES:
dp.addTelegramCommandHandler(('disc_' + currency), currDiscount)
dp.addTelegramMessageHandler(signup)
dp.addErrorHandler(error)
updater.start_polling()
updater.idle()
示例5: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
cnf = loadConfig()
TOKEN = cnf["token"]
games = cnf["games"]
print "games in: ", games
# 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.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("help", help)
dp.addTelegramCommandHandler("list_games", ls_closure(cnf))
dp.addTelegramCommandHandler("start_game", start_closure(cnf))
dp.addTelegramCommandHandler("update", update_cmd)
# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(process_message_closure(cnf))
# 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()
示例6: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# Create the EventHandler and pass it your bot's token.
updater = Updater("166865409:AAGSAEVXHyP1NlQaDOj65z4F9OgX5sarpGg")
# Get the dispatcher to register handlers
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.addTelegramCommandHandler("boz", startHandler)
dp.addTelegramCommandHandler("muto", stopHandler)
dp.addTelegramCommandHandler("help", helpHandler)
# on noncommand i.e message - send a proper message on Telegram
dp.addTelegramMessageHandler(messageHandler)
# log all errors
dp.addErrorHandler(errorHandler)
# 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()
示例7: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
"""Main program"""
# Create the EventHandler and pass it your bot's token.
updater = Updater(token='KEY')
# Get the dispatcher to register handlers
dispatcher = updater.dispatcher
# on different commands - answer in Telegram
dispatcher.addTelegramCommandHandler('start', start)
dispatcher.addTelegramCommandHandler('nuevavotacion', newpoll)
dispatcher.addTelegramCommandHandler('respuesta', response)
dispatcher.addTelegramCommandHandler('iniciovotacion', initpoll)
dispatcher.addTelegramCommandHandler('finvotacion', endpoll)
dispatcher.addUnknownTelegramCommandHandler(unknown)
# on noncommand i.e message
dispatcher.addTelegramMessageHandler(receiver)
# 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()
示例8: IngressoRapidoBot
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
class IngressoRapidoBot(object):
# Mapa de comandos -> funções de tratamento
commands = {
'start': start_handler,
'eventosnodia': events_on_handler,
'eventosem': events_at_handler,
'eventosdotipo': events_type_handler,
'busca': search_handler,
'eventosnoperiodo': events_between_handler,
'mais': more_handler,
'shows': shows_handler,
'festas': parties_handler,
'cinema': cinema_handler,
'esportes': sports_handler,
'teatro': theater_handler
}
def __init__(self, token):
self.updater = Updater(token=token)
dispatcher = self.updater.dispatcher
for cmd, cmd_handler in self.commands.iteritems():
dispatcher.addTelegramCommandHandler(cmd, cmd_handler)
def run(self):
self.updater.start_polling()
self.updater.idle()
示例9: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# Create the EventHandler and pass it your bot's token.
updater = Updater(private_conf.tokenid)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# on different commands - answer in Telegram
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("subscribe_op", subscribe_op)
dp.addTelegramCommandHandler("help", help)
dp.addTelegramCommandHandler("leeop",leeop)
#run One Piece manga checker
run_op(updater.bot)
# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(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()
示例10: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
# Create the EventHandler and pass it your bot's token.
updater = Updater(settings.TG_API_KEY)
# 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("on", cmd_on)
dp.addTelegramCommandHandler("off", cmd_off)
dp.addTelegramCommandHandler("check", cmd_check)
# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(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()
示例11: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
"""Defining the main function"""
global JOB_QUEUE
news.create_news_json()
utils.load_subscribers_json()
config = utils.get_configuration()
token = config.get('API-KEYS', 'TelegramBot')
debug = config.getboolean('UTILS', 'Debug')
logger = utils.get_logger(debug)
updater = Updater(token)
JOB_QUEUE = updater.job_queue
notify_news(updater.bot)
dispatcher = updater.dispatcher
dispatcher.addTelegramCommandHandler("start", start_command)
dispatcher.addTelegramCommandHandler("help", help_command)
dispatcher.addTelegramCommandHandler("news", news.news_command)
dispatcher.addTelegramCommandHandler("newson", newson_command)
dispatcher.addTelegramCommandHandler("newsoff", newsoff_command)
dispatcher.addTelegramCommandHandler("prof", other_commands.prof_command)
dispatcher.addTelegramCommandHandler("segreteria", other_commands.student_office_command)
dispatcher.addTelegramCommandHandler("mensa", other_commands.canteen_command)
dispatcher.addTelegramCommandHandler("adsu", other_commands.adsu_command)
# For Testing only
dispatcher.addTelegramCommandHandler("commands_keyboard", commands_keyboard)
logger.info('Bot started')
updater.start_polling()
updater.idle()
示例12: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
thread.start_new_thread(checkFlood, (2,))
updater = Updater(botID)
dp = updater.dispatcher
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("google", google)
dp.addErrorHandler(error)
updater.start_polling()
updater.idle()
示例13: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
updater = Updater(TOKEN)
# Get the dispatcher to register handlers
dp = updater.dispatcher
# Add handlers for Telegram commands
for (name, f) in bot_functions.items():
dp.addTelegramCommandHandler(name, f)
dp.addTelegramMessageHandler(bank_name_answer_handler)
updater.start_polling()
updater.idle()
示例14: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
updater = Updater(token='TOKEN')
dp = updater.dispatcher
dp.addTelegramCommandHandler('start', start)
dp.addTelegramCommandHandler('help', help)
dp.addTelegramCommandHandler('log', log)
dp.addTelegramCommandHandler('test', test)
dp.addTelegramMessageHandler(echo)
dp.addErrorHandler(error)
updater.start_polling()
updater.idle()
示例15: main
# 需要导入模块: from telegram import Updater [as 别名]
# 或者: from telegram.Updater import idle [as 别名]
def main():
updater=Updater("136820376:AAFgZ66FHblXImb0m-QyHj5i4gZAQ-5sN_c")
dp=updater.dispatcher
dp.addTelegramCommandHandler("start", start)
dp.addTelegramMessageHandler(startReturnThread)
dp.addErrorHandler(error)
updater.start_polling()
updater.idle()