2021-11-28 14:55:10 +00:00
|
|
|
import json
|
|
|
|
from secrets import choice
|
|
|
|
from os import sep
|
2022-07-25 09:35:54 +00:00
|
|
|
from typing import List
|
2021-11-28 14:55:10 +00:00
|
|
|
|
|
|
|
from pyrogram import Client, filters, ContinuePropagation
|
|
|
|
from pyrogram.types import Message
|
|
|
|
|
2023-06-23 15:37:55 +00:00
|
|
|
from init import bot
|
2021-11-28 14:55:10 +00:00
|
|
|
|
2022-07-25 09:35:54 +00:00
|
|
|
book_of_answers: List[str]
|
2021-11-28 14:55:10 +00:00
|
|
|
|
|
|
|
|
2023-01-12 13:19:54 +00:00
|
|
|
with open(
|
|
|
|
f"resources{sep}text{sep}book_of_answers.json", "r", encoding="utf-8"
|
|
|
|
) as file:
|
2021-11-28 14:55:10 +00:00
|
|
|
book_of_answers = json.load(file)
|
|
|
|
|
|
|
|
|
2023-06-23 15:37:55 +00:00
|
|
|
@bot.on_message(filters.incoming & filters.regex(r"^答案之书$"))
|
2022-07-25 09:35:54 +00:00
|
|
|
async def book_of_answer(_: Client, message: Message):
|
2023-01-12 13:19:54 +00:00
|
|
|
await message.reply_text(f"{choice(book_of_answers)}", quote=True)
|
2021-11-28 14:55:10 +00:00
|
|
|
raise ContinuePropagation
|