aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'searchbot.py')
-rw-r--r--searchbot.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/searchbot.py b/searchbot.py
index e18875f..ee504d5 100644
--- a/searchbot.py
+++ b/searchbot.py
@@ -3,8 +3,10 @@ from telegram.ext import Updater, CommandHandler
3import logging 3import logging
4# Enable logging 4# Enable logging
5logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', 5logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
6 level=logging.DEBUG) 6 level=logging.DEBUG)
7logger = logging.getLogger(__name__) 7logger = logging.getLogger(__name__)
8
9
8def search(bot, update, args): 10def search(bot, update, args):
9 agentid = args[0] 11 agentid = args[0]
10 print(agentid) 12 print(agentid)
@@ -15,10 +17,16 @@ def search(bot, update, args):
15 for i in res: 17 for i in res:
16 print(i) 18 print(i)
17 bot.sendMessage(update.message.chat_id, text=str(i)) 19 bot.sendMessage(update.message.chat_id, text=str(i))
20
21
18def start(bot, update): 22def start(bot, update):
19 bot.sendMessage(update.message.chat_id, text="Hi! Use /search agentid to start, no need for @") 23 bot.sendMessage(update.message.chat_id, text="Hi! Use /search agentid to start, no need for @")
24
25
20def error(bot, update, error): 26def error(bot, update, error):
21 logger.warn('Update "%s" caused error "%s"' % (update, error)) 27 logger.warn('Update "%s" caused error "%s"' % (update, error))
28
29
22def main(): 30def main():
23 updater = Updater('Telegram Bot ID') 31 updater = Updater('Telegram Bot ID')
24 dp = updater.dispatcher 32 dp = updater.dispatcher
@@ -28,5 +36,6 @@ def main():
28 dp.add_error_handler(error) 36 dp.add_error_handler(error)
29 updater.start_polling() 37 updater.start_polling()
30 updater.idle() 38 updater.idle()
39
31if __name__ == "__main__": 40if __name__ == "__main__":
32 main() 41 main()
Powered by cgit v1.2.3 (git 2.41.0)