diff options
Diffstat (limited to 'searchbot.py')
-rw-r--r-- | searchbot.py | 11 |
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 | |||
3 | import logging | 3 | import logging |
4 | # Enable logging | 4 | # Enable logging |
5 | logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | 5 | logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
6 | level=logging.DEBUG) | 6 | level=logging.DEBUG) |
7 | logger = logging.getLogger(__name__) | 7 | logger = logging.getLogger(__name__) |
8 | |||
9 | |||
8 | def search(bot, update, args): | 10 | def 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 | |||
18 | def start(bot, update): | 22 | def 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 | |||
20 | def error(bot, update, error): | 26 | def 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 | |||
22 | def main(): | 30 | def 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 | |||
31 | if __name__ == "__main__": | 40 | if __name__ == "__main__": |
32 | main() | 41 | main() |