예제 #1
0
def main_loop(app, queue=None):
    """Main loop of the bot.

    :param flask.app.Flask app: Flask app.
    :param queue: Update queue to be used as the source of updates instead of the Telegram API server. Used in tests.
    """
    bot = DelegatorBot(
        TELEGRAM_TOKEN,
        [pave_event_space()(per_chat_id(), create_open, ChoreBot, timeout=TELEGRAM_IDLE_TIMEOUT, flask_app=app)],
    )
    forever = False if queue else "Listening ({})...".format(app.config["ENV"])
    bot.message_loop(source=queue, run_forever=forever)
예제 #2
0
def main():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djing.settings")
    django.setup()
    from chatbot.telebot import token, DjingTelebot
    while True:
        try:
            bot = DelegatorBot(token, [
                pave_event_space()(
                    per_chat_id(), create_open, DjingTelebot, timeout=300
                ),
            ])
            bot.message_loop(run_forever='Listening ...')
        except BadHTTPResponse as e:
            print(e)
예제 #3
0
def main():
    setup_bot(PLATFORM)
    bot = DelegatorBot(BOT_TOKEN, [
        pave_event_space()(
            per_application(), create_open, NewsApiTelegramBot, timeout=np.inf)
    ])
    MessageLoop(bot).run_as_thread()

    while 1:
        time.sleep(3600)
def main():
    bot = DelegatorBot(token, [
        pave_event_space()(per_chat_id(types=['group']),
                           create_open,
                           TelegramManager,
                           timeout=300)
    ])
    MessageLoop(bot).run_as_thread()

    while 1:
        time.sleep(10)
예제 #5
0
                        print('event_id: ', event['id'])
                        bot.sendMessage(chat_id, response)

            else:
                # response = 'Please choose an event category!'
                pass

        # send the response
        #bot.sendMessage(chat_id, response)

    def on_callback_query(msg):
        global cat_bot
        query_id, from_id, query_data = telepot.glance(msg,
                                                       flavor='callback_query')

        # answer callback query or else telegram will forever wait on this
        bot.answerCallbackQuery(query_id)


bot = DelegatorBot(
    TOKEN,
    [pave_event_space()(per_chat_id(), create_open, EveBot, timeout=100)])
MessageLoop(bot).run_as_thread()

# show in cmd that bot is running
bot_name = bot.getMe()['first_name']
print(bot_name + ' is running...')

while True:
    time.sleep(10)
예제 #6
0
            response = findstall("Cuisine", "Chicken Rice")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui11'):
            response = findstall("Cuisine", "Asian")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui12'):
            response = findstall("Cuisine", "Dessert")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui13'):
            response = findstall("Cuisine", "Malay")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui14'):
            response = findstall("Cuisine", "Thai")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui15'):
            response = findstall("Cuisine", "Vietnamese")
            bot.sendMessage(from_id, response)

        # answer callback query or else telegram will forever wait on this
        bot.answerCallbackQuery(query_id)


#Implement DelegatorBot
bot = DelegatorBot(
    '465323177:AAEqS51N3IDG5e9smMx1It4FPuzuRMbcKjA',
    [pave_event_space()(per_chat_id(), create_open, ntuBot, timeout=300)])
MessageLoop(bot).run_as_thread()

while True:
    time.sleep(10)
예제 #7
0
        raw_text = msg.get('text')
        if Rules.url_allowed(raw_text):
            try:
                self._save_potential_meme(url=textutils.extract_url(text=raw_text))
                current_count = len(self._meme_dao.find_by_site(Site.TELEGRAM))
                message = 'Memebot found a potential image. Total images found %s' % current_count
            except DuplicateKeyError:
                message = 'Memebot found a duplicate image. Bad bad bad!!!'
            self.sender.sendMessage(message)
            logger.log('telegramparser.py', message)

    def _save_potential_meme(self, url):
        post_id = idutils.generate_id()
        meme = Meme(post_id=post_id, site=Site.TELEGRAM, text=None, media_url=url)
        self._meme_dao.insert_one(data=meme)


if __name__ == '__main__':
    TOKEN = ''

    bot = DelegatorBot(TOKEN, [
        pave_event_space()(
            per_chat_id(), create_open, TelegramParser, timeout=10
        ),
    ])
    MessageLoop(bot).run_as_thread()
    print('Listening ...')

    while 1:
        time.sleep(10)
예제 #8
0
            response = findstall("Cuisine", "Chicken Rice")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui11'):
            response = findstall("Cuisine", "Asian")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui12'):
            response = findstall("Cuisine", "Dessert")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui13'):
            response = findstall("Cuisine", "Malay")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui14'):
            response = findstall("Cuisine", "Thai")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui15'):
            response = findstall("Cuisine", "Vietnamese")
            bot.sendMessage(from_id, response)

        # answer callback query or else telegram will forever wait on this
        bot.answerCallbackQuery(query_id)


#Implement DelegatorBot
bot = DelegatorBot(
    '438517093:AAG3owJVduu_tFma_0jL_YayBuEd4BidkrY',
    [pave_event_space()(per_chat_id(), create_open, ntuBot, timeout=300)])
MessageLoop(bot).run_as_thread()

while True:
    time.sleep(10)
예제 #9
0
        if (query_data in telco_list):
            self.telco = query_data
            plan_list_l = df_con[df_con.loc[:, 'Provider'] == query_data]
            plan_list_l = plan_list_l.loc[:, 'Plan'].unique()

            keyboard = InlineKeyboardMarkup(inline_keyboard=[[
                InlineKeyboardButton(text=plan, callback_data=plan)
            ] for plan in plan_list_l])
            bot.sendMessage(from_id, query_data)
            bot.sendMessage(from_id, 'Select a plan: ', reply_markup=keyboard)

        if (query_data in plan_list):
            bot.sendMessage(from_id, query_data)
            self.convertImage(self.function2(self.telco, query_data), 2)
            self.sendImage(from_id)
        ##end
        bot.answerCallbackQuery(query_id, text='Wait a moment...')


## bot delegator
bot = DelegatorBot(
    TOKEN,
    [pave_event_space()(per_chat_id(), create_open, TelcoBot, timeout=100)])
MessageLoop(bot).run_as_thread()

print('Bot Started')

while 1:
    time.sleep(10)
예제 #10
0
파일: main.py 프로젝트: limjiale/duguqiubai
            response = findstall("Cuisine", "Chicken Rice")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui11'):
            response = findstall("Cuisine", "Asian")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui12'):
            response = findstall("Cuisine", "Dessert")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui13'):
            response = findstall("Cuisine", "Malay")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui14'):
            response = findstall("Cuisine", "Thai")
            bot.sendMessage(from_id, response)
        elif (query_data == 'cui15'):
            response = findstall("Cuisine", "Vietnamese")
            bot.sendMessage(from_id, response)

        # answer callback query or else telegram will forever wait on this
        bot.answerCallbackQuery(query_id)


#Implement DelegatorBot
bot = DelegatorBot(
    '442165685:AAHSNlvMc4CzsBVgXJv2kExQ3rCB9DJ_uAg',
    [pave_event_space()(per_chat_id(), create_open, ntuBot, timeout=300)])
MessageLoop(bot).run_as_thread()

while True:
    time.sleep(10)