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