本文整理汇总了Python中telegram.Updater类的典型用法代码示例。如果您正苦于以下问题:Python Updater类的具体用法?Python Updater怎么用?Python Updater使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Updater类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
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()
开发者ID:mikexine,项目名称:univeronabot,代码行数:26,代码来源:bot.py
示例2: main
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()
开发者ID:Ziul,项目名称:DeDBot,代码行数:27,代码来源:main.py
示例3: main
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()
开发者ID:criado,项目名称:Comeisbot,代码行数:29,代码来源:comeisbot.py
示例4: main
def main():
random.seed(None)
updater = Updater(token='<YOUR_TOKEN>')
dispatcher = updater.dispatcher
dispatcher.addTelegramMessageHandler(echo)
dispatcher.addTelegramCommandHandler('boobs', echo)
updater.start_polling()
开发者ID:kazin8,项目名称:Boobsik,代码行数:7,代码来源:Boobsik.py
示例5: IngressoRapidoBot
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()
开发者ID:thspinto,项目名称:TalkTechHackthon,代码行数:28,代码来源:irbot.py
示例6: main
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()
开发者ID:LombardIT,项目名称:TheRockBot,代码行数:32,代码来源:bot.py
示例7: main
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()
开发者ID:mjota,项目名称:VotaBot,代码行数:26,代码来源:main.py
示例8: main
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()
开发者ID:jgargallo,项目名称:heating-telegram-bot,代码行数:27,代码来源:heatbot.py
示例9: main
def main():
# Create the EventHandler and pass it your bot's token.
token = os.environ["TOKEN"]
updater = Updater(token, workers=10)
# Get the dispatcher to register handlers
dp = updater.dispatcher
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("blue", blue)
dp.addStringCommandHandler("reply", cli_reply)
dp.addUnknownStringCommandHandler(unknown_cli_command)
dp.addStringRegexHandler("[^/].*", cli_noncommand)
dp.addErrorHandler(error)
# Start the Bot and store the update Queue, so we can insert updates
update_queue = updater.start_polling(poll_interval=0.1, timeout=20)
# Start CLI-Loop
while True:
try:
text = raw_input()
except NameError:
text = input()
# Gracefully stop the event handler
if text == "stop":
updater.stop()
break
# else, put the text into the update queue
elif len(text) > 0:
update_queue.put(text) # Put command into queue
开发者ID:Bluelytics,项目名称:bluebot,代码行数:35,代码来源:bluebot.py
示例10: main
def main():
updater = Updater(man.settings["authkey"])
dp = updater.dispatcher
dp.addTelegramCommandHandler("reactio", reactio)
dp.addTelegramCommandHandler("kuva", kuva)
#dp.addTelegramCommandHandler("kiusua", insult)
#dp.addTelegramCommandHandler("new_insult", new_insult)
dp.addTelegramMessageHandler(jutku)
dp.addErrorHandler(error)
update_queue = updater.start_polling(poll_interval=0.1, timeout=10)
while True:
try:
text = input()
except NameError:
text = input()
# Gracefully stop the event handler
if text == 'stop':
updater.stop()
break
# else, put the text into the update queue to be handled by our handlers
elif len(text) > 0:
update_queue.put(text)
开发者ID:appleflower,项目名称:tele-reactio,代码行数:27,代码来源:main.py
示例11: main
def main():
### Updater será vinculado ao token informado,
### no caso, o token do grupo Brail Linux se não
### for mais release candidate
if RELEASE_CANDIDATE:
TOKEN2USE = TOKEN['rc']
else:
TOKEN2USE = TOKEN['released']
updater = Updater(TOKEN2USE , workers=10)
# Get the dispatcher to register handlers (funcoes...)
dp = updater.dispatcher
### Adiciona comandos ao handler...
### Loop pela lista com todos comandos
for lc in ALL_COMMANDS:
add_handler(dp, lc, isADM=False)
### Adiciona comandos adm ao handler
### É preciso por o flag isADM como true...
for lca in ALL_COMMANDS_ADMS:
add_handler(dp, lca, isADM=True)
### aqui tratamos comandos não reconhecidos.
### Tipicamente comandos procedidos por "/" que é o caracter
### default para comandos telegram
dp.addUnknownTelegramCommandHandler(showUnknowncommand)
### Loga todas mensagens para o terminal
### Pode ser util para funcoes anti-flood
dp.addTelegramMessageHandler(message)
### Aqui logamos todos erros que possam vir a acontecer...
dp.addErrorHandler(errosHandler)
# Start the Bot and store the update Queue, so we can insert updates
update_queue = updater.start_polling(poll_interval=0.1, timeout=10)
### Aqui lemos o dicionarios de usuarios do disco
##- global USERS
##- USERS =
logging.info('Quantia de users no DB: {udb}.'.format(udb=len(USERS)))
for u in USERS:
logging.info('User {un}, id: {uid}'.format(un=USERS[u]['username'],uid=u))
# Start CLI-Loop and heartbeat
while True:
try:
text = raw_input()
except NameError:
text = input()
# Gracefully stop the event handler
if text == 'stop':
updater.stop()
break
# else, put the text into the update queue to be handled by our handlers
elif len(text) > 0:
update_queue.put(text)
开发者ID:jpedrogarcia,项目名称:botTelegram,代码行数:60,代码来源:brasil.py
示例12: main
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()
开发者ID:bradparks,项目名称:UnivaqInformaticaBot,代码行数:35,代码来源:botcore.py
示例13: main
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()
开发者ID:Firebird1993,项目名称:BozBot,代码行数:25,代码来源:main.py
示例14: main
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()
开发者ID:prasenmsft,项目名称:whatsapp,代码行数:25,代码来源:telegram_layer.py
示例15: main
def main():
config = configparser.ConfigParser()
config.read('info.ini')
token = config.get("Connection","Token")
updater = Updater(token, workers=10)
dp = updater.dispatcher
dp.addUnknownTelegramCommandHandler(unknown_command)
dp.addTelegramMessageHandler(message)
dp.addTelegramRegexHandler('.*', any_message)
dp.addStringCommandHandler('reply', cli_reply)
dp.addUnknownStringCommandHandler(unknown_cli_command)
dp.addStringRegexHandler('[^/].*', cli_noncommand)
dp.addErrorHandler(error)
update_queue = updater.start_polling(poll_interval=0.1, timeout=10)
# Start CLI-Loop
while True:
try:
text = raw_input()
except NameError:
text = input()
if text == 'stop':
fileids.close()
updater.stop()
break
elif len(text) > 0:
update_queue.put(text)
开发者ID:Stormtiel,项目名称:ashur,代码行数:35,代码来源:fileIDFinder.py
示例16: main
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()
开发者ID:LuisAyuso,项目名称:TeleAdventure,代码行数:33,代码来源:__main__.py
示例17: main
def main():
#Get bot token.
Config = ConfigParser.ConfigParser()
Config.read("./jabberwocky.cfg")
#Create event handler
updater = Updater(Config.get("BotApi", "Token"))
dp = updater.dispatcher
#Add handlers
dp.addTelegramMessageHandler(parseMessage)
dp.addTelegramCommandHandler("apologize", apologize)
#Start up bot.
updater.start_polling()
while True:
if debug:
cmd = raw_input("Enter command...\n")
if cmd == 'list':
print 'Nouns:'
print nouns.values
print 'Verbs:'
print verbs.values
print 'Adverbs:'
print adverbs.values
print 'Numbers:'
print numbers.values
print 'Adjectives:'
print adjectives.values
print 'Garbage:'
print garbage.values
#Force generation of a random sentence.
elif cmd == 'forceprint':
m = markov.Markov(nouns, adjectives, verbs, adverbs, numbers, pronouns, prepositions, conjunctions, vowels, garbage)
print m.string
#Shutdown bot.
elif cmd == 'quit':
updater.stop()
sys.exit()
elif cmd == 'help':
print 'Commands are: list, forceprint, quit.'
else:
print 'Commmand not recognized.'
else:
time.sleep(1)
开发者ID:algidseas,项目名称:JabberwockyBot,代码行数:59,代码来源:jabberwocky.py
示例18: test_inUpdater
def test_inUpdater(self):
u = Updater(bot="MockBot", job_queue_tick_interval=0.005)
u.job_queue.put(self.job1, 0.5)
sleep(0.75)
self.assertEqual(1, self.result)
u.stop()
sleep(2)
self.assertEqual(1, self.result)
开发者ID:Suyashc1295,项目名称:python-telegram-bot,代码行数:8,代码来源:test_jobqueue.py
示例19: test_inUpdater
def test_inUpdater(self):
print('Testing job queue created by updater')
u = Updater(bot="MockBot", job_queue_tick_interval=0.005)
u.job_queue.put(self.job1, 0.1)
sleep(0.15)
self.assertEqual(1, self.result)
u.stop()
sleep(0.4)
self.assertEqual(1, self.result)
开发者ID:azigran,项目名称:python-telegram-bot,代码行数:9,代码来源:test_jobqueue.py
示例20: main
def main():
# Create the EventHandler and pass it your bot's token.
token = 'token'
updater = Updater(token, workers=2)
# Get the dispatcher to register handlers
dp = updater.dispatcher
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("help", help)
dp.addUnknownTelegramCommandHandler(unknown_command)
dp.addTelegramMessageHandler(message)
dp.addTelegramRegexHandler('.*', any_message)
dp.addStringCommandHandler('reply', cli_reply)
dp.addUnknownStringCommandHandler(unknown_cli_command)
dp.addStringRegexHandler('[^/].*', cli_noncommand)
dp.addErrorHandler(error)
# Start the Bot and store the update Queue, so we can insert updates
update_queue = updater.start_polling(poll_interval=0.1, timeout=20)
'''
# Alternatively, run with webhook:
updater.bot.setWebhook(webhook_url='https://example.com/%s' % token,
certificate=open('cert.pem', 'rb'))
update_queue = updater.start_webhook('0.0.0.0',
443,
url_path=token,
cert='cert.pem',
key='key.key')
# Or, if SSL is handled by a reverse proxy, the webhook URL is already set
# and the reverse proxy is configured to deliver directly to port 6000:
update_queue = updater.start_webhook('0.0.0.0',
6000)
'''
# Start CLI-Loop
while True:
try:
text = raw_input()
except NameError:
text = input()
# Gracefully stop the event handler
if text == 'stop':
updater.stop()
break
# else, put the text into the update queue
elif len(text) > 0:
update_queue.put(text) # Put command into queue
开发者ID:jgrondier,项目名称:python-telegram-bot,代码行数:56,代码来源:updater_bot.py
注:本文中的telegram.Updater类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论