-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.py
48 lines (39 loc) · 2.04 KB
/
data.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import abc
import pandas as pd
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import CallbackContext
PLAYING, SELECT_DICTIONARY, GAME_OVER, SELECT_MODE, SELECT_TEST, PLAYING_TEST = range(6)
dictionary = pd.read_excel('dictionaries/dict.xls', 0, header=None).transpose().stack().reset_index(drop=True)
dicts = [
('Словарь (1-3)', dictionary[:3 * 64].reset_index(drop=True)),
('Словарь (4-6)', dictionary[3 * 64:].reset_index(drop=True)),
('56 наречий', pd.read_excel('dictionaries/adverbs.xls', 0, header=None).stack()),
('Н и НН', pd.read_excel('dictionaries/nn.xls', 0, header=None).stack()),
('При/Пре', pd.read_excel('dictionaries/pri_pre.xls', 0, header=None).stack()),
]
tests = [
('НЕ и НИ', pd.read_excel('tests/ne-ni.xls', 0), ('слитно', 'раздельно'))
]
class BaseModule(metaclass=abc.ABCMeta):
@staticmethod
@abc.abstractmethod
async def select(update: Update, context: CallbackContext):
pass
@staticmethod
@abc.abstractmethod
async def play(update: Update, context: CallbackContext):
pass
@staticmethod
@abc.abstractmethod
async def stop(update: Update, context: CallbackContext, out_of_words=False):
pass
async def start(update: Update, context: CallbackContext):
context.user_data.clear()
keyboard = list(InlineKeyboardButton(label, callback_data=i) for i, label in enumerate(["Диктанты", "Тренажёры"]))
reply_markup = InlineKeyboardMarkup([keyboard])
await context.bot.send_message(chat_id=update.effective_chat.id,
text='Привет! ✌\n'
'Ты можешь провести диктант или проверить знание правил с помощью тренажёров.\n'
'Выбери режим, который тебе нужен',
reply_markup=reply_markup)
return SELECT_MODE