예제 #1
0
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
0
파일: main.py 프로젝트: Ziul/DeDBot
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
0
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)
예제 #4
0
파일: Boobsik.py 프로젝트: kazin8/Boobsik
def main():
	random.seed(None)
	updater = Updater(token='<YOUR_TOKEN>')
	dispatcher = updater.dispatcher
	dispatcher.addTelegramMessageHandler(echo)
	dispatcher.addTelegramCommandHandler('boobs', echo)
	updater.start_polling()
예제 #5
0
파일: bot.py 프로젝트: LombardIT/TheRockBot
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()
예제 #6
0
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()
예제 #7
0
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
예제 #8
0
파일: main.py 프로젝트: Firebird1993/BozBot
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()
예제 #9
0
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()
예제 #10
0
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
0
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)
예제 #12
0
def main():
    random.seed(None)
    updater = Updater(token='<YOUR_TOKEN>')
    dispatcher = updater.dispatcher
    dispatcher.addTelegramMessageHandler(echo)
    dispatcher.addTelegramCommandHandler('boobs', echo)
    updater.start_polling()
예제 #13
0
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)
예제 #14
0
    def __init__(self, token, rootpath='/opt/code/telegram-projects/'):
        self.token = token
        self.rootpath = rootpath

        print("[+] initializing telegram bot")
        self.updater = Updater(token=self.token)
        self.bot = self.updater.bot
        dispatcher = self.updater.dispatcher

        print("[+] make sure ssh-agent is running")
        if not j.sal.process.checkProcessRunning('ssh-agent'):
            j.do.execute('eval `ssh-agent`')

        # commands
        dispatcher.addTelegramCommandHandler('start', self.start)
        dispatcher.addTelegramCommandHandler('project', self.project)
        dispatcher.addTelegramCommandHandler('blueprint', self.blueprint)
        dispatcher.addTelegramCommandHandler('ays', self.ays)
        dispatcher.addTelegramCommandHandler('help', self.help)

        # messages
        dispatcher.addTelegramMessageHandler(self.message)

        # internal
        dispatcher.addUnknownTelegramCommandHandler(self.unknown)

        print("[+] projects will be saved to: %s" % rootpath)
        j.sal.fs.createDir(rootpath)

        print("[+] loading existing users")
        self.users = self.restore()
예제 #15
0
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()
예제 #16
0
파일: main.py 프로젝트: mjota/VotaBot
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()
예제 #17
0
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)
예제 #18
0
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()
예제 #19
0
    def __init__(self, refresh_users):
        self.updater = Updater(
            token="178290745:AAH_Vrkyg5f5C0NkOSUCs7kKaXcv__wUT90")
        self.dispatcher = self.updater.dispatcher

        self.dispatcher.addTelegramCommandHandler('start', self.start)
        self.dispatcher.addTelegramCommandHandler('help', self.help)
        self.dispatcher.addTelegramCommandHandler('add', self.add)
        self.dispatcher.addTelegramCommandHandler('done', self.done)
        self.dispatcher.addTelegramCommandHandler('show', self.show)
        self.dispatcher.addTelegramMessageHandler(self.echo)
        self.dispatcher.addUnknownTelegramCommandHandler(self.unknown)

        self.help_message = "The next commands are available:\n" \
                            + "- type '/start' to resend a greeting message\n" \
                            + "- type '/help' to see the help message with the list of a commands\n" \
                            + "- type '/add title' to add task with given title\n" \
                            + "- type '/done' to mark tasks as done\n" \
                            + "- type '/show' to see the full list of tasks\n"

        if refresh_users:
            self.users = {}
        else:
            try:
                with open("users.pickle", 'rb') as f:
                    self.users = pickle.load(f)
            except IOError:
                self.users = {}
