first
This commit is contained in:
58
handlers/AdminActionsHandler.py
Normal file
58
handlers/AdminActionsHandler.py
Normal file
@@ -0,0 +1,58 @@
|
||||
from bot.Handler import Handler
|
||||
from telegram.constants import ParseMode
|
||||
from bot import FIRST
|
||||
from bot.keyboards.VacancyNotificationToAdminKeyboard import VacancyNotificationToAdminKeyboard
|
||||
from bot.msg.AdminNotifMsg import AdminNotifMsg
|
||||
from itguild_api import client
|
||||
|
||||
|
||||
class AdminActionsHandler(Handler):
|
||||
@staticmethod
|
||||
async def admin_respond_to_vacancy(update, context):
|
||||
query = update.callback_query
|
||||
query.answer()
|
||||
|
||||
command, params = Handler.load_callback_query(query.data)
|
||||
print(command, params)
|
||||
|
||||
admins = client.tgBot.get_admins()
|
||||
recipient = client.tgBot.get_dialog(params['dialog_id'])
|
||||
post = client.tgParsing.get_by_id(params['ig_post_id'])
|
||||
anm = AdminNotifMsg()
|
||||
|
||||
for admin in admins:
|
||||
if admin['status'] == 2:
|
||||
reply_markup = VacancyNotificationToAdminKeyboard()
|
||||
reply_markup.add_option("post", post)
|
||||
reply_markup.add_option("recipient", admin)
|
||||
msg = anm.get_msg({'admin': admin, 'post': post, 'recipient': recipient, 'recipient_respond': True})
|
||||
await context.bot.send_message(chat_id=admin['dialog_id'], text=msg, parse_mode=ParseMode.HTML, reply_markup=reply_markup.create_keyboard())
|
||||
|
||||
await context.bot.send_message(chat_id=update.effective_chat.id, text="<b>Отклик отправлен</b>", parse_mode=ParseMode.HTML)
|
||||
|
||||
return FIRST
|
||||
|
||||
@staticmethod
|
||||
async def request_sent(update, context):
|
||||
query = update.callback_query
|
||||
# query.answer()
|
||||
|
||||
data = query.data
|
||||
command, params = Handler.load_callback_query(data)
|
||||
|
||||
user = client.tgBot.get_dialog(update.effective_chat.id)
|
||||
post = client.tgParsing.get_by_id(params['ig_post_id'])
|
||||
|
||||
reply_markup = VacancyNotificationToAdminKeyboard()
|
||||
reply_markup.add_option("post", post)
|
||||
reply_markup.add_option("recipient", user)
|
||||
|
||||
client.tgParsing.update({'id': int(post['id']), 'status': 5})
|
||||
post['status'] = 5
|
||||
|
||||
msg = AdminNotifMsg()
|
||||
text = msg.get_msg({"post": post, "admin": user, "status": "Запрос отправлен"})
|
||||
|
||||
await query.edit_message_text(text=text, parse_mode=ParseMode.HTML, reply_markup=reply_markup.create_keyboard())
|
||||
|
||||
return FIRST
|
Reference in New Issue
Block a user