-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathomen.py
More file actions
31 lines (26 loc) · 1.48 KB
/
omen.py
File metadata and controls
31 lines (26 loc) · 1.48 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
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton
from telegram.constants import ParseMode
from telegram.ext import ContextTypes
import const
from db import DataBase
from poem import Poem
class Omen:
@staticmethod
async def show_hafez_omen(update: Update, context: ContextTypes.DEFAULT_TYPE):
"""Displays a random poem from Qazaliat-e-Hafez along with its interpretation to the user."""
await update.callback_query.answer()
poet_name = 'حافظ'
category_name = 'غزلیات'
poem_id = DataBase().get_random_poem(poet_name, category_name)
user_id = update.effective_user.id
origin_message_id = update.effective_message.id
await Poem.get_poem_by_id(poem_id, user_id, context, origin_message_id)
interpretation = DataBase().get_omen(poem_id)
await context.bot.send_message(user_id, const.OMEN_RESULT.format(interpretation=interpretation,
username=context.bot.username))
@staticmethod
async def show_omen_introduction(update: Update, context: ContextTypes.DEFAULT_TYPE):
"""Displays the omen introduction message to the user."""
keyboard = InlineKeyboardMarkup([[InlineKeyboardButton('نمایش فال', callback_data='omen')]])
await context.bot.send_message(update.effective_user.id, const.OMEN_INTRO, reply_markup=keyboard,
parse_mode=ParseMode.HTML)