Beispiel #1
0
def main():
    global job_queue

    #@InfraredBot
    updater = telegram.Updater("134968583:AAEXYeTdmbi96qbnqQ3pdBpq3l-4RN8bkMQ")
    job_queue = updater.job_queue

    # Get the dispatcher to register handlers
    dp = updater.dispatcher
    dp.addTelegramCommandHandler("start", start)

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling()

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

    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit
Beispiel #2
0
def main():
    print "Token:", token_string
    updater = telegram.Updater(token_string)

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

    # Definisce gli handler di gestione dei comandi
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("menu", menu)
    dp.addTelegramCommandHandler("help", menu)

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

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling(poll_interval=0.1, timeout=10)

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

    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit
Beispiel #3
0
def main():
    updater = telegram.Updater(token=token_id)
    dispatcher = updater.dispatcher
    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramCommandHandler('help', help)
    dispatcher.addTelegramCommandHandler('verifyme', verifyme)
    dispatcher.addTelegramCommandHandler('verifypic', verifypic)
    dispatcher.addTelegramCommandHandler('verify', verify)
    dispatcher.addTelegramMessageHandler(pic_forwarder)
    updater.start_polling()
    updater.idle()
Beispiel #4
0
def main():
    global update_queue

    # Creata l'EventHandler e gli passa il token assegnato al bot
    # Cambia questo Token con quello che ti ha assegnato BotFather
    # Il token e' memorizzato nel file mytoken.py
    print "Token:", mytokens.token_string
    updater = telegram.Updater(mytokens.token_string)

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

    # Definisce gli handler di gestione dei comandi
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("menu", menu)
    dp.addTelegramCommandHandler("help", menu)
    dp.addTelegramCommandHandler("rele", send_menu_rele)
    dp.addTelegramCommandHandler("foto", send_photo)
    dp.addTelegramCommandHandler("video", send_video)
    dp.addTelegramCommandHandler("logo", send_logo)
    dp.addTelegramCommandHandler("pdf", send_pdf)
    dp.addTelegramCommandHandler("music", send_music)
    dp.addTelegramCommandHandler("dog", send_dog)
    dp.addTelegramCommandHandler("jingle", send_jingle)
    dp.addTelegramCommandHandler("graph", send_graph)
    dp.addTelegramCommandHandler("mute", send_mute)
    dp.addTelegramCommandHandler("stop", send_stop)

    # Regex handlers will receive all updates on which their regex matches
    dp.addTelegramRegexHandler('.*', any_message)

    dp.addStringCommandHandler('pir_alarm', send_pir_alarm)

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

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling()

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

    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit
Beispiel #5
0
def main():
    print("Reading config")
    init()
    global telegramToken
    print("Initialazing bot")
    updater = telegram.Updater(token=telegramToken)
    updater.dispatcher.addTelegramCommandHandler('start', reply_start)
    updater.dispatcher.addUnknownTelegramCommandHandler(reply_unknown)
    updater.dispatcher.addTelegramCommandHandler('name', reply_name)
    updater.dispatcher.addTelegramCommandHandler('location', reply_location)
    updater.dispatcher.addTelegramCommandHandler('namex', reply_namex)
    updater.dispatcher.addTelegramCommandHandler('locationx', reply_locationx)
    print("polling...")
    updater.start_polling()
    updater.idle()
Beispiel #6
0
def main():
    # Create the EventHandler and pass it your bot's token.
    updater = telegram.Updater(token="XXXX")

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

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

    # Start the Bot
    updater.start_polling()

    updater.idle()
Beispiel #7
0
def main():
    global bot
    global tgtoken
    bot = telegram.Bot(token=tgtoken)
    updater = telegram.Updater(token=tgtoken)
    dispatcher = updater.dispatcher
    updater.start_polling()
    dispatcher.addTelegramCommandHandler('start', start)
    dispatcher.addTelegramCommandHandler('help', help)
    dispatcher.addTelegramCommandHandler('make_a_coffee', make_a_coffee)
    dispatcher.addTelegramCommandHandler('get_file_report', getFileReport)
    dispatcher.addTelegramCommandHandler('get_url_report', getURLReport)
    dispatcher.addTelegramCommandHandler('get_ip_report', getIpAddressReport)
    dispatcher.addTelegramCommandHandler('get_domain_report', getDomainReport)
    dispatcher.addTelegramCommandHandler('scan_url', URLScan)
    dispatcher.addTelegramCommandHandler('rescan', rescan)
    dispatcher.addTelegramMessageHandler(messageChecker)
Beispiel #8
0
    def __init__(self):
        updater = telegram.Updater(token=TG_TOKEN)
        
        dp = updater.dispatcher
        dp.addTelegramCommandHandler('start', self.welcome)
        dp.addTelegramCommandHandler('suggest', self.suggest)
        dp.addTelegramCommandHandler('feedback', self.feedback)
        dp.addTelegramCommandHandler('stats', self.stats)
        dp.addTelegramMessageHandler(self.fetch)
        dp.addErrorHandler(self.error)
        
        updater.start_polling()

        logger.info("RedditRobot started polling")
        self.message = ''
        self.chat_id = None
        self.user_id = None
        self.subreddit = None
        self.submission = None
Beispiel #9
0
def main():
    global update_queue
    global myMatrix

    rows = 32
    chains = 4
    parallel = 1

    # @LedlampBot
    updater = telegram.Updater("194376022:AAHLWzfrLediKJwE3CXk1vYhRwVVBpmRJLQ")

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

    # Definisce gli handler di gestione dei comandi
    dp.addTelegramCommandHandler("start", cmd_start)

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

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling()

    myMatrix = RGBMatrix(rows, chains, parallel)
    myMatrix.Fill(0, 0, 0)

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

    except KeyboardInterrupt:
        print "Exit"
Beispiel #10
0
def error_handler(bot, update, error):
    if is_authorized(update):
        err_msg = 'Update "{}" caused error "{}"'.format(update, error)
        send_message(bot, update, err_msg)

def help_cmd(bot, update):
    send_message(bot, update, get_help_text())

if __name__ == '__main__':

    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    )

    updater = telegram.Updater(token=config.get_token())
    bc.dispatcher = updater.dispatcher

    PLUGINS = [
        cancel,
        clear,
        emojis,
        gimme,
        insult,
        lights,
        quote,
        random_fact,
        shell_exec,
        sms,
        snap,
    ]
Beispiel #11
0
            t.append(vfg)
    for i in t:
        ended.append(list(i))
    for i in ended:
        i[1] = i[1].replace(' – ', '')
        i[1] = i[1].replace(' - ', '')
        i[1] = i[1].replace('</em>', '')
        i[1] = i[1].replace('<em>', '')
        i[1] = i[1].replace('<strong>', ' ')
        i[1] = i[1].replace('</strong>', ' ')
    return ended


dit = dictr()

updater = telegram.Updater(
    token='179534327:AAFedcYG-OglD8Mpq6uHb0kSX6RW8yyNDew')
dispatcher = updater.dispatcher


def start_game(bot, update):
    repl = telegram.ReplyKeyboardMarkup([["/1", "/2", "/3"]],
                                        one_time_keyboard=True,
                                        resize_keyboard=True)
    global random_ans
    global random_words
    random_words = []
    for i in range(3):
        random_words.append(random.choice(dit))
    random_ans = random_words[0]
    bot.sendMessage(chat_id=update.message.chat_id, text=random_ans[0])
    random.shuffle(random_words)