Upload 4 files
Browse files- Akeno/plugins/chatgpt.py +113 -0
- Akeno/plugins/gban.py +142 -0
- Akeno/plugins/imageai.py +64 -0
- Akeno/plugins/ping.py +49 -0
Akeno/plugins/chatgpt.py
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
# Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea
|
4 |
+
#
|
5 |
+
# from : https://github.com/TeamKillerX
|
6 |
+
# Channel : @RendyProjects
|
7 |
+
# This program is free software: you can redistribute it and/or modify
|
8 |
+
# it under the terms of the GNU Affero General Public License as published by
|
9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
10 |
+
# (at your option) any later version.
|
11 |
+
#
|
12 |
+
# This program is distributed in the hope that it will be useful,
|
13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
# GNU Affero General Public License for more details.
|
16 |
+
#
|
17 |
+
# You should have received a copy of the GNU Affero General Public License
|
18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
+
|
20 |
+
from pyrogram import Client, filters
|
21 |
+
from pyrogram.types import *
|
22 |
+
from pyrogram import *
|
23 |
+
from config import GOOGLE_API_KEY, CMD_HANDLER
|
24 |
+
|
25 |
+
from Akeno.utils.logger import LOGS
|
26 |
+
from Akeno.utils.handler import Akeno
|
27 |
+
from Akeno.utils.chat import chat_message
|
28 |
+
from RyuzakiLib import RendyDevChat, FullStackDev, GeminiLatest
|
29 |
+
|
30 |
+
@Akeno(
|
31 |
+
~filters.scheduled
|
32 |
+
& filters.command(["askf"], CMD_HANDLER)
|
33 |
+
& filters.me
|
34 |
+
& ~filters.forwarded
|
35 |
+
)
|
36 |
+
async def googlegm(client: Client, message: Message):
|
37 |
+
if not message.reply_to_message:
|
38 |
+
await message.reply_text("Please reply to message photo")
|
39 |
+
return
|
40 |
+
user_message = message.reply_to_message
|
41 |
+
caption = user_message.caption or "What's this?"
|
42 |
+
if not user_message.photo:
|
43 |
+
await message.reply_text("Not allowed text")
|
44 |
+
return
|
45 |
+
try:
|
46 |
+
replys = await message.reply_text("Prossing.....")
|
47 |
+
if user_message.photo:
|
48 |
+
file_path = await user_message.download()
|
49 |
+
if not GOOGLE_API_KEY:
|
50 |
+
return await replys.edit_text("Required .env `GOOGLE_API_KEY`")
|
51 |
+
x = GeminiLatest(api_keys=GOOGLE_API_KEY)
|
52 |
+
response = x.get_response_image(caption, file_path)
|
53 |
+
await replys.edit_text(response)
|
54 |
+
return
|
55 |
+
except Exception as e:
|
56 |
+
LOGS.error(str(e))
|
57 |
+
await replys.edit_text(str(e))
|
58 |
+
return
|
59 |
+
|
60 |
+
@Akeno(
|
61 |
+
~filters.scheduled
|
62 |
+
& filters.command(["askm"], CMD_HANDLER)
|
63 |
+
& filters.me
|
64 |
+
& ~filters.forwarded
|
65 |
+
)
|
66 |
+
async def chatgpt_images(client: Client, message: Message):
|
67 |
+
question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
68 |
+
if not question:
|
69 |
+
return await message.reply_text("Give ask from CHATGPT images")
|
70 |
+
try:
|
71 |
+
replys = await message.reply_text("Prossing.....")
|
72 |
+
response = await RendyDevChat.image_generator(question)
|
73 |
+
x = response["randydev"].get("url")
|
74 |
+
for i, url in enumerate(x, start=1):
|
75 |
+
await FullStackDev.fast(url, filename=f"original_{i}.png")
|
76 |
+
await message.reply_media_group(
|
77 |
+
[
|
78 |
+
InputMediaPhoto(f"original_1.png"),
|
79 |
+
InputMediaPhoto(f"original_2.png"),
|
80 |
+
InputMediaPhoto(f"original_3.png"),
|
81 |
+
InputMediaPhoto(f"original_4.png")
|
82 |
+
],
|
83 |
+
)
|
84 |
+
await replys.delete()
|
85 |
+
except Exception as e:
|
86 |
+
LOGS.error(str(e))
|
87 |
+
return await message.reply_text(str(e))
|
88 |
+
|
89 |
+
@Akeno(
|
90 |
+
~filters.scheduled
|
91 |
+
& filters.command(["ask"], CMD_HANDLER)
|
92 |
+
& filters.me
|
93 |
+
& ~filters.forwarded
|
94 |
+
)
|
95 |
+
async def chatgpt(client: Client, message: Message):
|
96 |
+
question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
97 |
+
if not question:
|
98 |
+
return await message.reply_text("Give ask from CHATGPT")
|
99 |
+
try:
|
100 |
+
messager = await chat_message(question)
|
101 |
+
if len(messager) > 4096:
|
102 |
+
with open("chat.txt", "w+", encoding="utf8") as out_file:
|
103 |
+
out_file.write(messager)
|
104 |
+
await message.reply_document(
|
105 |
+
document="chat.txt",
|
106 |
+
disable_notification=True
|
107 |
+
)
|
108 |
+
os.remove("chat.txt")
|
109 |
+
else:
|
110 |
+
await message.reply_text(messager)
|
111 |
+
except Exception as e:
|
112 |
+
LOGS.error(str(e))
|
113 |
+
return await message.reply_text(str(e))
|
Akeno/plugins/gban.py
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
# Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea
|
4 |
+
#
|
5 |
+
# from : https://github.com/TeamKillerX
|
6 |
+
# Channel : @RendyProjects
|
7 |
+
# This program is free software: you can redistribute it and/or modify
|
8 |
+
# it under the terms of the GNU Affero General Public License as published by
|
9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
10 |
+
# (at your option) any later version.
|
11 |
+
#
|
12 |
+
# This program is distributed in the hope that it will be useful,
|
13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
# GNU Affero General Public License for more details.
|
16 |
+
#
|
17 |
+
# You should have received a copy of the GNU Affero General Public License
|
18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
+
|
20 |
+
# Credits Developer by @xtdevs
|
21 |
+
# NO NEED DATABASE USING API REST DB
|
22 |
+
|
23 |
+
import asyncio
|
24 |
+
from pyrogram import Client, filters
|
25 |
+
from pyrogram.types import Message
|
26 |
+
from pyrogram import errors, filters
|
27 |
+
from pyrogram import *
|
28 |
+
from pyrogram.types import *
|
29 |
+
from pyrogram.enums import ChatType, ChatMemberStatus as CMS
|
30 |
+
from pyrogram.errors import FloodWait
|
31 |
+
from pyrogram.errors import ChannelInvalid
|
32 |
+
from pyrogram.types import ChatPermissions, Message
|
33 |
+
from pyrogram.raw.functions.messages import DeleteHistory
|
34 |
+
from Akeno.utils.tools import get_ub_chats
|
35 |
+
from Akeno.utils.spamwatch import auto_post_gban, auto_check_gban
|
36 |
+
from Akeno.utils.handler import Akeno, Akeno_chat_member_updated
|
37 |
+
from config import FEDBAN_API_KEY, CMD_HANDLER
|
38 |
+
|
39 |
+
async def input_user(message: Message) -> str:
|
40 |
+
"""Get the input from the user"""
|
41 |
+
if len(message.command) < 2:
|
42 |
+
output = ""
|
43 |
+
else:
|
44 |
+
try:
|
45 |
+
output = message.text.split(" ", 1)[1].strip() or ""
|
46 |
+
except IndexError:
|
47 |
+
output = ""
|
48 |
+
return output
|
49 |
+
|
50 |
+
@Akeno(
|
51 |
+
~filters.scheduled & filters.command(["gban"], CMD_HANDLER) & filters.me & ~filters.forwarded
|
52 |
+
)
|
53 |
+
async def globalban(client: Client, message: Message):
|
54 |
+
if not message.reply_to_message:
|
55 |
+
if len(message.command) < 2:
|
56 |
+
return await message.reply_text(
|
57 |
+
"Reply to a user or pass a username/id to gban."
|
58 |
+
)
|
59 |
+
try:
|
60 |
+
user = await client.get_users(message.command[1])
|
61 |
+
except Exception as e:
|
62 |
+
return await message.reply_text(f"`{str(e)}`")
|
63 |
+
reason = (
|
64 |
+
message.text.split(None, 2)[2]
|
65 |
+
if len(message.text.split()) > 2
|
66 |
+
else "No reason provided."
|
67 |
+
)
|
68 |
+
else:
|
69 |
+
user = message.reply_to_message.from_user
|
70 |
+
reason = await input_user(message) or "No reason provided."
|
71 |
+
if user.is_self:
|
72 |
+
return await message.reply_text("I can't gban myself.")
|
73 |
+
if user.id == client.me.id:
|
74 |
+
return await message.reply_text("I can't gban my auth user.")
|
75 |
+
success = 0
|
76 |
+
failed = 0
|
77 |
+
pro = await message.reply_text(f"Gban initiated on {user.mention}...")
|
78 |
+
if not FEDBAN_API_KEY:
|
79 |
+
return await pro.edit_text("Required `FEDBAN_API_KEY` from @randydev_bot use /getapikey")
|
80 |
+
is_banned, get_message = await auto_post_gban(user.id, reason)
|
81 |
+
if is_banned == True:
|
82 |
+
async for dialog in client.get_dialogs():
|
83 |
+
if dialog.chat.type in [
|
84 |
+
ChatType.CHANNEL,
|
85 |
+
ChatType.GROUP,
|
86 |
+
ChatType.SUPERGROUP,
|
87 |
+
]:
|
88 |
+
try:
|
89 |
+
await dialog.chat.ban_member(user.id)
|
90 |
+
success += 1
|
91 |
+
except FloodWait as e:
|
92 |
+
await pro.edit_text(
|
93 |
+
f"Gban initiated on {user.mention}...\nSleeping for {e.x} seconds due to floodwait..."
|
94 |
+
)
|
95 |
+
await asyncio.sleep(e.x)
|
96 |
+
await dialog.chat.ban_member(user.id)
|
97 |
+
success += 1
|
98 |
+
await pro.edit_text(f"Gban initiated on {user.mention}...")
|
99 |
+
except BaseException:
|
100 |
+
failed += 1
|
101 |
+
messager = ""
|
102 |
+
messager += get_message
|
103 |
+
messager += f"\n\nSuccess: {success}\n"
|
104 |
+
messager += f"Failed: {failed}\n"
|
105 |
+
await pro.edit_text(messager)
|
106 |
+
|
107 |
+
@Akeno_chat_member_updated
|
108 |
+
async def globalbanwatcher(_, u: ChatMemberUpdated):
|
109 |
+
if not (member.new_chat_member and member.new_chat_member.status not in {CMS.BANNED, CMS.LEFT, CMS.RESTRICTED} and not member.old_chat_member):
|
110 |
+
return
|
111 |
+
user = member.new_chat_member.user if member.new_chat_member else member.from_user
|
112 |
+
response = await auto_check_gban(user.id)
|
113 |
+
if response[0] == True:
|
114 |
+
watchertext = f"**𝖦𝖻𝖺𝗇𝗇𝖾𝖽 𝖴𝗌𝖾𝗋 𝗃𝗈𝗂𝗇𝖾𝖽 𝗍𝗁𝖾 𝖼𝗁𝖺𝗍! \n\n𝖦𝖻𝖺𝗇 𝖱𝖾𝖺𝗌𝗈𝗇 𝗐𝖺𝗌:** __{response[1]}__\n\n"
|
115 |
+
try:
|
116 |
+
await _.ban_chat_member(u.chat.id, user.id)
|
117 |
+
watchertext += f"**𝖲𝗈𝗋𝗋𝗒 𝖨 𝖼𝖺𝗇'𝗍 𝗌𝖾𝖾 𝗒𝗈𝗎 𝗂𝗇 𝗍𝗁𝗂𝗌 𝖼𝗁𝖺��!**"
|
118 |
+
except BaseException:
|
119 |
+
watchertext += f"Reported to @admins"
|
120 |
+
await _.send_message(u.chat.id, watchertext)
|
121 |
+
return
|
122 |
+
|
123 |
+
@Akeno(
|
124 |
+
filters.private
|
125 |
+
& filters.incoming
|
126 |
+
& ~filters.service
|
127 |
+
& ~filters.me
|
128 |
+
& ~filters.bot
|
129 |
+
)
|
130 |
+
async def global_spammer(client: Client, message: Message):
|
131 |
+
if not message or not message.from_user:
|
132 |
+
return
|
133 |
+
user_id = message.from_user.id
|
134 |
+
response = await auto_check_gban(user_id)
|
135 |
+
if response[0] == True:
|
136 |
+
if message.photo:
|
137 |
+
await message.delete()
|
138 |
+
elif message.video:
|
139 |
+
await message.delete()
|
140 |
+
else:
|
141 |
+
await client.block_user(user_id)
|
142 |
+
message.continue_propagation()
|
Akeno/plugins/imageai.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# -*- coding: utf-8 -*-
|
3 |
+
# Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea
|
4 |
+
#
|
5 |
+
# from : https://github.com/TeamKillerX
|
6 |
+
# Channel : @RendyProjects
|
7 |
+
# This program is free software: you can redistribute it and/or modify
|
8 |
+
# it under the terms of the GNU Affero General Public License as published by
|
9 |
+
# the Free Software Foundation, either version 3 of the License, or
|
10 |
+
# (at your option) any later version.
|
11 |
+
#
|
12 |
+
# This program is distributed in the hope that it will be useful,
|
13 |
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
# GNU Affero General Public License for more details.
|
16 |
+
#
|
17 |
+
# You should have received a copy of the GNU Affero General Public License
|
18 |
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
+
|
20 |
+
import requests
|
21 |
+
import io
|
22 |
+
from PIL import Image
|
23 |
+
from pyrogram import Client, filters
|
24 |
+
from pyrogram.types import *
|
25 |
+
from pyrogram import *
|
26 |
+
|
27 |
+
from Akeno.utils.logger import LOGS
|
28 |
+
from Akeno.utils.handler import Akeno
|
29 |
+
from config import HUGGING_TOKEN, CMD_HANDLER
|
30 |
+
|
31 |
+
async def schellwithflux(args):
|
32 |
+
API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-schnell"
|
33 |
+
headers = {"Authorization": f"Bearer {HUGGING_TOKEN}"}
|
34 |
+
payload = {"inputs": args}
|
35 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
36 |
+
if not response.status_code != 200:
|
37 |
+
LOGS.error(f"Error status {response.status_code}")
|
38 |
+
return "Error Response"
|
39 |
+
return response.content
|
40 |
+
|
41 |
+
@Akeno(
|
42 |
+
~filters.scheduled
|
43 |
+
& filters.command(["fluxai"], CMD_HANDLER)
|
44 |
+
& filters.me
|
45 |
+
& ~filters.forwarded
|
46 |
+
)
|
47 |
+
async def fluxai(client: Client, message: Message):
|
48 |
+
question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None
|
49 |
+
if not question:
|
50 |
+
return await message.reply_text("Give ask from Flux")
|
51 |
+
try:
|
52 |
+
if not HUGGING_TOKEN:
|
53 |
+
return await message.reply_text("Required `HUGGING_TOKEN`")
|
54 |
+
image_bytes = await schellwithflux(question)
|
55 |
+
pro = await message.reply_text("Image Generator wait...")
|
56 |
+
image = Image.open(io.BytesIO(image_bytes))
|
57 |
+
if image:
|
58 |
+
image.save("testing.jpg")
|
59 |
+
ok = await pro.edit_text("Uploading......")
|
60 |
+
await message.reply_photo("testing.jpg")
|
61 |
+
await ok.delete()
|
62 |
+
except Exception as e:
|
63 |
+
LOGS.error(str(e))
|
64 |
+
await pro.edit_text(str(e))
|
Akeno/plugins/ping.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
import asyncio
|
3 |
+
from pyrogram import Client, filters
|
4 |
+
from datetime import datetime as dt
|
5 |
+
from Akeno import StartTime
|
6 |
+
from Akeno.utils.handler import Akeno
|
7 |
+
from datetime import datetime as dt
|
8 |
+
from config import CMD_HANDLER
|
9 |
+
|
10 |
+
def get_readable_time(seconds: int) -> str:
|
11 |
+
count = 0
|
12 |
+
readable_time = ""
|
13 |
+
time_list = []
|
14 |
+
time_suffix_list = ["s", "m", "h", "days"]
|
15 |
+
|
16 |
+
while count < 4:
|
17 |
+
count += 1
|
18 |
+
remainder, result = divmod(seconds, 60) if count < 3 else divmod(seconds, 24)
|
19 |
+
if seconds == 0 and remainder == 0:
|
20 |
+
break
|
21 |
+
time_list.append(int(result))
|
22 |
+
seconds = int(remainder)
|
23 |
+
|
24 |
+
for x in range(len(time_list)):
|
25 |
+
time_list[x] = str(time_list[x]) + time_suffix_list[x]
|
26 |
+
if len(time_list) == 4:
|
27 |
+
readable_time += f"{time_list.pop()}, "
|
28 |
+
|
29 |
+
time_list.reverse()
|
30 |
+
readable_time += ":".join(time_list)
|
31 |
+
|
32 |
+
return readable_time
|
33 |
+
|
34 |
+
@Akeno(
|
35 |
+
~filters.scheduled
|
36 |
+
& filters.command(["ping"], CMD_HANDLER)
|
37 |
+
& filters.me
|
38 |
+
& ~filters.forwarded
|
39 |
+
)
|
40 |
+
async def custom_ping_handler(client: Client, message: Message):
|
41 |
+
uptime = get_readable_time((time.time() - StartTime))
|
42 |
+
start = dt.now()
|
43 |
+
lol = await message.reply_text("**Pong!!**")
|
44 |
+
await asyncio.sleep(1.5)
|
45 |
+
end = dt.now()
|
46 |
+
duration = (end - start).microseconds / 1000
|
47 |
+
await lol.edit_text(
|
48 |
+
f" **Pong !!** " f"`%sms` \n" f" **Uptime** - " f"`{uptime}` " % (duration)
|
49 |
+
)
|