Ejemplo n.º 1
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()
Ejemplo n.º 2
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()
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()
Ejemplo n.º 4
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()
Ejemplo n.º 5
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", 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()
Ejemplo n.º 6
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()
Ejemplo n.º 7
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()
Ejemplo n.º 8
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()
Ejemplo n.º 9
0
def main():
    random.seed(None)
    updater = Updater(token='<YOUR_TOKEN>')
    dispatcher = updater.dispatcher
    dispatcher.addTelegramMessageHandler(echo)
    dispatcher.addTelegramCommandHandler('boobs', echo)
    updater.start_polling()
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()
Ejemplo n.º 11
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)
Ejemplo n.º 12
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()
Ejemplo n.º 13
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()
Ejemplo n.º 14
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()
Ejemplo n.º 15
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()
Ejemplo n.º 16
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()
Ejemplo n.º 17
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()
Ejemplo n.º 18
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)
Ejemplo n.º 19
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()
Ejemplo n.º 20
0
def main():
    global CLIENT
    # Create the EventHandler and pass it your bot's token.
    updater = Updater("TOKEN_HERE")
    
    # Set URL to Dublin Bus RTPI
    url = 'http://rtpi.dublinbus.ie/DublinBusRTPIService.asmx?wsdl'

    # Import the correct XML Schema and namespace
    imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd')
    imp.filter.add('http://dublinbus.ie/')
    d = ImportDoctor(imp)

    # Setup the global client with the import doctor and url
    try:
        CLIENT = Client(url, doctor=d) 
        print "Suds Client Connected"
    except:
        print "Client connection error"

    # UTF-8: http://stackoverflow.com/a/17628350
    reload(sys)  # Reload does the trick!
    sys.setdefaultencoding('UTF8')

    # 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(message)

    # on error - print error to stdout
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling(timeout=5)

    # Run the bot until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT
    updater.idle()
Ejemplo n.º 21
0
def main():	
	# Create the EventHandler and pass it your bot's token.
	updater = Updater("128116768:AAFsiMmSV7KjiN8xIidv7eX8TNgbnJ4zMLA")
	jobs = updater.job_queue
	jobs.put(update, 1, prevent_autostart=False)
	# Get the dispatcher to register handlers
	dp = updater.dispatcher

	dp.addTelegramCommandHandler('status',statusOfPlant)

	dp.addTelegramCommandHandler('register',register)

	# 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()
Ejemplo n.º 22
0
def bot_main(bot_token=""):
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(bot_token)

    common.bot = updater.bot

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

    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("subscribe", subscribe)
    dp.addTelegramCommandHandler("unsubscribe", unsubscribe)

    # Start the Bot
    updater.start_polling(timeout=5)

    # Run the bot until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT
    updater.idle()
Ejemplo n.º 23
0
def main():
    token = os.environ["TOKEN"]
    updater = Updater(token)
    dp = updater.dispatcher

    # on different commands - answer in Telegram
    dp.addTelegramCommandHandler("diana", diana)

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

    # on error - print error to stdout
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT
    updater.idle()
Ejemplo n.º 24
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

    dp.addConversationHandler('start', Echo)

    # 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()
Ejemplo n.º 25
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()
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("start", start)
    dp.addTelegramCommandHandler("help", help)

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

    # on error - print error to stdout
    dp.addErrorHandler(error)

    # Start the Bot
    updater.start_polling(timeout=5)

    # Run the bot until the user presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT
    updater.idle()
Ejemplo n.º 27
0
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
Ejemplo n.º 28
0
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(config.get('TELEGRAM_TOKEN'))

    # 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()

    # 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()
Ejemplo n.º 29
0
    def run(self):
        # Create the EventHandler and pass it your bot's token.
        updater = Updater("194949588:AAETiWnXkKaOipiu2jaKHWmcTWnPfHXLXf0")

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

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

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

        # log all errors
        dp.addErrorHandler(self.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()
Ejemplo n.º 30
0
def main():
    # Create the Updater 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)

    # 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()