Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
678fc0d
1
Parent(s):
3580517
forgot to add this
Browse files- Powers/plugins/stickers.py +62 -4
- Powers/utils/sticker_help.py +41 -0
Powers/plugins/stickers.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
import os
|
| 2 |
-
from asyncio import gather
|
| 3 |
from random import choice
|
| 4 |
from traceback import format_exc
|
| 5 |
|
|
@@ -376,6 +375,66 @@ async def get_my_sticker_sets(c: Gojo, m: Message):
|
|
| 376 |
return
|
| 377 |
await m.reply_text(txt, reply_markup=kb)
|
| 378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
| 380 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
| 381 |
data = q.data.split("_")
|
|
@@ -408,11 +467,10 @@ __HELP__ = """
|
|
| 408 |
• /getsticker (/getst) : Get sticker as photo, gif or vice versa.
|
| 409 |
• /stickerid (/stid) : Reply to any sticker to get it's id
|
| 410 |
• /mypacks : Get all of your current sticker pack you have made via me.
|
|
|
|
|
|
|
| 411 |
• /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
|
| 412 |
■ For e.g.
|
| 413 |
-
○ /mmf Hello freinds : this will add text to the top
|
| 414 |
-
○ /mmf Hello ; freinds : this will add Hello to the top and freinds at the bottom
|
| 415 |
-
○ /mmf ; Hello friends : this will add text at the bottom
|
| 416 |
○ /mmfb <text>: To fill text with black colour
|
| 417 |
○ /mmfw or /mmf <text>: To fill it with white colour
|
| 418 |
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
from random import choice
|
| 3 |
from traceback import format_exc
|
| 4 |
|
|
|
|
| 375 |
return
|
| 376 |
await m.reply_text(txt, reply_markup=kb)
|
| 377 |
|
| 378 |
+
@Gojo.on_message(command("q"))
|
| 379 |
+
async def quote_the_msg(_, m: Message):
|
| 380 |
+
if not m.reply_to_message:
|
| 381 |
+
await m.reply_text("Reply to a message to quote it")
|
| 382 |
+
return
|
| 383 |
+
|
| 384 |
+
to_edit = await m.reply_text("Genrating quote...")
|
| 385 |
+
|
| 386 |
+
msg_data = []
|
| 387 |
+
if len(m.command) > 1:
|
| 388 |
+
reply_msg = m.reply_to_message.reply_to_message
|
| 389 |
+
if not reply_msg:
|
| 390 |
+
reply_message = {}
|
| 391 |
+
elif reply_msg and not reply_msg.text:
|
| 392 |
+
reply_message = {}
|
| 393 |
+
else:
|
| 394 |
+
to_edit = await to_edit.edit_text("Genrating quote with reply to the message...")
|
| 395 |
+
replied_name = reply_msg.from_user.first_name
|
| 396 |
+
if reply_msg.from_user.last_name:
|
| 397 |
+
replied_name += f" {reply_msg.from_user.last_name}"
|
| 398 |
+
|
| 399 |
+
reply_message = {
|
| 400 |
+
"chatId": reply_msg.from_user.id,
|
| 401 |
+
"entities": get_msg_entities(reply_msg),
|
| 402 |
+
"name": replied_name,
|
| 403 |
+
"text": reply_msg.text,
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
name = m.reply_to_message.from_user.first_name
|
| 407 |
+
if m.reply_to_message.from_user.last_name:
|
| 408 |
+
name += f" {m.reply_to_message.from_user.last_name}"
|
| 409 |
+
|
| 410 |
+
emoji_status = None
|
| 411 |
+
if m.reply_to_message.from_user.emoji_status:
|
| 412 |
+
emoji_status = str(m.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
| 413 |
+
|
| 414 |
+
msg_data.append(
|
| 415 |
+
{
|
| 416 |
+
"entities": get_msg_entities(m.reply_to_message),
|
| 417 |
+
"avatar": True,
|
| 418 |
+
"from": {
|
| 419 |
+
"id": m.reply_to_message.from_user.id,
|
| 420 |
+
"name": name,
|
| 421 |
+
"emoji_status": emoji_status,
|
| 422 |
+
},
|
| 423 |
+
"text": m.reply_to_message.text,
|
| 424 |
+
"replyMessage": reply_message,
|
| 425 |
+
}
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
+
status, path = quotify(msg_data)
|
| 429 |
+
|
| 430 |
+
if not status:
|
| 431 |
+
await to_edit.edit_text(path)
|
| 432 |
+
return
|
| 433 |
+
|
| 434 |
+
await m.reply_sticker(path)
|
| 435 |
+
await to_edit.delete()
|
| 436 |
+
os.remove(path)
|
| 437 |
+
|
| 438 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
| 439 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
| 440 |
data = q.data.split("_")
|
|
|
|
| 467 |
• /getsticker (/getst) : Get sticker as photo, gif or vice versa.
|
| 468 |
• /stickerid (/stid) : Reply to any sticker to get it's id
|
| 469 |
• /mypacks : Get all of your current sticker pack you have made via me.
|
| 470 |
+
• /q <reply to message> : Will quote the replied message
|
| 471 |
+
• /q r <reply to message> : Will quote the replied message and message it was replied to.
|
| 472 |
• /mmf <your text>: Reply to a normal sticker or a photo or video file to memify it. If you want to right text at bottom use `;right your message`
|
| 473 |
■ For e.g.
|
|
|
|
|
|
|
|
|
|
| 474 |
○ /mmfb <text>: To fill text with black colour
|
| 475 |
○ /mmfw or /mmf <text>: To fill it with white colour
|
| 476 |
|
Powers/utils/sticker_help.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import asyncio
|
|
|
|
| 2 |
import math
|
| 3 |
import os
|
| 4 |
import shlex
|
|
@@ -6,6 +7,7 @@ import textwrap
|
|
| 6 |
from time import time
|
| 7 |
from typing import List, Tuple
|
| 8 |
|
|
|
|
| 9 |
from PIL import Image, ImageDraw, ImageFont
|
| 10 |
from pyrogram import errors, raw
|
| 11 |
from pyrogram.file_id import FileId
|
|
@@ -18,6 +20,45 @@ from Powers.bot_class import Gojo
|
|
| 18 |
from Powers.utils.string import encode_decode
|
| 19 |
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
async def get_all_sticker_packs(c: Gojo, user_id: int, st_type: str, offset: int = 1, limit: int = 25):
|
| 22 |
packnum = 25 * (offset - 1)
|
| 23 |
txt = f"Here is your stickers pack that I have created:\nPage: {offset}\n\nNOTE: I may have kanged more sticker sets for you, but since last update I will no longer add stickers in those packs due to recent telegram update in bot api sorry."
|
|
|
|
| 1 |
import asyncio
|
| 2 |
+
import base64
|
| 3 |
import math
|
| 4 |
import os
|
| 5 |
import shlex
|
|
|
|
| 7 |
from time import time
|
| 8 |
from typing import List, Tuple
|
| 9 |
|
| 10 |
+
import requests
|
| 11 |
from PIL import Image, ImageDraw, ImageFont
|
| 12 |
from pyrogram import errors, raw
|
| 13 |
from pyrogram.file_id import FileId
|
|
|
|
| 20 |
from Powers.utils.string import encode_decode
|
| 21 |
|
| 22 |
|
| 23 |
+
def quotify(msg_info: List[dict]) -> Tuple[bool, str]:
|
| 24 |
+
json = {
|
| 25 |
+
"type": "quote",
|
| 26 |
+
"format": "webp",
|
| 27 |
+
"backgroundColor": "#000000",
|
| 28 |
+
"width": 512,
|
| 29 |
+
"height": 768,
|
| 30 |
+
"scale": 2,
|
| 31 |
+
"messages": msg_info,
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
try:
|
| 35 |
+
response = requests.post("https://bot.lyo.su/quote/generate", json=json).json()
|
| 36 |
+
image = base64.b64decode(str(response["result"]["image"]).encode("utf-8"))
|
| 37 |
+
|
| 38 |
+
file_name = f"Quote_{int(time())}.webp"
|
| 39 |
+
with open(file_name, "wb") as f:
|
| 40 |
+
f.write(image)
|
| 41 |
+
|
| 42 |
+
return True, file_name
|
| 43 |
+
except Exception as e:
|
| 44 |
+
return False, str(e)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def get_msg_entities(m: Message) -> List[dict]:
|
| 48 |
+
entities = []
|
| 49 |
+
|
| 50 |
+
if m.entities:
|
| 51 |
+
for entity in m.entities:
|
| 52 |
+
entities.append(
|
| 53 |
+
{
|
| 54 |
+
"type": entity.type.name.lower(),
|
| 55 |
+
"offset": entity.offset,
|
| 56 |
+
"length": entity.length,
|
| 57 |
+
}
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
return entities
|
| 61 |
+
|
| 62 |
async def get_all_sticker_packs(c: Gojo, user_id: int, st_type: str, offset: int = 1, limit: int = 25):
|
| 63 |
packnum = 25 * (offset - 1)
|
| 64 |
txt = f"Here is your stickers pack that I have created:\nPage: {offset}\n\nNOTE: I may have kanged more sticker sets for you, but since last update I will no longer add stickers in those packs due to recent telegram update in bot api sorry."
|