예제 #20
0
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()
예제 #21
0
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()
예제 #22
0
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)
예제 #23
0
    def __init__(self, token, vk_client_id):
        self.poller = Poller()
        self.updater = Updater(token=token)
        self.vk = Vk(vk_client_id)
        self.clients = Client.all_from_db()

        self.reg_actions()
        self.restore()
예제 #24
0
 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)
 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)
예제 #26
0
 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)
예제 #27
0
 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)
예제 #28
0
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
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()
예제 #30
0
def main():
    config = configparser.ConfigParser()
    config.read('config.ini')
    token = config['authorization']['token']

    updater = Updater(token=token)
    dispatcher = updater.dispatcher

    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramMessageHandler(print_pdf)

    updater.start_polling()
예제 #31
0
def main():
    updater = Updater(config['bot_id'], workers=5)
    dispatcher = updater.dispatcher
    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramCommandHandler('help', help)
    dispatcher.addTelegramCommandHandler('ping', ping)
    dispatcher.addTelegramCommandHandler('ping6', ping6)
    dispatcher.addTelegramCommandHandler('traceroute', traceroute)
    dispatcher.addTelegramCommandHandler('traceroute6', traceroute6)
    dispatcher.addTelegramCommandHandler('down', down)
    dispatcher.addErrorHandler(error)
    updater.start_polling()
예제 #32
0
파일: main.py 프로젝트: ilevn/TBot
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()
예제 #33
0
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()
예제 #34
0
def main():
    # parse argument from command line
    parser = argparse.ArgumentParser(
        description='Personal Telegram Bot'
    )
    parser.add_argument(
        '-l',
        action='store_true',
        help='If set write log in stdout.'
    )
    args = parser.parse_args()
    global logger
    if args.l:
        logging.basicConfig(
            format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
            level=logging.INFO
        )
        logger = logging.getLogger(__name__)

    # get the updater
    updater = Updater(getToken())

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

    # Set different commands that marvin must respond
    # Fill commands hash map with
    # - key: the name of command that marvin must respond
    # - value: a tuple as (handler function, description)
    commands['start'] = (start, "start chatting with Marvin")
    commands['help'] = (help, "list the possible commands")
    commands['hi_marvin'] = (sayHello, "greeting Marvin")
    commands['introduce'] = (start, "Marvin introduce itself")
    commands['test_args'] = (testArgs, "test command")
    for k, v in commands.items():
        dp.addTelegramCommandHandler(k, v[0])
    # Handle the unrecognized command
    dp.addUnknownTelegramCommandHandler(unrecognizedCommand)

    # Implement this if you want that marvin respond to messages
    # that not start with /
    # dp.addTelegramMessageHandler()

    # If errors happens, call the function given
    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()
예제 #35
0
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()
예제 #36
0
def main():
    updater = Updater(config['bot_id'], workers=5)
    dispatcher = updater.dispatcher
    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramCommandHandler('help', help)
    dispatcher.addTelegramCommandHandler('ping', ping)
    dispatcher.addTelegramCommandHandler('ping6', ping6)
    dispatcher.addTelegramCommandHandler('traceroute', traceroute)
    dispatcher.addTelegramCommandHandler('traceroute6', traceroute6)
    dispatcher.addTelegramCommandHandler('down', down)
    dispatcher.addErrorHandler(error)
    updater.start_polling()
예제 #37
0
def main():
    config = configparser.ConfigParser()
    config.read('config.ini')
    token = config['authorization']['token']

    updater = Updater(token=token)
    dispatcher = updater.dispatcher

    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramMessageHandler(print_pdf)

    updater.start_polling()
예제 #38
0
    def __init__(self):
        self.config = configparser.ConfigParser()
        self.config.read(CONFIGFILE_PATH)

        self.updater = Updater(token=self.get_bot_conf("TOKEN"))
        self.dispatcher = self.updater.dispatcher
        self.add_handlers()

        try:
            self.tzinfo = timezone(self.get_bot_conf("TIMEZONE"))
        except:
            self.tzinfo = pytz.utc
