Upload 4 files
Browse files- Akeno/plugins/alive.py +18 -29
- Akeno/plugins/logger.py +42 -0
- Akeno/plugins/ping.py +8 -7
- Akeno/plugins/quote.py +120 -0
Akeno/plugins/alive.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
-
import
|
2 |
import os
|
|
|
3 |
import time
|
4 |
-
|
|
|
5 |
from pyrogram import Client, filters
|
6 |
from pyrogram.types import *
|
7 |
-
|
8 |
-
from Akeno
|
9 |
-
from Akeno.utils.handler import *
|
10 |
-
from Akeno.utils.database import db
|
11 |
from Akeno.plugins.ping import get_readable_time
|
12 |
-
from Akeno import
|
13 |
-
from Akeno import
|
|
|
14 |
from config import *
|
15 |
|
16 |
FONT_PATH = "resources/fonts/Montserrat.ttf"
|
@@ -53,23 +54,7 @@ async def alive(client: Client, message: Message):
|
|
53 |
pro = await message.reply_text("Processing ...")
|
54 |
img = await db.get_env(ENV_TEMPLATE.alive_pic)
|
55 |
if not img:
|
56 |
-
|
57 |
-
user_pfp = await client.download_media(message.from_user.photo.big_file_id)
|
58 |
-
del_path = True
|
59 |
-
else:
|
60 |
-
user_pfp = "resources/images/logo.png"
|
61 |
-
del_path = False
|
62 |
-
img = [
|
63 |
-
generate_alive_image(
|
64 |
-
message.from_user.first_name,
|
65 |
-
user_pfp,
|
66 |
-
del_path,
|
67 |
-
FONT_PATH
|
68 |
-
)
|
69 |
-
]
|
70 |
-
else:
|
71 |
-
img = img.split(" ")
|
72 |
-
img = random.choice(img)
|
73 |
uptime = get_readable_time(time.time() - StartTime)
|
74 |
caption = await alive_template(client.me.first_name, uptime)
|
75 |
if img.endswith(".mp4"):
|
@@ -77,7 +62,11 @@ async def alive(client: Client, message: Message):
|
|
77 |
else:
|
78 |
await message.reply_photo(img, caption=caption)
|
79 |
await pro.delete()
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
import os
|
3 |
+
import random
|
4 |
import time
|
5 |
+
|
6 |
+
from pyrogram import *
|
7 |
from pyrogram import Client, filters
|
8 |
from pyrogram.types import *
|
9 |
+
|
10 |
+
from Akeno import StartTime, __version__
|
|
|
|
|
11 |
from Akeno.plugins.ping import get_readable_time
|
12 |
+
from Akeno.utils.database import db
|
13 |
+
from Akeno.utils.handler import *
|
14 |
+
from Akeno.utils.images import generate_alive_image
|
15 |
from config import *
|
16 |
|
17 |
FONT_PATH = "resources/fonts/Montserrat.ttf"
|
|
|
54 |
pro = await message.reply_text("Processing ...")
|
55 |
img = await db.get_env(ENV_TEMPLATE.alive_pic)
|
56 |
if not img:
|
57 |
+
img = "https://telegra.ph/file/316e8e52a723e06d59bbf.jpg"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
uptime = get_readable_time(time.time() - StartTime)
|
59 |
caption = await alive_template(client.me.first_name, uptime)
|
60 |
if img.endswith(".mp4"):
|
|
|
62 |
else:
|
63 |
await message.reply_photo(img, caption=caption)
|
64 |
await pro.delete()
|
65 |
+
if os.path.exists(img):
|
66 |
+
try:
|
67 |
+
os.remove(img)
|
68 |
+
except:
|
69 |
+
pass
|
70 |
+
|
71 |
+
module = modules_help.add_module("alive", __file__)
|
72 |
+
module.add_command("alive", "Get the alive message of the bot.")
|
Akeno/plugins/logger.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
import time
|
5 |
+
import datetime
|
6 |
+
from pyrogram import *
|
7 |
+
from pyrogram import Client, filters
|
8 |
+
from pyrogram.types import *
|
9 |
+
|
10 |
+
from Akeno.utils.database import db
|
11 |
+
from Akeno.utils.handler import *
|
12 |
+
from Akeno.utils.logger import LOGS
|
13 |
+
from config import *
|
14 |
+
|
15 |
+
@Akeno(filters.incoming & filters.group & filters.mentioned & ~filters.service)
|
16 |
+
async def tag_logger(client: Client, message: Message):
|
17 |
+
tag_gc = await db.get_env(ENV_TEMPLATE.tag_logger)
|
18 |
+
if not tag_gc:
|
19 |
+
return
|
20 |
+
if message.from_user.is_bot:
|
21 |
+
return
|
22 |
+
if not message.mentioned:
|
23 |
+
return
|
24 |
+
msg = await message.forward(int(tag_gc), True)
|
25 |
+
await client.send_message(
|
26 |
+
int(tag_gc),
|
27 |
+
f"{message.from_user.mention} **tagged** {client.me.mention} **in** {message.chat.title} (`{message.chat.id}`) Go to {message.link}",
|
28 |
+
disable_web_page_preview=True,
|
29 |
+
reply_to_message_id=msg.id
|
30 |
+
)
|
31 |
+
|
32 |
+
@Akeno(filters.incoming & filters.private & ~filters.bot & ~filters.service)
|
33 |
+
async def pm_logger(client: Client, message: Message):
|
34 |
+
if message.from_user.id == 777000:
|
35 |
+
return
|
36 |
+
logger = await db.get_env(ENV_TEMPLATE.pm_logger)
|
37 |
+
try:
|
38 |
+
if logger:
|
39 |
+
if message.chat.id != client.me.id:
|
40 |
+
await message.forward(int(logger), True)
|
41 |
+
except Exception as e:
|
42 |
+
LOGS.warning(f"PM Logger Err: {e}")
|
Akeno/plugins/ping.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import asyncio
|
2 |
-
import time
|
3 |
import random
|
|
|
4 |
from datetime import datetime as dt
|
5 |
|
6 |
from pyrogram import Client, filters
|
@@ -8,10 +8,11 @@ from pyrogram.types import *
|
|
8 |
from pyrogram.types import Message
|
9 |
|
10 |
from Akeno import StartTime
|
11 |
-
from Akeno.utils.handler import *
|
12 |
from Akeno.utils.database import db
|
|
|
13 |
from config import *
|
14 |
|
|
|
15 |
def get_readable_time(seconds: int) -> str:
|
16 |
count = 0
|
17 |
readable_time = ""
|
@@ -37,11 +38,11 @@ def get_readable_time(seconds: int) -> str:
|
|
37 |
return readable_time
|
38 |
|
39 |
PING_TEMPLATES = [
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
]
|
46 |
|
47 |
async def ping_template(speed: float, uptime: str, owner: str) -> str:
|
|
|
1 |
import asyncio
|
|
|
2 |
import random
|
3 |
+
import time
|
4 |
from datetime import datetime as dt
|
5 |
|
6 |
from pyrogram import Client, filters
|
|
|
8 |
from pyrogram.types import Message
|
9 |
|
10 |
from Akeno import StartTime
|
|
|
11 |
from Akeno.utils.database import db
|
12 |
+
from Akeno.utils.handler import *
|
13 |
from config import *
|
14 |
|
15 |
+
|
16 |
def get_readable_time(seconds: int) -> str:
|
17 |
count = 0
|
18 |
readable_time = ""
|
|
|
38 |
return readable_time
|
39 |
|
40 |
PING_TEMPLATES = [
|
41 |
+
"""
|
42 |
+
🔷 **Speed:** {speed} m/s
|
43 |
+
🔷 **Uptime:** {uptime}
|
44 |
+
🔷 **Onwer:** {owner}
|
45 |
+
""",
|
46 |
]
|
47 |
|
48 |
async def ping_template(speed: float, uptime: str, owner: str) -> str:
|
Akeno/plugins/quote.py
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import os
|
3 |
+
import random
|
4 |
+
import time
|
5 |
+
import datetime
|
6 |
+
import base64
|
7 |
+
import requests
|
8 |
+
from pyrogram import *
|
9 |
+
from pyrogram import Client, filters
|
10 |
+
from pyrogram.types import *
|
11 |
+
|
12 |
+
from Akeno.utils.database import db
|
13 |
+
from Akeno.utils.handler import *
|
14 |
+
from Akeno.utils.logger import LOGS
|
15 |
+
from config import *
|
16 |
+
|
17 |
+
def generate_quote(messages: list[dict]) -> tuple[bool, str]:
|
18 |
+
json = {
|
19 |
+
"type": "quote",
|
20 |
+
"format": "webp",
|
21 |
+
"backgroundColor": "#260746/#6100c2",
|
22 |
+
"width": 512,
|
23 |
+
"height": 768,
|
24 |
+
"scale": 2,
|
25 |
+
"messages": messages,
|
26 |
+
}
|
27 |
+
try:
|
28 |
+
response = requests.post("https://bot.lyo.su/quote/generate", json=json).json()
|
29 |
+
image = base64.b64decode(str(response["result"]["image"]).encode("utf-8"))
|
30 |
+
file_name = f"Quote_{int(time.time())}.webp"
|
31 |
+
with open(file_name, "wb") as f:
|
32 |
+
f.write(image)
|
33 |
+
return True, file_name
|
34 |
+
except Exception as e:
|
35 |
+
return False, str(e)
|
36 |
+
|
37 |
+
def get_entities(message: Message) -> list[dict]:
|
38 |
+
entities = []
|
39 |
+
if message.entities:
|
40 |
+
for entity in message.entities:
|
41 |
+
entities.append(
|
42 |
+
{
|
43 |
+
"type": entity.type.name.lower(),
|
44 |
+
"offset": entity.offset,
|
45 |
+
"length": entity.length,
|
46 |
+
}
|
47 |
+
)
|
48 |
+
|
49 |
+
return entities
|
50 |
+
|
51 |
+
@Akeno(
|
52 |
+
~filters.scheduled
|
53 |
+
& filters.command(["q"], CMD_HANDLER)
|
54 |
+
& filters.me
|
55 |
+
& ~filters.forwarded
|
56 |
+
)
|
57 |
+
async def quotely(client: Client, message: Message):
|
58 |
+
if not message.reply_to_message:
|
59 |
+
return await message.reply_text("Reply to a message to quote it.")
|
60 |
+
if message.reply_to_message.media:
|
61 |
+
if message.reply_to_message.caption:
|
62 |
+
message.reply_to_message.text = message.reply_to_message.caption
|
63 |
+
else:
|
64 |
+
return await message.reply_text("Reply to a text message to quote it.")
|
65 |
+
cmd = None
|
66 |
+
if len(message.command) > 1:
|
67 |
+
cmd = message.command[1].lower()
|
68 |
+
pro = await message.reply_text("__Generating quote...__")
|
69 |
+
msg_data = []
|
70 |
+
if cmd and cmd == "r":
|
71 |
+
await pro.edit_text("__Generating quote with reply...__")
|
72 |
+
reply_msg_id = message.reply_to_message.reply_to_message_id
|
73 |
+
if reply_msg_id:
|
74 |
+
reply_msg = await client.get_messages(message.chat.id, reply_msg_id)
|
75 |
+
if reply_msg and reply_msg.text:
|
76 |
+
replied_name = reply_msg.from_user.first_name
|
77 |
+
if reply_msg.from_user.last_name:
|
78 |
+
replied_name += f" {reply_msg.from_user.last_name}"
|
79 |
+
reply_message = {
|
80 |
+
"chatId": reply_msg.from_user.id,
|
81 |
+
"entities": get_entities(reply_msg),
|
82 |
+
"name": replied_name,
|
83 |
+
"text": reply_msg.text,
|
84 |
+
}
|
85 |
+
else:
|
86 |
+
reply_message = {}
|
87 |
+
else:
|
88 |
+
reply_message = {}
|
89 |
+
else:
|
90 |
+
reply_message = {}
|
91 |
+
|
92 |
+
name = message.reply_to_message.from_user.first_name
|
93 |
+
if message.reply_to_message.from_user.last_name:
|
94 |
+
name += f" {message.reply_to_message.from_user.last_name}"
|
95 |
+
emoji_status = None
|
96 |
+
if message.reply_to_message.from_user.emoji_status:
|
97 |
+
emoji_status = str(message.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
98 |
+
msg_data.append(
|
99 |
+
{
|
100 |
+
"entities": get_entities(message.reply_to_message),
|
101 |
+
"avatar": True,
|
102 |
+
"from": {
|
103 |
+
"id": message.reply_to_message.from_user.id,
|
104 |
+
"name": name,
|
105 |
+
"emoji_status": emoji_status,
|
106 |
+
},
|
107 |
+
"text": message.reply_to_message.text,
|
108 |
+
"replyMessage": reply_message,
|
109 |
+
}
|
110 |
+
)
|
111 |
+
status, path = generate_quote(msg_data)
|
112 |
+
if not status:
|
113 |
+
return await message.reply_text(f"`{path}`")
|
114 |
+
await message.reply_sticker(path)
|
115 |
+
await pro.delete()
|
116 |
+
os.remove(path)
|
117 |
+
|
118 |
+
module = modules_help.add_module("quote", __file__)
|
119 |
+
module.add_command("q", "Generate a quote sticker of the replied message.")
|
120 |
+
module.add_command("q r", "Generate a quote sticker of the replied message with it's reply message.")
|