-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbot.py
More file actions
executable file
·58 lines (43 loc) · 1.51 KB
/
bot.py
File metadata and controls
executable file
·58 lines (43 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
from uuid import uuid4
import re
import telegram
from telegram import InlineQueryResultArticle, ParseMode, InputTextMessageContent, InlineKeyboardButton, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove
from telegram.ext import Updater, InlineQueryHandler, CommandHandler, MessageHandler, CallbackQueryHandler, ConversationHandler, Filters
import logging
import argparse
# Command modules
import commands.cmdFAQ as FAQ
import commands.cmdICO as ICO
method = ''
token = ''
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
logger = logging.getLogger(__name__)
def help(bot, update):
help_message = 'Use\n\
More info: '
bot.sendMessage(update.message.chat_id, text=help_message)
def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))
def unknown(bot, update):
bot.sendMessage(update.message.chat_id, text="Unknown command... (/help)")
def main():
import yaml
cfg_file = './config/botcfg.yml'
with open(cfg_file, 'r') as ymlfile:
cfg = yaml.load(ymlfile)
token = cfg['token']
bot = telegram.Bot(token=token)
updater = Updater(token)
dp = updater.dispatcher
dp.add_handler(CommandHandler("help", help))
dp.add_handler(CommandHandler("question", FAQ.get_faq, pass_args=True))
dp.add_handler(CommandHandler("ico", ICO.get_ico, pass_args=True))
updates = bot.getUpdates()
dp.add_error_handler(error)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()