-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcloud.py
executable file
·71 lines (59 loc) · 2.38 KB
/
cloud.py
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
# █ █ ▀ █▄▀ ▄▀█ █▀█ ▀
# █▀█ █ █ █ █▀█ █▀▄ █
# © Copyright 2022
# https://t.me/hikariatama
#
# 🔒 Licensed under the GNU AGPLv3
# 🌐 https://www.gnu.org/licenses/agpl-3.0.html
# meta pic: https://static.dan.tatar/cloud_icon.png
# meta banner: https://mods.hikariatama.ru/badges/cloud.jpg
# meta developer: @hikarimods
# scope: hikka_only
# scope: hikka_min 1.2.10
import time
import requests
from telethon.tl.types import Message
from .. import loader, utils
@loader.tds
class ModuleCloudMod(loader.Module):
"""Hikari modules management"""
strings = {
"name": "ModuleCloud",
"args": "🚫 <b>Args not specified</b>",
"mod404": "🚫 <b>Module {} not found</b>",
"ilink": (
"<emoji document_id=5370705803051279512>🐹</emoji> <b><u>{name}</u> - <a"
' href="https://mods.hikariatama.ru/view/{file}.py">source</a></b>\n<emoji'
" document_id=5787544344906959608>ℹ️</emoji> <i>{desc}</i>\n\n<i>By"
" @hikarimods with </i><emoji"
" document_id=5875452644599795072>🔞</emoji>\n\n<emoji"
" document_id=5188377234380954537>🌘</emoji> <code>.dlm {file}</code>"
),
"404": "😔 <b>Module not found</b>",
"not_exact": (
"⚠️ <b>No exact match occured, so the closest result is shown instead</b>"
),
}
@loader.unrestricted
async def ilinkcmd(self, message: Message):
"""<modname> - Get hikari module banner"""
args = utils.get_args_raw(message)
badge = await utils.run_sync(
requests.get,
f"https://mods.hikariatama.ru/badge/{args}",
)
if badge.status_code == 404:
await utils.answer(message, self.strings("mod404").format(args))
return
img = requests.get(badge.json()["badge"] + f"?t={round(time.time())}").content
info = badge.json()["info"]
info["file"] = info["file"].split(".")[0]
if not message.media or not message.out:
await self._client.send_file(
message.peer_id,
img,
caption=self.strings("ilink").format(**info),
)
await message.delete()
else:
await message.edit(self.strings("ilink").format(**info), file=img)