2022-12-26 09:48:13 +00:00
|
|
|
from mipac.models.notification import NotificationFollow, NotificationFollowRequest
|
|
|
|
from mipac.models.lite.user import LiteUser
|
|
|
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
|
|
|
|
2023-01-17 03:26:10 +00:00
|
|
|
from glover import admin, topic_group_id, notice_topic_id
|
2022-12-26 09:48:13 +00:00
|
|
|
from init import bot
|
|
|
|
|
|
|
|
user_followed_template = """<b>有人关注了你!</b> <a href="{0}">{1}</a>"""
|
|
|
|
follow_request_template = """<b>有人申请关注你!</b> <a href="{0}">{1}</a>"""
|
|
|
|
follow_request_accept_template = """<b>有人同意了你的关注申请!</b> <a href="{0}">{1}</a>"""
|
|
|
|
|
|
|
|
|
|
|
|
def gen_user_link_button(user: LiteUser):
|
|
|
|
return [
|
|
|
|
InlineKeyboardButton(
|
|
|
|
text="Link",
|
|
|
|
url=user.api.action.get_profile_link(),
|
|
|
|
),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
async def send_user_followed(notice: NotificationFollow):
|
|
|
|
await bot.send_message(
|
2023-01-17 03:26:10 +00:00
|
|
|
topic_group_id or admin,
|
2022-12-26 09:48:13 +00:00
|
|
|
user_followed_template.format(
|
|
|
|
notice.user.api.action.get_profile_link(),
|
|
|
|
notice.user.username,
|
|
|
|
),
|
2023-01-17 03:26:10 +00:00
|
|
|
reply_to_message_id=notice_topic_id,
|
2022-12-26 09:48:13 +00:00
|
|
|
reply_markup=InlineKeyboardMarkup([gen_user_link_button(notice.user)]),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def send_follow_request(notice: NotificationFollowRequest):
|
|
|
|
await bot.send_message(
|
2023-01-17 03:26:10 +00:00
|
|
|
topic_group_id or admin,
|
2022-12-26 09:48:13 +00:00
|
|
|
follow_request_template.format(
|
|
|
|
notice.user.api.action.get_profile_link(),
|
|
|
|
notice.user.username,
|
|
|
|
),
|
2023-01-17 03:26:10 +00:00
|
|
|
reply_to_message_id=notice_topic_id,
|
2022-12-26 09:48:13 +00:00
|
|
|
reply_markup=InlineKeyboardMarkup(
|
|
|
|
[
|
|
|
|
gen_user_link_button(notice.user),
|
|
|
|
[
|
|
|
|
InlineKeyboardButton(
|
|
|
|
text="Accept",
|
|
|
|
callback_data=f"request_accept:{notice.user.id}",
|
|
|
|
),
|
|
|
|
InlineKeyboardButton(
|
|
|
|
text="Reject",
|
|
|
|
callback_data=f"request_reject:{notice.user.id}",
|
|
|
|
),
|
|
|
|
]
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
async def send_follow_request_accept(notice: NotificationFollowRequest):
|
|
|
|
await bot.send_message(
|
2023-01-17 03:26:10 +00:00
|
|
|
topic_group_id or admin,
|
2022-12-26 09:48:13 +00:00
|
|
|
follow_request_accept_template.format(
|
|
|
|
notice.user.api.action.get_profile_link(),
|
|
|
|
notice.user.username,
|
|
|
|
),
|
2023-01-17 03:26:10 +00:00
|
|
|
reply_to_message_id=notice_topic_id,
|
2022-12-26 09:48:13 +00:00
|
|
|
reply_markup=InlineKeyboardMarkup([gen_user_link_button(notice.user)]),
|
|
|
|
)
|