예제 #39
0
파일: vb.py 프로젝트: RedayStudios/bot
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater("221791426:AAGRMjmhyhGehCpT0SvkYUfLBlvLtpMpB_M")
    # Get the dispatcher to register handlers
    dp = updater.dispatcher
    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramMessageHandler(echo)
    # log all errors
    dp.addErrorHandler(error)
    # Start the Bot
    updater.start_polling()
    updater.idle()
예제 #40
0
파일: bot.py 프로젝트: alroqime/welcomebot
def main():
    # Create the Updater and pass it your bot's token.
    updater = Updater(TOKEN, workers=2)

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

    dp.addTelegramCommandHandler("start", help)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramCommandHandler('welcome', set_welcome)
    dp.addTelegramCommandHandler('goodbye', set_goodbye)
    dp.addTelegramCommandHandler('disable_goodbye', disable_goodbye)
    dp.addTelegramCommandHandler("lock", lock)
    dp.addTelegramCommandHandler("unlock", unlock)
    dp.addTelegramCommandHandler("quiet", quiet)
    dp.addTelegramCommandHandler("unquiet", unquiet)

    dp.addTelegramRegexHandler('^$', empty_message)

    dp.addStringCommandHandler('broadcast', broadcast)
    dp.addStringCommandHandler('level', set_log_level)
    dp.addStringCommandHandler('count', chatcount)

    dp.addErrorHandler(error)

    # Start the Bot and store the update Queue, so we can insert updates
    update_queue = updater.start_polling(poll_interval=1, timeout=5)

    '''
    # Alternatively, run with webhook:
    updater.bot.setWebhook(webhook_url='https://%s/%s' % (BASE_URL, TOKEN))

    # 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(HOST, PORT, url_path=TOKEN)
    '''

    # Start CLI-Loop
    while True:
        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
예제 #41
0
파일: bot.py 프로젝트: obinsc/welcomebot
def main():
    # Create the Updater and pass it your bot's token.
    updater = Updater(TOKEN, workers=2)

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

    dp.addTelegramCommandHandler("start", help)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramCommandHandler('welcome', set_welcome)
    dp.addTelegramCommandHandler('goodbye', set_goodbye)
    dp.addTelegramCommandHandler('disable_goodbye', disable_goodbye)
    dp.addTelegramCommandHandler("lock", lock)
    dp.addTelegramCommandHandler("unlock", unlock)
    dp.addTelegramCommandHandler("quiet", quiet)
    dp.addTelegramCommandHandler("unquiet", unquiet)

    dp.addTelegramRegexHandler('^$', empty_message)

    dp.addStringCommandHandler('broadcast', broadcast)
    dp.addStringCommandHandler('level', set_log_level)
    dp.addStringCommandHandler('count', chatcount)

    dp.addErrorHandler(error)

    # Start the Bot and store the update Queue, so we can insert updates
    update_queue = updater.start_polling(poll_interval=1, timeout=5)
    '''
    # Alternatively, run with webhook:
    updater.bot.setWebhook(webhook_url='https://%s/%s' % (BASE_URL, TOKEN))

    # 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(HOST, PORT, url_path=TOKEN)
    '''

    # Start CLI-Loop
    while True:
        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
