-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHistoryFacts.py
More file actions
112 lines (106 loc) · 5.58 KB
/
HistoryFacts.py
File metadata and controls
112 lines (106 loc) · 5.58 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import asyncio
import json
import random
from random import choice
from pyrogram import Client, filters
from command import fox_command, fox_sudo, who_message
from requirements_installer import install_library
import os
install_library("aiohttp -U")
import aiohttp
@Client.on_message(fox_command("rfact", "HistoryFacts", os.path.basename(__file__)) & fox_sudo())
async def rfact(client, message):
message = await who_message(client, message)
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 message.edit(
"<b><emoji id=5386596911463541476>📚</emoji> Random interesting fact about the Great Patriotic War:\n{}</b>".format(
text))
else:
await message.edit(
"<b><i>Error: Key not found.</i></b>")
except json.JSONDecodeError:
await message.edit(
"<b><i>Error: The JSON could not be decoded.</i></b>")
else:
await message.edit(
"<b><i>Error loading data</i></b>: {}".format(response.status))
@Client.on_message(fox_command("hfact", "HistoryFacts", os.path.basename(__file__)) & fox_sudo())
async def hfact(client, message):
message = await who_message(client, message)
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 message.edit(
"<b><emoji id=5386596911463541476>📚</emoji> Random fact about Adolf Hitler:\n{}</b>".format(
text))
else:
await message.edit(
"<b><i>Error: Key not found.</i></b>")
except json.JSONDecodeError:
await message.edit(
"<b><i>Error: The JSON could not be decoded.</i></b>")
else:
await message.edit(
"<b><i>Error loading data</i></b>: {}".format(response.status))
@Client.on_message(fox_command("mfact", "HistoryFacts", os.path.basename(__file__)) & fox_sudo())
async def mfact(client, message):
message = await who_message(client, message)
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 message.edit(
"<b><emoji id=5386596911463541476>📚</emoji> Random fact about Benito Mussolini:\n{}</b>".format(
text))
else:
await message.edit(
"<b><i>Error: Key not found.</i></b>")
except json.JSONDecodeError:
await message.edit(
"<b><i>Error: The JSON could not be decoded.</i></b>")
else:
await message.edit(
"<b><i>Error loading data</i></b>: {}".format(response.status))
@Client.on_message(fox_command("sfact", "HistoryFacts", os.path.basename(__file__)) & fox_sudo())
async def sfact(client, message):
message = await who_message(client, message)
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 message.edit(
"<b><emoji id=5386596911463541476>📚</emoji> Random fact about Iosif Stalin:\n{}</b>".format(
text))
else:
await message.edit(
"<b><i>Error: Key not found.</i></b>")
except json.JSONDecodeError:
await message.edit(
"<b><i>Error: The JSON could not be decoded.</i></b>")
else:
await message.edit(
"<b><i>Error loading data</i></b>: {}".format(response.status))