Exemple #1
0
def get_callback(data):
    try:
        cd = callback_data.CallbackData('@', 'func', 'json',
                                        sep='&').parse(data)
    except ValueError:
        return
    parsed = cd.get('json')
    func = cd.get('func')
    if parsed is None or func is None or not func.isdigit():
        return
    return int(func), json.loads(parsed)
Exemple #2
0
def set_callback(func, data):
    return callback_data.CallbackData('@', 'func', 'json', sep='&').new(
        func, json.dumps(data, separators=(',', ':')))
Exemple #3
0
from aiogram import types
from aiogram.utils import callback_data
from keyboards.inline import cancel_button

callback = callback_data.CallbackData("primer", "age", "sex")  # пример

text_and_data = [('НАЗАД', 'go_back')]

inline_kb_go_back = types.InlineKeyboardMarkup(
    row_width=1)  # создаём экземпляр клавиатуры
for text, data in text_and_data:  # добавляем в клавиатуру кномпи из списка выше
    button = types.InlineKeyboardButton(text=text, callback_data=data)
    inline_kb_go_back.add(button)

# inline_kb1.add(types.InlineKeyboardButton('отмена', callback_data='cancel'))  # добавляем кнопку отмена
Exemple #4
0
from config import API_TOKEN, admin_id
from poll_module import get_text_from, Attack_question, Defense_question, DB
import attack_questions
import defense_questions

# Configure logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger('messages_sender')

# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN, parse_mode="HTML")
dp = Dispatcher(bot)

# sructure of callback bottons
button_cb = callback_data.CallbackData('B', 'q_name', 'ans', 's_id', 'data')

attack_message = '⚔ Я АТАКУЮ!'
defense_message = '🛡 Я ЗАЩИЩАЮСЬ'
help_message = 'Помощь'
basemenu_list = [attack_message, defense_message, help_message]

all_attack_list = Attack_question.get_all_questions_list()
all_defense_list = Defense_question.get_all_questions_list()
all_list = all_attack_list + all_defense_list

broadcast_text = ''


async def make_keyboard(question_name,
                        keyboard_type,
Exemple #5
0
from poll_module import get_text_from, get_next_question
from analysis_module import get_analysis

# Data base
DB = DB_module(DB_HOST, DB_NAME, DB_USER, DB_PASS, DB_PORT)

# Configure logging
logging.basicConfig(level=logging.INFO)
log = logging.getLogger('messages_sender')

# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)

# sructure of callback bottons
button_cb = callback_data.CallbackData('button', 'question_name', 'answer',
                                       'data')

like_word = 'Нравится'
like_mark = 2
dislike_word = 'Не нравится'
dislike_mark = 1
like_dislike_list = ['Нравится', 'Не нравится']
like_list = ['Нравится 👍', 'Не нравится']
dislike_list = ['Нравится', 'Не нравится 👎']

keywords_day = ['Меню позавчера', 'Меню вчера', 'Меню сегодня']
loyaltyMark_word = 'Оценить работу компании'
basemenu_list = keywords_day + [
    loyaltyMark_word,
]