예제 #42
0
def main():
    # Create the EventHandler and pass it your bot's 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:
    update_queue = updater.start_webhook('example.com',
                                         443,
                                         'cert.pem',
                                         'key.key',
                                         listen='0.0.0.0')
    '''

    # 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
예제 #43
0
파일: Bot.py 프로젝트: pashna/PNP_Bot
    def __init__(self, db, chats):

        self.db = db
        self.chats = chats
        self.updater = Updater(token=GET_TOKEN())
        dispatcher = self.updater.dispatcher

        dispatcher.addTelegramCommandHandler('start', self.start)
        dispatcher.addTelegramCommandHandler('restrict', self.add_restrict)
        dispatcher.addTelegramCommandHandler('stat', self.stats)
        dispatcher.addTelegramCommandHandler('info', self.info)
        dispatcher.addTelegramCommandHandler('help', self.help)
        dispatcher.addTelegramCommandHandler('sites', self.sites)
        dispatcher.addTelegramMessageHandler(self.answer)

        self.updater.start_polling()
        self.bot = telegram.Bot(token=GET_TOKEN())

        self.statistician = Statistic(GET_FIRST_TIME(), GET_LAST_TIME(), db)
예제 #44
0
def main():
    updater = Updater(man.settings["authkey"])  #brew bot
    #updater = Updater(man.settings["authkey_gmfrpg"]) #gmf rpg
    dp = updater.dispatcher
    j_que = updater.job_queue
    j_que.put(brew_timer, 1)
    j_que.put(msg_que, 2)
    print("Brew 0.80 + Items&Drops DLC 2.0 + ILLUMICOFFEE")

    dp.addTelegramCommandHandler("brew", brew)
    dp.addTelegramCommandHandler("brew_stats", brew_stats)
    dp.addTelegramCommandHandler("brew_score", brew_score)
    dp.addTelegramCommandHandler("brew_check", brew_check)
    dp.addTelegramCommandHandler("brew_inventory", brew_inventory)
    dp.addTelegramCommandHandler("brew_cons", brew_cons)
    dp.addTelegramCommandHandler("brew_help", brew_help)
    dp.addTelegramCommandHandler("brew_status", brew_status)
    dp.addTelegramCommandHandler("rahka", rahka)
    dp.addTelegramCommandHandler("illuminati", illuminati)
    dp.addTelegramCommandHandler("illumi_shop", illumi_shop)
    dp.addTelegramCommandHandler("give_money", give_money)
    dp.addTelegramCommandHandler("terästä", terasta)
    dp.addTelegramCommandHandler("brew_notify", brew_notify)
    dp.addTelegramCommandHandler("brew_cancel", brew_cancel)

    dp.addErrorHandler(error)
    update_queue = updater.start_polling(poll_interval=2, 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)
예제 #45
0
    def __init__(self, token, adminid):
        self.adminid = adminid
        self._upd = Updater(token=token)
        self._upd.dispatcher.addTelegramMessageHandler(
            lambda bot, update, args: self.exceptionhook(
                self.onMessage, bot, update, None))
        self._upd.dispatcher.addTelegramCommandHandler(
            "start", lambda bot, update, args: self.exceptionhook(
                self.start, bot, update, None))
        self._upd.dispatcher.addTelegramCommandHandler(
            "derpibooru", lambda bot, update, args: self.exceptionhook(
                self.derpibooru_lookup, bot, update, args))
        self._upd.dispatcher.addTelegramCommandHandler(
            "advanced", lambda bot, update, args, **kwargs: self.exceptionhook(
                self.help, bot, update, None))
        self._upd.dispatcher.addTelegramCommandHandler(
            "debug", lambda bot, update, args: self.exceptionhook(
                self.debug, bot, update, args))

        self._upd.start_polling()
예제 #46
0
파일: bot.py 프로젝트: mikexine/TheRockBot
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()
def main():
    # Create the EventHandler and pass it your bot's token.
    #updater = Updater(settings.APITOKEN)
    updater = Updater(APITOKEN)

    # 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("randomvideo", randomvideo)
    dp.addTelegramCommandHandler("random", random)
    dp.addTelegramCommandHandler("caso", caso)

    # 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()
예제 #48
0
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(BOTKEY)

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

    # on different commands - answer in Telegram
    for cmd in ['up', 'down', 'refresh', 'status']:
        dp.addTelegramCommandHandler(cmd, ssrs)

    for cmd in ['newbot', 'forcenewbot']:
        dp.addTelegramCommandHandler(cmd, newbot)

    for cmd in [1]:
        dp.addTelegramCommandHandler('updatebot', updatebot)
        dp.addTelegramCommandHandler('rmbot', rmbot)
        dp.addTelegramCommandHandler('listbots', listbots)

    dp.addTelegramCommandHandler("start", help)
    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()

    # 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()
예제 #49
0
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()
예제 #50
0
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater("123456789:ABCDEFGHIJKLM")
    job_queue = updater.job_queue
    job_queue.put(track_items, 60, next_t=0)
    #job_queue.put(publish_new_offers, 60, next_t=0)

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

    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help_info)
    dp.addTelegramCommandHandler("add", add_item)
    dp.addTelegramCommandHandler("list", list_items)
    dp.addTelegramCommandHandler("readd", readd_items)
    dp.addTelegramCommandHandler("addme", add_user)
    dp.addTelegramCommandHandler("del", del_item)
    dp.addTelegramCommandHandler("canal", canal)

    # 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()
예제 #51
0
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()
예제 #52
0
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()
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()
예제 #54
0
def main():
    mybot = Updater("699053794:AAH8KEIug-7IZXTSlUOMQGfFEq_oyrVPQtk", request_kwargs=PROXY)
    
    dp = mybot.dispatcher
    dp.add_handler(CommandHandler("start", greet_user))
    dp.add_handler(CommandHandler("planet", planet_take))
    dp.add_handler(MessageHandler(Filters.text, talk_to_me))
    print('*'*10)
    mybot.start_polling()
    mybot.idle()
    print('*' * 10)
예제 #55
0
def run_bot():
    updater = Updater(BOT_TOCKEN)
    updater.dispatcher.addErrorHandler(on_error)
    updater.dispatcher.addTelegramCommandHandler("start", on_start)
    updater.dispatcher.addTelegramCommandHandler("ls", on_ls)
    updater.dispatcher.addTelegramCommandHandler("cd", on_cd)
    updater.dispatcher.addTelegramCommandHandler("get", on_get)
    updater.dispatcher.addTelegramCommandHandler("cat", on_cat)
    updater.dispatcher.addTelegramCommandHandler("pwd", on_pwd)
    updater.dispatcher.addTelegramCommandHandler("history", on_history)
    updater.dispatcher.addTelegramMessageHandler(on_message)
    updater.start_polling()
    updater.idle()
예제 #56
0
def main():
    """Add command handlers specified earlier and start the bot."""
    updater = Updater(TOKEN)
    dispatcher = updater.dispatcher

    dispatcher.addTelegramCommandHandler("start", bot_start)
    dispatcher.addTelegramCommandHandler("online", bot_online)
    dispatcher.addTelegramCommandHandler("help", bot_help)
    dispatcher.addErrorHandler(bot_error)
    
    
    updater.start_polling()
    updater.idle()
예제 #57
0
def main():
    updater = Updater(token='TOKEN')
    dp = updater.dispatcher

    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help)

    dp.addTelegramMessageHandler(echo)

    dp.addErrorHandler(error)

    updater.start_polling()

    updater.idle()
예제 #58
0
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.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramMessageHandler(echo)
    # log all errors
    dp.addErrorHandler(error)
    # Start the Bot
    updater.start_polling()
    updater.idle()
예제 #59
0
def main():
    updater = Updater("KEY")

    dp = updater.dispatcher

    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("help", help)
    dp.addTelegramCommandHandler("gerrit", gerrit)
    dp.addTelegramCommandHandler("turingtest", turingtest)
    dp.addTelegramCommandHandler("halay", halay)
    dp.addTelegramCommandHandler("icselhalay", icselhalay)
    dp.addTelegramCommandHandler("turku", turku)
    dp.addTelegramMessageHandler(echo)

    dp.addErrorHandler(error)
    updater.start_polling(timeout=5)
    updater.idle()