# * _ __ __ _ _
# * / \ _ _ _ __ ___ _ __ __ _| \/ | ___ __| |_ _| | ___ ___
# * / _ \| | | | '__/ _ \| '__/ _` | |\/| |/ _ \ / _` | | | | |/ _ \/ __|
# * / ___ \ |_| | | | (_) | | | (_| | | | | (_) | (_| | |_| | | __/\__ \
# * /_/ \_\__,_|_| \___/|_| \__,_|_| |_|\___/ \__,_|\__,_|_|\___||___/
# *
# * © Copyright 2024
# *
# * https://t.me/AuroraModules
# *
# * 🔒 Code is licensed under GNU AGPLv3
# * 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# * ⛔️ You CANNOT edit this file without direct permission from the author.
# * ⛔️ You CANNOT distribute this file if you have modified it without the direct permission of the author.
# Name: HistoryFacts
# Author: dend1yya
# Commands:
# .rfact | .hfact | .mfact | .sfact
# scope: hikka_only
# meta developer: @AuroraModules
# meta pic: https://i.postimg.cc/Hx3Zm8rB/logo.png
# meta banner: https://te.legra.ph/file/388d6138470f2036d08ed.jpg
__version__ = (1, 1, 0)
import json
import aiohttp
import asyncio
import random
from random import choice
from .. import loader, utils
from telethon.tl.types import Message # type: ignore
@loader.tds
class HistoryFactMod(loader.Module):
"""Get a random historical fact"""
strings = {
"name": "HistoryFact",
"fact": "📚 Random interesting fact about the Great Patriotic War:\n {}",
"adolf_fact": "📚 Random fact about Adolf Hitler:\n{}",
"mussolini_fact": "📚 Random fact about Benito Mussolini:\n{}",
"stalin_fact": "📚 Random fact about Iosif Stalin:\n{}",
"error_key": "Error: Key not found.",
"error_decoding": "Error: The JSON could not be decoded.",
"error_uploading_data": "Error loading data",
"error_valid_args": "Please enter valid arguments!",
}
strings_ru = {
"fact": "📚 Случайный интересный факт о Великой Отечественной войне:\n{}",
"adolf_fact": "📚 Случайный факт об Адольфе Гитлере:\n{}",
"mussolini_fact": "📚 Случайный факт о Бенито Муссолини:\n{}",
"stalin_fact": "📚 Случайный факт об Иосифе Сталине:\n{}",
"error_key": "Error: ключ не найден.",
"error_decoding": "Error: не удалось декодировать JSON.",
"error_uploading_data": "Ошибка при загрузке данных",
"error_valid_args": "Введите корректные аргументы!",
}
strings_uz = {
"fact": "📚 Buyuk Vatan jangiga oid qiziq fikr:\n{}",
"adolf_fact": "📚 Adolf Gitler haqida tasodifiy fakt:\n{}",
"mussolini_fact": "📚 Benito Mussolini haqida tasodifiy fakt:\n{}",
"stalin_fact": "📚 Iosif Stalin haqida tasodifiy fakt:\n{}",
"error_key": "Error: калити топилмади.",
"error_decoding": "Error: JSON декодлаш муваффақиятли амалга ошмади.",
"error_uploading_data": "Маълумотлар юклаб олинмади",
"error_valid_args": "Iltimos, to'g'ri dalillarni kiriting!",
}
strings_de = {
"fact": "📚 Zufällige interessante Tatsache über den Großen Vaterländischen Krieg:\n{}",
"adolf_fact": "📚 Zufällige Tatsache über Adolf Hitler:\n{}",
"mussolini_fact": "📚 Zufällige Tatsache über Benito Mussolini:\n{}",
"stalin_fact": "📚 Zufällige Tatsache über Iosif Stalin:\n{}",
"error_key": "Error: Der Schlüssel wurde nicht gefunden.",
"error_decoding": "Error: JSON konnte nicht decodiert werden.",
"error_uploading_data": "Fehler beim Hochladen der Daten",
"error_valid_args": "Bitte geben Sie gültige Argumente ein!",
}
strings_es = {
"fact": "📚 Hecho interesante aleatorio sobre la Gran Guerra Patria:\n{}",
"adolf_fact": "📚 Hecho aleatorio sobre Adolf Hitler:\n{}",
"mussolini_fact": "📚 Hecho aleatorio sobre Benito Mussolini:\n{}",
"stalin_fact": "📚 Hecho aleatorio sobre Iosif Stalin:\n{}",
"error_key": "Error: No se encontró la clave.",
"error_decoding": "Error: No se pudo decodificar JSON.",
"error_uploading_data": "Error al cargar los datos",
"error_valid_args": "¡Por favor ingrese argumentos válidos!",
}
@loader.command(
ru_doc="Вывод случайного исторического факта",
uz_doc="tasodifiy tarixiy faktlar chiqarish",
de_doc="Gibt eine zufällige historische Tatsache aus",
es_doc="Muestra un hecho histórico aleatorio",
)
async def rfact(self, message):
"""Output a random historical fact"""
url = "https://raw.githubusercontent.com/KorenbZla/HikkaModules/main/HistoryFacts.json"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
response_text = await response.text()
try:
data = json.loads(response_text)
if "RandomFact" in data and isinstance(data["RandomFact"], list) and data["RandomFact"]:
text = choice(data["RandomFact"])
await utils.answer(message, self.strings['fact'].format(text))
else:
await utils.answer(message, self.strings["error_key"])
except json.JSONDecodeError:
await utils.answer(message, self.strings["error_decoding"])
else:
await utils.answer(message, f"{self.strings('error_uploading_data')}: {response.status}")
@loader.command(
ru_doc="Вывод случайного факта об Адольфе Гитлере",
uz_doc="Adolf Gitler haqida tasodifiy faktlar chiqarish",
de_doc="Gibt eine zufällige Tatsache über Adolf Hitler aus",
es_doc="Muestra un hecho aleatorio sobre Adolf Hitler",
)
async def hfact(self, message):
"""To deduce a random fact about Adolf Hitler"""
url = "https://raw.githubusercontent.com/KorenbZla/HikkaModules/main/HistoryFacts.json"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
response_text = await response.text()
try:
data = json.loads(response_text)
if "AdolfFact" in data and isinstance(data["AdolfFact"], list) and data["AdolfFact"]:
text = choice(data["AdolfFact"])
await utils.answer(message, self.strings['adolf_fact'].format(text))
else:
await utils.answer(message, self.strings["error_key"])
except json.JSONDecodeError:
await utils.answer(message, self.strings["error_decoding"])
else:
await utils.answer(message, f"{self.strings('error_uploading_data')}: {response.status}")
@loader.command(
ru_doc="Вывести случайный факт о Бенито Муссолини",
uz_doc="Benito Mussolini haqida tasodifiy faktlar chiqarish",
de_doc="Gibt eine zufällige Tatsache über Benito Mussolini aus",
es_doc="Muestra un hecho aleatorio sobre Benito Mussolini",
)
async def mfact(self, message):
"""To deduce a random fact about Benito Mussolini"""
url = "https://raw.githubusercontent.com/KorenbZla/HikkaModules/main/HistoryFacts.json"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
response_text = await response.text()
try:
data = json.loads(response_text)
if "MussoliniFact" in data and isinstance(data["MussoliniFact"], list) and data["MussoliniFact"]:
text = choice(data["MussoliniFact"])
await utils.answer(message, self.strings['mussolini_fact'].format(text))
else:
await utils.answer(message, self.strings["error_key"])
except json.JSONDecodeError:
await utils.answer(message, self.strings["error_decoding"])
else:
await utils.answer(message, f"{self.strings('error_uploading_data')}: {response.status}")
@loader.command(
ru_doc="Вывести случайный факт о Иосифе Сталине",
uz_doc="Iosif Stalin haqida tasodifiy faktlar chiqarish",
de_doc="Gibt eine zufällige Tatsache über Joseph Stalin aus",
es_doc="Muestra un hecho aleatorio sobre Joseph Stalin",
)
async def sfact(self, message):
"""To deduce a random fact about Joseph Stalin"""
url = "https://raw.githubusercontent.com/KorenbZla/HikkaModules/main/HistoryFacts.json"
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
if response.status == 200:
response_text = await response.text()
try:
data = json.loads(response_text)
if "StalinFact" in data and isinstance(data["StalinFact"], list) and data["StalinFact"]:
text = choice(data["StalinFact"])
await utils.answer(message, self.strings['stalin_fact'].format(text))
else:
await utils.answer(message, self.strings["error_key"])
except json.JSONDecodeError:
await utils.answer(message, self.strings["error_decoding"])
else:
await utils.answer(message, f"{self.strings('error_uploading_data')}: {response.status}")