forked from SeongCheol-Kim/ime_db_2019_project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatBotModel.py
34 lines (27 loc) · 986 Bytes
/
ChatBotModel.py
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
import telegram
from telegram.ext import Updater, CommandHandler
from sql_model import *
class TelegramBot:
def __init__(self, name, token):
self.core = telegram.Bot(token)
self.updater = Updater(token)
self.id = secrets['admin_id']
self.name = name
def sendMessage(self, text):
self.core.sendMessage(chat_id = self.id, text=text)
def stop(self):
self.updater.start_polling()
self.updater.dispatcher.stop()
self.updater.job_queue.stop()
self.updater.stop()
class HangangBot(TelegramBot):
def __init__(self):
self.token = secrets['telegram_access_token']
TelegramBot.__init__(self, '텔레그램', self.token)
self.updater.stop()
def add_handler(self, cmd, func):
self.updater.dispatcher.add_handler(CommandHandler(cmd, func))
def start(self):
self.sendMessage('안녕하세요')
self.updater.start_polling()
self.updater.idle()