Added and updated repositories 2025-07-11 08:27:20

This commit is contained in:
github-actions[bot]
2025-07-11 08:27:20 +00:00
parent 35e8befc45
commit e328cd957a
320 changed files with 37419 additions and 33510 deletions

View File

@@ -1,39 +1,39 @@
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from requests import post
import io
@loader.tds
class x0Mod(loader.Module):
"""Uploader"""
strings = {
"name": "x0 Uploader"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def x0cmd(self, message):
await message.edit("<b>Uploading...</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to message!</b>")
return
media = reply.media
if not media:
file = io.BytesIO(bytes(reply.raw_text, "utf-8"))
file.name = "txt.txt"
else:
file = io.BytesIO(await self.client.download_file(media))
file.name = reply.file.name if reply.file.name else reply.file.id+reply.file.ext
try:
x0at = post('https://x0.at', files={'file': file})
except ConnectionError as e:
await message.edit(ste(e))
return
url = x0at.text
output = f'<a href="{url}">URL: </a><code>{url}</code>'
await message.edit(output)
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from requests import post
import io
@loader.tds
class x0Mod(loader.Module):
"""Uploader"""
strings = {
"name": "x0 Uploader"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def x0cmd(self, message):
await message.edit("<b>Uploading...</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to message!</b>")
return
media = reply.media
if not media:
file = io.BytesIO(bytes(reply.raw_text, "utf-8"))
file.name = "txt.txt"
else:
file = io.BytesIO(await self.client.download_file(media))
file.name = reply.file.name if reply.file.name else reply.file.id+reply.file.ext
try:
x0at = post('https://x0.at', files={'file': file})
except ConnectionError as e:
await message.edit(ste(e))
return
url = x0at.text
output = f'<a href="{url}">URL: </a><code>{url}</code>'
await message.edit(output)

View File

@@ -1,105 +1,105 @@
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from PIL import Image, ImageDraw, ImageOps, ImageFilter
import io
from telethon.tl.types import DocumentAttributeFilename
import logging
from moviepy.editor import VideoFileClip
import os
logger = logging.getLogger(__name__)
def register(cb):
cb(CirclesMod())
@loader.tds
class CirclesMod(loader.Module):
"""округляет всё"""
strings = {
"name": "Circles"
}
def __init__(self):
self.name = self.strings['name']
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def roundcmd(self, message):
""".round <Reply to image/sticker or video/gif>"""
reply = None
if message.is_reply:
reply = await message.get_reply_message()
data = await check_media(reply)
if isinstance(data, bool):
await utils.answer(message, "<b>Reply to image/sticker or video/gif!</b>")
return
else:
await utils.answer(message, "<b>Reply to image/sticker or video/gif!</b>")
return
data, type = data
if type == "img":
await message.edit("<b>Processing image</b>📷")
img = io.BytesIO()
bytes = await message.client.download_file(data, img)
im = Image.open(img)
w, h = im.size
img = Image.new("RGBA", (w,h), (0,0,0,0))
img.paste(im, (0, 0))
m = min(w, h)
img = img.crop(((w-m)//2, (h-m)//2, (w+m)//2, (h+m)//2))
w, h = img.size
mask = Image.new('L', (w, h), 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((10, 10, w-10, h-10), fill=255)
mask = mask.filter(ImageFilter.GaussianBlur(2))
img = ImageOps.fit(img, (w, h))
img.putalpha(mask)
im = io.BytesIO()
im.name = "img.webp"
img.save(im)
im.seek(0)
await message.client.send_file(message.to_id, im, reply_to=reply)
else:
await message.edit("<b>Processing video</b>🎥")
await message.client.download_file(data, "video.mp4")
video = VideoFileClip("video.mp4")
video.reader.close()
w, h = video.size
m = min(w, h)
box = [(w-m)//2, (h-m)//2, (w+m)//2, (h+m)//2]
video = video.crop(*box)
await message.edit("<b>Saving video</b>📼")
video.write_videofile("result.mp4")
await message.client.send_file(message.to_id, "result.mp4", video_note=True, reply_to=reply)
os.remove("video.mp4")
os.remove("result.mp4")
await message.delete()
async def check_media(reply):
type = "img"
if reply and reply.media:
if reply.photo:
data = reply.photo
elif reply.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply.media.document.attributes:
return False
if reply.gif or reply.video:
type = "vid"
if reply.audio or reply.voice:
return False
data = reply.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return (data, type)
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from PIL import Image, ImageDraw, ImageOps, ImageFilter
import io
from telethon.tl.types import DocumentAttributeFilename
import logging
from moviepy.editor import VideoFileClip
import os
logger = logging.getLogger(__name__)
def register(cb):
cb(CirclesMod())
@loader.tds
class CirclesMod(loader.Module):
"""округляет всё"""
strings = {
"name": "Circles"
}
def __init__(self):
self.name = self.strings['name']
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def roundcmd(self, message):
""".round <Reply to image/sticker or video/gif>"""
reply = None
if message.is_reply:
reply = await message.get_reply_message()
data = await check_media(reply)
if isinstance(data, bool):
await utils.answer(message, "<b>Reply to image/sticker or video/gif!</b>")
return
else:
await utils.answer(message, "<b>Reply to image/sticker or video/gif!</b>")
return
data, type = data
if type == "img":
await message.edit("<b>Processing image</b>📷")
img = io.BytesIO()
bytes = await message.client.download_file(data, img)
im = Image.open(img)
w, h = im.size
img = Image.new("RGBA", (w,h), (0,0,0,0))
img.paste(im, (0, 0))
m = min(w, h)
img = img.crop(((w-m)//2, (h-m)//2, (w+m)//2, (h+m)//2))
w, h = img.size
mask = Image.new('L', (w, h), 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((10, 10, w-10, h-10), fill=255)
mask = mask.filter(ImageFilter.GaussianBlur(2))
img = ImageOps.fit(img, (w, h))
img.putalpha(mask)
im = io.BytesIO()
im.name = "img.webp"
img.save(im)
im.seek(0)
await message.client.send_file(message.to_id, im, reply_to=reply)
else:
await message.edit("<b>Processing video</b>🎥")
await message.client.download_file(data, "video.mp4")
video = VideoFileClip("video.mp4")
video.reader.close()
w, h = video.size
m = min(w, h)
box = [(w-m)//2, (h-m)//2, (w+m)//2, (h+m)//2]
video = video.crop(*box)
await message.edit("<b>Saving video</b>📼")
video.write_videofile("result.mp4")
await message.client.send_file(message.to_id, "result.mp4", video_note=True, reply_to=reply)
os.remove("video.mp4")
os.remove("result.mp4")
await message.delete()
async def check_media(reply):
type = "img"
if reply and reply.media:
if reply.photo:
data = reply.photo
elif reply.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply.media.document.attributes:
return False
if reply.gif or reply.video:
type = "vid"
if reply.audio or reply.voice:
return False
data = reply.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return (data, type)

View File

@@ -1,111 +1,111 @@
# requires: pillow
# requires: wand
from .. import loader, utils
import io
from telethon.tl.types import DocumentAttributeFilename
import logging
from wand.image import Image
from PIL import Image as IM
# https://t.me/KeyZenD
# https://t.me/SomeScripts
logger = logging.getLogger(__name__)
def register(cb):
cb(DistortNoApiMod())
@loader.tds
class DistortNoApiMod(loader.Module):
"""distorting images"""
strings = {
"name": "DistortNoApi"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def distortcmd(self, message):
""".distort <reply to photo>
.distort im
.distort 50
.distort 50 im
.distort im 50
im => кидает стикеры как фото
50 => (от 0 до дохуя) процент сжатия"""
if message.is_reply:
reply_message = await message.get_reply_message()
data, mime = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Reply to image or stick!</code>")
return
else:
await utils.answer(message, "<code>Reply to image or stick!</code>")
return
rescale_rate = 70
a = utils.get_args(message)
force_file = False
if a:
if 'im' in a:
force_file = True
a.remove('im')
if len(a) > 0:
if a[0].isdigit():
rescale_rate = int(a[0])
if rescale_rate <= 0:
rescale_rate = 70
await message.edit("<code>D i s t o r t i n g . . .</code>")
file = await message.client.download_media(data, bytes)
file, img = io.BytesIO(file), io.BytesIO()
img.name = 'img.png'
IM.open(file).save(img, 'PNG')
media = await distort(io.BytesIO(img.getvalue()), rescale_rate)
out, im = io.BytesIO(), IM.open(media)
if force_file:
mime = 'png'
out.name = f'out.{mime}'
im.save(out, mime.upper())
out.seek(0)
await message.edit("<code>S e n d i n g . . .</code>")
await message.client.send_file(message.to_id, out, reply_to=reply_message.id)
await message.delete()
async def distort(file, rescale_rate):
img = Image(file=file)
x, y = img.size[0], img.size[1]
popx = int(rescale_rate*(x//100))
popy = int(rescale_rate*(y//100))
img.liquid_rescale(popx, popy, delta_x=1, rigidity=0)
img.resize(x, y)
out = io.BytesIO()
out.name = f'output.png'
img.save(file=out)
return io.BytesIO(out.getvalue())
async def check_media(reply_message):
mime = None
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
mime = 'image/jpeg'
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False, mime
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False, mime
data = reply_message.media.document
mime = reply_message.media.document.mime_type
if 'image/' not in mime:
return False, mime
else:
return False, mime
else:
return False, mime
if not data or data is None:
return False, mime
else:
mime = mime.split('/')[1]
return data, mime
# requires: pillow
# requires: wand
from .. import loader, utils
import io
from telethon.tl.types import DocumentAttributeFilename
import logging
from wand.image import Image
from PIL import Image as IM
# https://t.me/KeyZenD
# https://t.me/SomeScripts
logger = logging.getLogger(__name__)
def register(cb):
cb(DistortNoApiMod())
@loader.tds
class DistortNoApiMod(loader.Module):
"""distorting images"""
strings = {
"name": "DistortNoApi"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def distortcmd(self, message):
""".distort <reply to photo>
.distort im
.distort 50
.distort 50 im
.distort im 50
im => кидает стикеры как фото
50 => (от 0 до дохуя) процент сжатия"""
if message.is_reply:
reply_message = await message.get_reply_message()
data, mime = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Reply to image or stick!</code>")
return
else:
await utils.answer(message, "<code>Reply to image or stick!</code>")
return
rescale_rate = 70
a = utils.get_args(message)
force_file = False
if a:
if 'im' in a:
force_file = True
a.remove('im')
if len(a) > 0:
if a[0].isdigit():
rescale_rate = int(a[0])
if rescale_rate <= 0:
rescale_rate = 70
await message.edit("<code>D i s t o r t i n g . . .</code>")
file = await message.client.download_media(data, bytes)
file, img = io.BytesIO(file), io.BytesIO()
img.name = 'img.png'
IM.open(file).save(img, 'PNG')
media = await distort(io.BytesIO(img.getvalue()), rescale_rate)
out, im = io.BytesIO(), IM.open(media)
if force_file:
mime = 'png'
out.name = f'out.{mime}'
im.save(out, mime.upper())
out.seek(0)
await message.edit("<code>S e n d i n g . . .</code>")
await message.client.send_file(message.to_id, out, reply_to=reply_message.id)
await message.delete()
async def distort(file, rescale_rate):
img = Image(file=file)
x, y = img.size[0], img.size[1]
popx = int(rescale_rate*(x//100))
popy = int(rescale_rate*(y//100))
img.liquid_rescale(popx, popy, delta_x=1, rigidity=0)
img.resize(x, y)
out = io.BytesIO()
out.name = f'output.png'
img.save(file=out)
return io.BytesIO(out.getvalue())
async def check_media(reply_message):
mime = None
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
mime = 'image/jpeg'
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False, mime
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False, mime
data = reply_message.media.document
mime = reply_message.media.document.mime_type
if 'image/' not in mime:
return False, mime
else:
return False, mime
else:
return False, mime
if not data or data is None:
return False, mime
else:
mime = mime.split('/')[1]
return data, mime

View File

@@ -1,68 +1,68 @@
import asyncio
import logging
import sys, os, random
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class GlitcherMod(loader.Module):
"""Glitcher of anything"""
strings = {"name": "Glitcher",
"reply": "Reply to message!",
"error": "Impossible to upload file!",
"processing": "Work in progress!"}
@loader.unrestricted
async def glitchcmd(self, message):
""".glitch level: float or int <reply to anything>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
if not reply.file:
infile = "message.txt"
f = open(infile,"w")
f.write(reply.text)
f.close()
outfile = "glitched_message.txt"
else:
infile = await reply.download_media()
outfile = "glitched_"+infile
percent = 0.1
try:
percent = float(utils.get_args_raw(message))
except ValueError or TypeError:
pass
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("processing", message)]))
with open(infile, 'rb') as inf:
with open(outfile, 'wb') as outf:
fileext = infile.split(".")[1]
try:
for byte in range(headersize[fileext]):
inbyte = inf.read(1)
outbyte = inbyte
outf.write(outbyte)
except KeyError:
pass
while True:
inbyte = inf.read(1)
if not inbyte:
break
if (random.random() < percent/100):
outbyte = os.urandom(1)
else:
outbyte = inbyte
outf.write(outbyte)
try:
await reply.reply(file=outfile)
await message.delete()
except:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("error", message) ]))
finally:
[os.remove(file) for file in [infile, outfile]]
html = ["<b>{}<b>", "<code>{}</code>", "<i>{}</i>", "<del>{}</del>", "<u>{}</u>", '<a href="https://bruh.moment">{}</a>']
headersize = {'jpg': 9, 'png': 8, 'bmp': 54, 'gif': 14, 'tiff': 8}
import asyncio
import logging
import sys, os, random
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class GlitcherMod(loader.Module):
"""Glitcher of anything"""
strings = {"name": "Glitcher",
"reply": "Reply to message!",
"error": "Impossible to upload file!",
"processing": "Work in progress!"}
@loader.unrestricted
async def glitchcmd(self, message):
""".glitch level: float or int <reply to anything>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
if not reply.file:
infile = "message.txt"
f = open(infile,"w")
f.write(reply.text)
f.close()
outfile = "glitched_message.txt"
else:
infile = await reply.download_media()
outfile = "glitched_"+infile
percent = 0.1
try:
percent = float(utils.get_args_raw(message))
except ValueError or TypeError:
pass
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("processing", message)]))
with open(infile, 'rb') as inf:
with open(outfile, 'wb') as outf:
fileext = infile.split(".")[1]
try:
for byte in range(headersize[fileext]):
inbyte = inf.read(1)
outbyte = inbyte
outf.write(outbyte)
except KeyError:
pass
while True:
inbyte = inf.read(1)
if not inbyte:
break
if (random.random() < percent/100):
outbyte = os.urandom(1)
else:
outbyte = inbyte
outf.write(outbyte)
try:
await reply.reply(file=outfile)
await message.delete()
except:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("error", message) ]))
finally:
[os.remove(file) for file in [infile, outfile]]
html = ["<b>{}<b>", "<code>{}</code>", "<i>{}</i>", "<del>{}</del>", "<u>{}</u>", '<a href="https://bruh.moment">{}</a>']
headersize = {'jpg': 9, 'png': 8, 'bmp': 54, 'gif': 14, 'tiff': 8}

View File

@@ -1,70 +1,70 @@
from .. import loader, utils
from hashlib import md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s
def register(cb):
cb(HasherMod())
class HasherMod(loader.Module):
"""Hashing text and files"""
strings = {'name': 'Hasher'}
def __init__(self):
self.name = self.strings['name']
self._me = None
self._ratelimit = []
async def client_ready(self, client, db):
self._db = db
self._client = client
self.me = await client.get_me()
async def md5cmd(self, message):
""".md5 <(text or media) or (reply to text or media)>\nHashing to md5"""
await hashing(message, 0)
async def sha1cmd(self, message):
""".sha1 <(text or media) or (reply to text or media)\nHashing to sha1"""
await hashing(message, 1)
async def sha224cmd(self, message):
""".sha224 <(text or media) or (reply to text or media)\nHashing to sha224"""
await hashing(message, 2)
async def sha256cmd(self, message):
""".sha255 <(text or media) or (reply to text or media)\nHashing to sha256"""
await hashing(message, 3)
async def sha384cmd(self, message):
""".sha384 <(text or media) or (reply to text or media)\nHashing to sha384"""
await hashing(message, 4)
async def sha512cmd(self, message):
""".sha512 <(text or media) or (reply to text or media)\nHashing to sha512"""
await hashing(message, 5)
async def blake2bcmd(self, message):
""".blake2 <(text or media) or (reply to text or media)\nHashing to blake2"""
await hashing(message, 6)
async def blake2scmd(self, message):
""".blake2s <(text or media) or (reply to text or media)\nHashing to blake2s"""
await hashing(message, 7)
async def hashing(m, type):
types = [md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s]
typez = ["md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "blake2s"]
reply = await m.get_reply_message()
mtext = utils.get_args_raw(m)
if m.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(m, bytes)
elif mtext:
data = mtext.encode()
elif reply:
if reply.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(reply, bytes)
else:
data = reply.raw_text.encode()
else:
await m.edit(f"<b>What hashing to {typez[type]}?</b>")
return
await m.edit("<b>H a s h i n g . . .</b>")
try:
result = types[type](data)
await m.edit(typez[type].upper()+": <code>" + str(result.hexdigest()).upper()+"</code>")
except:
await m.edit("<b>ERЯOR!</b>")
from .. import loader, utils
from hashlib import md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s
def register(cb):
cb(HasherMod())
class HasherMod(loader.Module):
"""Hashing text and files"""
strings = {'name': 'Hasher'}
def __init__(self):
self.name = self.strings['name']
self._me = None
self._ratelimit = []
async def client_ready(self, client, db):
self._db = db
self._client = client
self.me = await client.get_me()
async def md5cmd(self, message):
""".md5 <(text or media) or (reply to text or media)>\nHashing to md5"""
await hashing(message, 0)
async def sha1cmd(self, message):
""".sha1 <(text or media) or (reply to text or media)\nHashing to sha1"""
await hashing(message, 1)
async def sha224cmd(self, message):
""".sha224 <(text or media) or (reply to text or media)\nHashing to sha224"""
await hashing(message, 2)
async def sha256cmd(self, message):
""".sha255 <(text or media) or (reply to text or media)\nHashing to sha256"""
await hashing(message, 3)
async def sha384cmd(self, message):
""".sha384 <(text or media) or (reply to text or media)\nHashing to sha384"""
await hashing(message, 4)
async def sha512cmd(self, message):
""".sha512 <(text or media) or (reply to text or media)\nHashing to sha512"""
await hashing(message, 5)
async def blake2bcmd(self, message):
""".blake2 <(text or media) or (reply to text or media)\nHashing to blake2"""
await hashing(message, 6)
async def blake2scmd(self, message):
""".blake2s <(text or media) or (reply to text or media)\nHashing to blake2s"""
await hashing(message, 7)
async def hashing(m, type):
types = [md5, sha1, sha224, sha256, sha384, sha512, blake2b, blake2s]
typez = ["md5", "sha1", "sha224", "sha256", "sha384", "sha512", "blake2b", "blake2s"]
reply = await m.get_reply_message()
mtext = utils.get_args_raw(m)
if m.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(m, bytes)
elif mtext:
data = mtext.encode()
elif reply:
if reply.media:
await m.edit("<b>D o w n l o a d i n g . . .</b>")
data = await m.client.download_file(reply, bytes)
else:
data = reply.raw_text.encode()
else:
await m.edit(f"<b>What hashing to {typez[type]}?</b>")
return
await m.edit("<b>H a s h i n g . . .</b>")
try:
result = types[type](data)
await m.edit(typez[type].upper()+": <code>" + str(result.hexdigest()).upper()+"</code>")
except:
await m.edit("<b>ERЯOR!</b>")

View File

@@ -1,44 +1,44 @@
from .. import loader, utils
import io
from requests import get
def register(cb):
cb(LoremIpsumMod())
class LoremIpsumMod(loader.Module):
"""Lorem Ipsum generation"""
strings = {'name': 'LoermIpsum'}
def __init__(self):
self.name = self.strings['name']
async def loremipsumcmd(self, message):
""".loremipsum <count: int> <length: str> <file?>
count - number of paragraphs| std: 1
length - s-short, m-medium, l-long, v-verylong|std: m(edium)
file - if nothing- send as message, if anything- send as file"""
s = 'small'
m = length = 'medium'
l = 'long'
v = 'verylong'
args = utils.get_args(message)
count = 1
as_file = False
if args:
count = int(args[0]) if args[0].isdigit() else 1
if len(args) == 2:
lenght = args[1].lower()
length = s if lenght in [s[:i+1] for i in range(len(s))] else l if lenght in [l[:i+1] for i in range(len(l))] else v if lenght in [v[:i+1] for i in range(len(v))] else m # сижу ахуел
if len(args) >= 3:
as_file = True
url = f"https://loripsum.net/api/{count}/{length}/plaintext"
out = get(url)
if as_file:
out = io.BytesIO(out.content)
out.name = f"LoremIpsum.{count}.txt"
out.seek(0)
else: out = out.text
await utils.answer(message, out)
from .. import loader, utils
import io
from requests import get
def register(cb):
cb(LoremIpsumMod())
class LoremIpsumMod(loader.Module):
"""Lorem Ipsum generation"""
strings = {'name': 'LoermIpsum'}
def __init__(self):
self.name = self.strings['name']
async def loremipsumcmd(self, message):
""".loremipsum <count: int> <length: str> <file?>
count - number of paragraphs| std: 1
length - s-short, m-medium, l-long, v-verylong|std: m(edium)
file - if nothing- send as message, if anything- send as file"""
s = 'small'
m = length = 'medium'
l = 'long'
v = 'verylong'
args = utils.get_args(message)
count = 1
as_file = False
if args:
count = int(args[0]) if args[0].isdigit() else 1
if len(args) == 2:
lenght = args[1].lower()
length = s if lenght in [s[:i+1] for i in range(len(s))] else l if lenght in [l[:i+1] for i in range(len(l))] else v if lenght in [v[:i+1] for i in range(len(v))] else m # сижу ахуел
if len(args) >= 3:
as_file = True
url = f"https://loripsum.net/api/{count}/{length}/plaintext"
out = get(url)
if as_file:
out = io.BytesIO(out.content)
out.name = f"LoremIpsum.{count}.txt"
out.seek(0)
else: out = out.text
await utils.answer(message, out)

View File

@@ -1,33 +1,33 @@
from .. import loader, utils
import io
@loader.tds
class MTFMod(loader.Module):
"""send Message as file"""
strings = {'name': 'MessageToFile'}
async def mtfcmd(self, message):
""".mtf <reply to text>"""
reply = await message.get_reply_message()
if not reply or not reply.message:
await message.edit("<b>Reply to text!</b>")
return
text = bytes(reply.raw_text, "utf8")
fname = utils.get_args_raw(message) or str(message.id+reply.id)+".txt"
file = io.BytesIO(text)
file.name = fname
file.seek(0)
await reply.reply(file=file)
await message.delete()
async def ftmcmd(self, message):
""".ftm <reply to file>"""
reply = await message.get_reply_message()
if not reply or not reply.file:
await message.edit("<b>Reply to file!</b>")
return
text = await reply.download_media(bytes)
text = str(text, "utf8")
if utils.get_args(message):
text = f"<code>{text}</code>"
from .. import loader, utils
import io
@loader.tds
class MTFMod(loader.Module):
"""send Message as file"""
strings = {'name': 'MessageToFile'}
async def mtfcmd(self, message):
""".mtf <reply to text>"""
reply = await message.get_reply_message()
if not reply or not reply.message:
await message.edit("<b>Reply to text!</b>")
return
text = bytes(reply.raw_text, "utf8")
fname = utils.get_args_raw(message) or str(message.id+reply.id)+".txt"
file = io.BytesIO(text)
file.name = fname
file.seek(0)
await reply.reply(file=file)
await message.delete()
async def ftmcmd(self, message):
""".ftm <reply to file>"""
reply = await message.get_reply_message()
if not reply or not reply.file:
await message.edit("<b>Reply to file!</b>")
return
text = await reply.download_media(bytes)
text = str(text, "utf8")
if utils.get_args(message):
text = f"<code>{text}</code>"
await utils.answer(message, utils.escape_html(text))

View File

@@ -1,83 +1,83 @@
# @KeyZenD & @D4n13l3k00
import random
from telethon import types
from .. import loader, utils
@loader.tds
class MegaMozgMod(loader.Module):
strings = {
'name': 'MegaMozg',
'pref': '<b>[MegaMozg]</b> ',
'need_arg': '{}Нужен аргумент',
'status': '{}{}',
'on': '{}Включён',
'off': '{}Выключен',
}
_db_name = 'MegaMozg'
async def client_ready(self, _, db):
self.db = db
@staticmethod
def str2bool(v):
return v.lower() in ("yes", "y", "ye", "yea", "true", "t", "1", "on", "enable", "start", "run", "go", "да")
async def mozgcmd(self, m: types.Message):
'.mozg <on/off/...> - Переключить режим дурачка в чате'
args = utils.get_args_raw(m)
if not m.chat:
return
chat = m.chat.id
if self.str2bool(args):
chats: list = self.db.get(self._db_name, 'chats', [])
chats.append(chat)
chats = list(set(chats))
self.db.set(self._db_name, 'chats', chats)
return await utils.answer(m, self.strings('on').format(self.strings('pref')))
chats: list = self.db.get(self._db_name, 'chats', [])
try:
chats.remove(chat)
except:
pass
chats = list(set(chats))
self.db.set(self._db_name, 'chats', chats)
return await utils.answer(m, self.strings('off').format(self.strings('pref')))
async def mozgchancecmd(self, m: types.Message):
'.mozgchance <int> - Устанвоить шанс 1 к N.\n0 - всегда отвечать'
args: str = utils.get_args_raw(m)
if args.isdigit():
self.db.set(self._db_name, 'chance', int(args))
return await utils.answer(m, self.strings('status').format(self.strings('pref'), args))
return await utils.answer(m, self.strings('need_arg').format(self.strings('pref')))
async def watcher(self, m: types.Message):
if not isinstance(m, types.Message):
return
if m.sender_id == (await m.client.get_me()).id or not m.chat:
return
if m.chat.id not in self.db.get(self._db_name, 'chats', []):
return
ch = self.db.get(self._db_name, 'chance', 0)
if ch != 0:
if random.randint(0, ch) != 0:
return
text = m.raw_text
words = {random.choice(
list(filter(lambda x: len(x) >= 3, text.split()))) for _ in ".."}
msgs = []
for word in words:
[msgs.append(x) async for x in m.client.iter_messages(m.chat.id, search=word) if x.replies and x.replies.max_id]
replier = random.choice(msgs)
sid = replier.id
eid = replier.replies.max_id
msgs = [x async for x in m.client.iter_messages(m.chat.id, ids=list(range(sid+1, eid+1))) if x and x.reply_to and x.reply_to.reply_to_msg_id == sid]
msg = random.choice(msgs)
await m.reply(msg)
# @KeyZenD & @D4n13l3k00
import random
from telethon import types
from .. import loader, utils
@loader.tds
class MegaMozgMod(loader.Module):
strings = {
'name': 'MegaMozg',
'pref': '<b>[MegaMozg]</b> ',
'need_arg': '{}Нужен аргумент',
'status': '{}{}',
'on': '{}Включён',
'off': '{}Выключен',
}
_db_name = 'MegaMozg'
async def client_ready(self, _, db):
self.db = db
@staticmethod
def str2bool(v):
return v.lower() in ("yes", "y", "ye", "yea", "true", "t", "1", "on", "enable", "start", "run", "go", "да")
async def mozgcmd(self, m: types.Message):
'.mozg <on/off/...> - Переключить режим дурачка в чате'
args = utils.get_args_raw(m)
if not m.chat:
return
chat = m.chat.id
if self.str2bool(args):
chats: list = self.db.get(self._db_name, 'chats', [])
chats.append(chat)
chats = list(set(chats))
self.db.set(self._db_name, 'chats', chats)
return await utils.answer(m, self.strings('on').format(self.strings('pref')))
chats: list = self.db.get(self._db_name, 'chats', [])
try:
chats.remove(chat)
except:
pass
chats = list(set(chats))
self.db.set(self._db_name, 'chats', chats)
return await utils.answer(m, self.strings('off').format(self.strings('pref')))
async def mozgchancecmd(self, m: types.Message):
'.mozgchance <int> - Устанвоить шанс 1 к N.\n0 - всегда отвечать'
args: str = utils.get_args_raw(m)
if args.isdigit():
self.db.set(self._db_name, 'chance', int(args))
return await utils.answer(m, self.strings('status').format(self.strings('pref'), args))
return await utils.answer(m, self.strings('need_arg').format(self.strings('pref')))
async def watcher(self, m: types.Message):
if not isinstance(m, types.Message):
return
if m.sender_id == (await m.client.get_me()).id or not m.chat:
return
if m.chat.id not in self.db.get(self._db_name, 'chats', []):
return
ch = self.db.get(self._db_name, 'chance', 0)
if ch != 0:
if random.randint(0, ch) != 0:
return
text = m.raw_text
words = {random.choice(
list(filter(lambda x: len(x) >= 3, text.split()))) for _ in ".."}
msgs = []
for word in words:
[msgs.append(x) async for x in m.client.iter_messages(m.chat.id, search=word) if x.replies and x.replies.max_id]
replier = random.choice(msgs)
sid = replier.id
eid = replier.replies.max_id
msgs = [x async for x in m.client.iter_messages(m.chat.id, ids=list(range(sid+1, eid+1))) if x and x.reply_to and x.reply_to.reply_to_msg_id == sid]
msg = random.choice(msgs)
await m.reply(msg)

View File

@@ -1,51 +1,51 @@
from .. import loader, utils
import io
from PIL import Image, ImageFont, ImageDraw
import requests
import textwrap
@loader.tds
class MicroQuotesMod(loader.Module):
"""Микроцитаты"""
strings = {"name": "MicroQuotes"}
async def mqcmd(self, message):
""".mq <реплай на текст>"""
bw = False if utils.get_args(message) else True
reply = await message.get_reply_message()
if not reply or not reply.raw_text:
await message.edit("<b>Ответь командой на умную цитату!</b>")
return
sender = reply.sender_id
if not sender:
sender = message.chat.id
if sender == 1087968824:
sender = message.chat.id
pfp = await message.client.download_profile_photo(sender, bytes)
await message.edit("<i>И сказал этот гений...</i>")
if not pfp:
pfp = b'BM:\x00\x00\x00\x00\x00\x00\x006\x00\x00\x00(\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x18\x00\x00\x00\x00\x00\x04\x00\x00\x00\xc4\x0e\x00\x00\xc4\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00'
text = "\n".join(textwrap.wrap(reply.raw_text, 30))
text = ""+text+""
bf = requests.get("https://raw.githubusercontent.com/KeyZenD/l/master/times.ttf").content
font = ImageFont.truetype(io.BytesIO(bf), 50)
im = Image.open(io.BytesIO(pfp))
if bw:
im = im.convert("L")
im = im.convert("RGBA").resize((1024, 1024))
w, h = im.size
w_, h_ = 20*(w//100), 20*(h//100)
im_ = Image.new("RGBA", (w-w_, h-h_), (0, 0, 0))
im_.putalpha(150)
im.paste(im_, (w_//2, h_//2), im_)
draw = ImageDraw.Draw(im)
_w, _h = draw.textsize(text=text, font=font)
x, y = (w-_w)//2, (h-_h)//2
draw.text((x, y), text=text, font=font, fill="#fff", align="center")
output=io.BytesIO()
im.save(output, "PNG")
output.seek(0)
await reply.reply(file=output)
await message.delete()
from .. import loader, utils
import io
from PIL import Image, ImageFont, ImageDraw
import requests
import textwrap
@loader.tds
class MicroQuotesMod(loader.Module):
"""Микроцитаты"""
strings = {"name": "MicroQuotes"}
async def mqcmd(self, message):
""".mq <реплай на текст>"""
bw = False if utils.get_args(message) else True
reply = await message.get_reply_message()
if not reply or not reply.raw_text:
await message.edit("<b>Ответь командой на умную цитату!</b>")
return
sender = reply.sender_id
if not sender:
sender = message.chat.id
if sender == 1087968824:
sender = message.chat.id
pfp = await message.client.download_profile_photo(sender, bytes)
await message.edit("<i>И сказал этот гений...</i>")
if not pfp:
pfp = b'BM:\x00\x00\x00\x00\x00\x00\x006\x00\x00\x00(\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x18\x00\x00\x00\x00\x00\x04\x00\x00\x00\xc4\x0e\x00\x00\xc4\x0e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\x00'
text = "\n".join(textwrap.wrap(reply.raw_text, 30))
text = ""+text+""
bf = requests.get("https://raw.githubusercontent.com/KeyZenD/l/master/times.ttf").content
font = ImageFont.truetype(io.BytesIO(bf), 50)
im = Image.open(io.BytesIO(pfp))
if bw:
im = im.convert("L")
im = im.convert("RGBA").resize((1024, 1024))
w, h = im.size
w_, h_ = 20*(w//100), 20*(h//100)
im_ = Image.new("RGBA", (w-w_, h-h_), (0, 0, 0))
im_.putalpha(150)
im.paste(im_, (w_//2, h_//2), im_)
draw = ImageDraw.Draw(im)
_w, _h = draw.textsize(text=text, font=font)
x, y = (w-_w)//2, (h-_h)//2
draw.text((x, y), text=text, font=font, fill="#fff", align="center")
output=io.BytesIO()
im.save(output, "PNG")
output.seek(0)
await reply.reply(file=output)
await message.delete()

View File

@@ -1,46 +1,46 @@
from .. import loader, utils
from telethon.tl.types import Message
class OneMessageMod(loader.Module):
"""@faq lines"""
strings = {'name': 'OneMessage'}
def __init__(self):
self.name = self.strings['name']
async def client_ready(self, client, db):
self.client = client
self._db = db
@loader.sudo
async def omstartcmd(self, message):
"""Start OneMessage mode"""
self._db.set("OneMessage", "status", True)
self._db.set("OneMessage", "my_id", message.sender_id)
await message.edit("<b>OneMessage mode activated!</b>")
async def omstopcmd(self, message):
"""Stop OneMessage mode"""
self._db.set("OneMessage", "status", False)
await message.edit("<b>OneMessage mode diactivated!</b>")
async def watcher(self, message):
if not isinstance(message, Message):
return
if message.message:
if message.raw_text[0] in self._db.get("friendly-telegram.modules.corectrl", "command_prefix", ".") or message.fwd_from:
return
if self._db.get("OneMessage", "status", None) and message.sender_id == self._db.get("OneMessage", "my_id", None) and not message.media:
last_msg = (await self.client.get_messages(message.to_id, limit=2))[-1]
if last_msg.sender_id == message.sender_id and not last_msg.fwd_from:
text = last_msg.text
text += "\n"*2
text += message.text
if message.is_reply:
message, last_msg = last_msg, message
try:
await last_msg.edit(text)
await message.delete()
except:
return
from .. import loader, utils
from telethon.tl.types import Message
class OneMessageMod(loader.Module):
"""@faq lines"""
strings = {'name': 'OneMessage'}
def __init__(self):
self.name = self.strings['name']
async def client_ready(self, client, db):
self.client = client
self._db = db
@loader.sudo
async def omstartcmd(self, message):
"""Start OneMessage mode"""
self._db.set("OneMessage", "status", True)
self._db.set("OneMessage", "my_id", message.sender_id)
await message.edit("<b>OneMessage mode activated!</b>")
async def omstopcmd(self, message):
"""Stop OneMessage mode"""
self._db.set("OneMessage", "status", False)
await message.edit("<b>OneMessage mode diactivated!</b>")
async def watcher(self, message):
if not isinstance(message, Message):
return
if message.message:
if message.raw_text[0] in self._db.get("friendly-telegram.modules.corectrl", "command_prefix", ".") or message.fwd_from:
return
if self._db.get("OneMessage", "status", None) and message.sender_id == self._db.get("OneMessage", "my_id", None) and not message.media:
last_msg = (await self.client.get_messages(message.to_id, limit=2))[-1]
if last_msg.sender_id == message.sender_id and not last_msg.fwd_from:
text = last_msg.text
text += "\n"*2
text += message.text
if message.is_reply:
message, last_msg = last_msg, message
try:
await last_msg.edit(text)
await message.delete()
except:
return

View File

@@ -1,224 +1,224 @@
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
@borg.on(admin_cmd(pattern=".new ?(.*)", allow_sudo=True))
async def pilnew(event):
uinp = event.pattern_match.group(1)
if not uinp:
get = await event.get_reply_message()
if not get:
await event.delete()
return
uinp = get.text
uinp = uinp.split(" ", 2)
try:
x = int(uinp[0])
y = int(uinp[1])
except ValueError:
await event.edit("ERROR INPUT=> X or Y is not int")
return
if "(" in uinp[2] and ")" in uinp[2]:
color = uinp[2].replace("(","").replace(")","").split(", ")
try:
a = 255
r = int(color[0])
g = int(color[1])
b = int(color[2])
if len(color) == 4:
a = int(color[3])
except ValueError:
await event.edit("ERROR INPUT=> R or G or B is not int")
return
color = (r, g, b, a)
else:
color = uinp[2]
try:
image = Image.new("RGBA", (x, y), color)
except Exception as e:
await event.edit("ERROR IN DRAW\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilnew.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".rotate ?(.*)", allow_sudo=True))
async def pilrotate(event):
try:
angle = int(event.pattern_match.group(1))
except ValueError:
await event.edit("ERROR INPUT=> ANGLE")
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't rotate that!".upper())
return
else:
await event.edit("Reply to an image or sticker to rotate it!".upper())
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
try:
image = image.rotate(angle, expand=True)
except Exception as e:
await event.edit("ERROR IN ROTATE\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilrotate.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".ops ?(.*)", allow_sudo=True))
async def pilops(event):
way = event.pattern_match.group(1)
if not way:
return
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't ops that!".upper())
return
else:
await event.edit("Reply to an image or sticker to ops it!".upper())
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
if "m" in way:
try:
image = ImageOps.mirror(image)
except Exception as e:
await event.edit("ERROR IN MIRROR\n"+str(e))
return
if "f" in way:
try:
image = ImageOps.flip(image)
except Exception as e:
await event.edit("ERROR IN FLIP\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilops.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".resize ?(.*)", allow_sudo=True))
async def pilrotate(event):
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't resize that!".upper())
return
else:
await event.edit("Reply to an image or sticker to resize it!".upper())
return
uinp = event.pattern_match.group(1)
if not uinp:
await event.edit("What's about input".upper())
return
uinp = uinp.split()
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
x, y = image.size
rx, ry = None, None
if len(uinp) == 1:
try:
rx, ry = int(uinp[0]), int(uinp[0])
except ValueError:
if uinp[0] == "x":
rx, ry = x, x
if uinp[0] == "y":
rx, ry = y, y
else:
await event.edit("INPUT MUST BE STING")
return
else:
if uinp[0] == "x":
rx = x
if uinp[0] == "y":
rx = y
if uinp[1] == "x":
ry = x
if uinp[1] == "y":
ry = y
if not rx:
try:
rx = int(uinp[0])
except:
await event.edit("ERROR IN INPUT")
return
if not ry:
try:
ry = int(uinp[1])
except:
await event.edit("ERROR IN INPUT")
return
try:
image = image.resize((rx, ry))
except Exception as e:
await event.edit("ERROR IN RESIZE\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilresize.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
@borg.on(admin_cmd(pattern=".new ?(.*)", allow_sudo=True))
async def pilnew(event):
uinp = event.pattern_match.group(1)
if not uinp:
get = await event.get_reply_message()
if not get:
await event.delete()
return
uinp = get.text
uinp = uinp.split(" ", 2)
try:
x = int(uinp[0])
y = int(uinp[1])
except ValueError:
await event.edit("ERROR INPUT=> X or Y is not int")
return
if "(" in uinp[2] and ")" in uinp[2]:
color = uinp[2].replace("(","").replace(")","").split(", ")
try:
a = 255
r = int(color[0])
g = int(color[1])
b = int(color[2])
if len(color) == 4:
a = int(color[3])
except ValueError:
await event.edit("ERROR INPUT=> R or G or B is not int")
return
color = (r, g, b, a)
else:
color = uinp[2]
try:
image = Image.new("RGBA", (x, y), color)
except Exception as e:
await event.edit("ERROR IN DRAW\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilnew.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".rotate ?(.*)", allow_sudo=True))
async def pilrotate(event):
try:
angle = int(event.pattern_match.group(1))
except ValueError:
await event.edit("ERROR INPUT=> ANGLE")
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't rotate that!".upper())
return
else:
await event.edit("Reply to an image or sticker to rotate it!".upper())
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
try:
image = image.rotate(angle, expand=True)
except Exception as e:
await event.edit("ERROR IN ROTATE\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilrotate.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".ops ?(.*)", allow_sudo=True))
async def pilops(event):
way = event.pattern_match.group(1)
if not way:
return
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't ops that!".upper())
return
else:
await event.edit("Reply to an image or sticker to ops it!".upper())
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
if "m" in way:
try:
image = ImageOps.mirror(image)
except Exception as e:
await event.edit("ERROR IN MIRROR\n"+str(e))
return
if "f" in way:
try:
image = ImageOps.flip(image)
except Exception as e:
await event.edit("ERROR IN FLIP\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilops.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
@borg.on(admin_cmd(pattern=".resize ?(.*)", allow_sudo=True))
async def pilrotate(event):
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.edit("`I can't resize that!".upper())
return
else:
await event.edit("Reply to an image or sticker to resize it!".upper())
return
uinp = event.pattern_match.group(1)
if not uinp:
await event.edit("What's about input".upper())
return
uinp = uinp.split()
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
x, y = image.size
rx, ry = None, None
if len(uinp) == 1:
try:
rx, ry = int(uinp[0]), int(uinp[0])
except ValueError:
if uinp[0] == "x":
rx, ry = x, x
if uinp[0] == "y":
rx, ry = y, y
else:
await event.edit("INPUT MUST BE STING")
return
else:
if uinp[0] == "x":
rx = x
if uinp[0] == "y":
rx = y
if uinp[1] == "x":
ry = x
if uinp[1] == "y":
ry = y
if not rx:
try:
rx = int(uinp[0])
except:
await event.edit("ERROR IN INPUT")
return
if not ry:
try:
ry = int(uinp[1])
except:
await event.edit("ERROR IN INPUT")
return
try:
image = image.resize((rx, ry))
except Exception as e:
await event.edit("ERROR IN RESIZE\n"+str(e))
return
await event.delete()
image_stream = io.BytesIO()
image_stream.name = "pilresize.png"
image.save(image_stream, "PNG")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,80 +1,80 @@
from .. import loader, utils
from telethon.tl.types import DocumentAttributeFilename
from requests import get, post
from PIL import Image
from io import BytesIO
@loader.tds
class QRtoolsMod(loader.Module):
"""Generator and reader of QR codes"""
strings = {"name": "QR tool's"}
@loader.owner
async def makeqrcmd(self, message):
""".makeqr <text or reply>"""
text = utils.get_args_raw(message)
reply = await message.get_reply_message()
file = False
if not text or text.lower() == ".file":
if text and text == ".file":
file = True
if not reply or not reply.message:
await message.edit("<b>Нет текста для кодирования!</b>")
return
text = reply.raw_text
else:
if text.startswith(".file"):
file = True
text = text[5:].strip()
url = "https://api.qrserver.com/v1/create-qr-code/?data={}&size=512x512&charset-source=UTF-8&charset-target=UTF-8&ecc=L&color=0-0-0&bgcolor=255-255-255&margin=1&qzone=1&format=png"
r = get(url.format(text), stream=True)
qrcode = BytesIO()
qrcode.name = "qr.png" if file else "qr.webp"
Image.open(BytesIO(r.content)).save(qrcode)
qrcode.seek(0)
await message.delete()
await message.client.send_file(message.to_id, qrcode, reply_to=reply, force_document=file)
@loader.owner
async def readqrcmd(self, message):
""".readqr <qrcode or reply to qrcode>"""
ok = await check(message)
if not ok:
reply = await message.get_reply_message()
ok = await check(reply)
if not ok:
text = "<b>Это не изображение!</b>" if reply else "<b>Нечего не передано!</b>"
await message.edit(text)
return
file = BytesIO()
file.name = "qr.png"
data = await message.client.download_file(ok)
Image.open(BytesIO(data)).save(file)
url = "https://api.qrserver.com/v1/read-qr-code/?outputformat=json"
resp = post(url, files={"file": file.getvalue()})
text = resp.json()[0]["symbol"][0]["data"]
if not text:
text = "<b>Невозможно распознать или QR пуст!<b>"
await utils.answer(message, text)
async def check(msg):
if msg and msg.media:
if msg.photo:
ok = msg.photo
elif msg.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in msg.media.document.attributes:
return False
if msg.gif or msg.video or msg.audio or msg.voice:
return False
ok = msg.media.document
else:
return False
else:
return False
if not ok or ok is None:
return False
else:
return ok
from .. import loader, utils
from telethon.tl.types import DocumentAttributeFilename
from requests import get, post
from PIL import Image
from io import BytesIO
@loader.tds
class QRtoolsMod(loader.Module):
"""Generator and reader of QR codes"""
strings = {"name": "QR tool's"}
@loader.owner
async def makeqrcmd(self, message):
""".makeqr <text or reply>"""
text = utils.get_args_raw(message)
reply = await message.get_reply_message()
file = False
if not text or text.lower() == ".file":
if text and text == ".file":
file = True
if not reply or not reply.message:
await message.edit("<b>Нет текста для кодирования!</b>")
return
text = reply.raw_text
else:
if text.startswith(".file"):
file = True
text = text[5:].strip()
url = "https://api.qrserver.com/v1/create-qr-code/?data={}&size=512x512&charset-source=UTF-8&charset-target=UTF-8&ecc=L&color=0-0-0&bgcolor=255-255-255&margin=1&qzone=1&format=png"
r = get(url.format(text), stream=True)
qrcode = BytesIO()
qrcode.name = "qr.png" if file else "qr.webp"
Image.open(BytesIO(r.content)).save(qrcode)
qrcode.seek(0)
await message.delete()
await message.client.send_file(message.to_id, qrcode, reply_to=reply, force_document=file)
@loader.owner
async def readqrcmd(self, message):
""".readqr <qrcode or reply to qrcode>"""
ok = await check(message)
if not ok:
reply = await message.get_reply_message()
ok = await check(reply)
if not ok:
text = "<b>Это не изображение!</b>" if reply else "<b>Нечего не передано!</b>"
await message.edit(text)
return
file = BytesIO()
file.name = "qr.png"
data = await message.client.download_file(ok)
Image.open(BytesIO(data)).save(file)
url = "https://api.qrserver.com/v1/read-qr-code/?outputformat=json"
resp = post(url, files={"file": file.getvalue()})
text = resp.json()[0]["symbol"][0]["data"]
if not text:
text = "<b>Невозможно распознать или QR пуст!<b>"
await utils.answer(message, text)
async def check(msg):
if msg and msg.media:
if msg.photo:
ok = msg.photo
elif msg.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in msg.media.document.attributes:
return False
if msg.gif or msg.video or msg.audio or msg.voice:
return False
ok = msg.media.document
else:
return False
else:
return False
if not ok or ok is None:
return False
else:
return ok

View File

@@ -1,33 +1,33 @@
from PIL import Image, ImageFilter
import io
from .. import loader, utils
@loader.tds
class SquareBlurMod(loader.Module):
"""Make image 1:1 ratio"""
strings = {"name": "SquareBlur"}
@loader.unrestricted
async def squareblurcmd(self, message):
"""make image 1:1 ratio"""
reply = await message.get_reply_message()
if not reply or not reply.file or not reply.file.mime_type.split("/")[0].lower() == "image":
await message.edit("<b>Reply to image!</b>")
return
im = io.BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
if w == h:
await message.edit("<b>Ты за меня придурка не держи!</b>")
return
_min, _max = min(w, h), max(w, h)
bg = im.crop(((w-_min)//2, (h-_min)//2, (w+_min)//2, (h+_min)//2))
bg = bg.filter(ImageFilter.GaussianBlur(5))
bg = bg.resize((_max, _max))
bg.paste(im, ((_max-w)//2, (_max-h)//2))
img = io.BytesIO()
img.name = "im.png"
bg.save(img)
img.seek(0)
await reply.reply(file=img)
await message.delete()
from PIL import Image, ImageFilter
import io
from .. import loader, utils
@loader.tds
class SquareBlurMod(loader.Module):
"""Make image 1:1 ratio"""
strings = {"name": "SquareBlur"}
@loader.unrestricted
async def squareblurcmd(self, message):
"""make image 1:1 ratio"""
reply = await message.get_reply_message()
if not reply or not reply.file or not reply.file.mime_type.split("/")[0].lower() == "image":
await message.edit("<b>Reply to image!</b>")
return
im = io.BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
if w == h:
await message.edit("<b>Ты за меня придурка не держи!</b>")
return
_min, _max = min(w, h), max(w, h)
bg = im.crop(((w-_min)//2, (h-_min)//2, (w+_min)//2, (h+_min)//2))
bg = bg.filter(ImageFilter.GaussianBlur(5))
bg = bg.resize((_max, _max))
bg.paste(im, ((_max-w)//2, (_max-h)//2))
img = io.BytesIO()
img.name = "im.png"
bg.save(img)
img.seek(0)
await reply.reply(file=img)
await message.delete()

View File

@@ -1,58 +1,58 @@
from .. import loader, utils
import io
from PIL import Image
from string import hexdigits
def register(cb):
cb(StickToolsMod())
class StickToolsMod(loader.Module):
""""""
strings = {'name': 'StickTools'}
def __init__(self):
self.name = self.strings['name']
async def stick2piccmd(self, message):
"""reply to Sticker\nsend stricker as image"""
await convert(message, False)
async def stick2filecmd(self, message):
"""reply to Sticker\nsend stricker as image"""
await convert(message, True)
async def convert(message, as_file):
reply = await message.get_reply_message()
if not reply or not reply.sticker:
await message.edit("<b>Reply to sticker!</b>")
return
fname = reply.sticker.attributes[-1].file_name
if ".tgs" in fname:
await message.edit("<b>Reply to not animated sticker!</b>")
return
bg = (0,0,0,0)
args = utils.get_args(message)
if args:
args = args[0]
if args.startswith("#"):
for ch in args[1:]:
if ch not in hexdigits:
break
bg = args
im = io.BytesIO()
await message.client.download_file(reply, im)
im = Image.open(im)
img = Image.new("RGBA", im.size, bg)
if im.mode == "RGBA":
img.paste(im, (0,0), im)
else:
img.paste(im, (0,0))
out = io.BytesIO()
out.name = fname+".png"
img.save(out, "PNG")
out.seek(0)
await message.delete()
await message.client.send_file(message.to_id, out, force_document=as_file, reply_to=reply)
from .. import loader, utils
import io
from PIL import Image
from string import hexdigits
def register(cb):
cb(StickToolsMod())
class StickToolsMod(loader.Module):
""""""
strings = {'name': 'StickTools'}
def __init__(self):
self.name = self.strings['name']
async def stick2piccmd(self, message):
"""reply to Sticker\nsend stricker as image"""
await convert(message, False)
async def stick2filecmd(self, message):
"""reply to Sticker\nsend stricker as image"""
await convert(message, True)
async def convert(message, as_file):
reply = await message.get_reply_message()
if not reply or not reply.sticker:
await message.edit("<b>Reply to sticker!</b>")
return
fname = reply.sticker.attributes[-1].file_name
if ".tgs" in fname:
await message.edit("<b>Reply to not animated sticker!</b>")
return
bg = (0,0,0,0)
args = utils.get_args(message)
if args:
args = args[0]
if args.startswith("#"):
for ch in args[1:]:
if ch not in hexdigits:
break
bg = args
im = io.BytesIO()
await message.client.download_file(reply, im)
im = Image.open(im)
img = Image.new("RGBA", im.size, bg)
if im.mode == "RGBA":
img.paste(im, (0,0), im)
else:
img.paste(im, (0,0))
out = io.BytesIO()
out.name = fname+".png"
img.save(out, "PNG")
out.seek(0)
await message.delete()
await message.client.send_file(message.to_id, out, force_document=as_file, reply_to=reply)

File diff suppressed because one or more lines are too long

View File

@@ -1,174 +1,174 @@
from .. import loader, utils
import logging
from PIL import Image, ImageDraw, ImageOps, ImageFont
from textwrap import wrap
import io
import requests
# https://t.me/KeyZenD
# https://t.me/SomeScripts
logger = logging.getLogger(__name__)
@loader.tds
class DeMoTiVaToRsMod(loader.Module):
"""Демотиваторы на картинки от @SomeScripts by @DneZyeK"""
strings = {
"name": "SuperDemotivator"
}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def demoticmd(self, message):
"""текст + фото или ответ на фото
не мнёт фотки"""
await cmds(message, 0)
async def demotcmd(self, message):
"""текст + фото или ответ на фото
мнёт фотки"""
await cmds(message, 1)
async def cmds(message, type):
event, is_reply = await check_media(message)
if not event:
await message.edit("<b>Ответ командой на картинку!</b>")
return
text = utils.get_args_raw(message)
if not text:
await message.edit("<b>Команду нужно использовать с текстом!</b>")
return
await message.edit("<b>Демотивирую...</b>")
bytes_image = await event.download_media(bytes)
demotivator = await demotion(font_bytes, bytes_image, text, type)
if is_reply:
a = await event.reply(file=demotivator)
await message.delete()
return a
else:
return await event.edit(file=demotivator, text="")
async def check_media(message):
reply = await message.get_reply_message()
is_reply = True
if not reply:
reply = message
is_reply = False
if not reply.file:
return False, ...
mime = reply.file.mime_type.split("/")[0].lower()
if mime != "image":
return False, ...
return reply, is_reply
async def textwrap(text, length=50, splitter = "\n\n"):
out = []
lines = text.rsplit(splitter, 1)
for text in lines:
txt = []
parts = text.split("\n")
for part in parts:
part = "\n".join(wrap(part, length))
txt.append(part)
text = "\n".join(txt)
out.append(text)
return out
async def draw_main(
bytes_image,
type,
frame_width_1 = 5,
frame_fill_1 = (0, 0, 0),
frame_width_2 = 3,
frame_fill_2 = (255, 255, 255),
expand_proc = 10,
main_fill = (0, 0, 0)
):
main_ = Image.open(io.BytesIO(bytes_image))
main = Image.new("RGB", main_.size, "black")
main.paste(main_, (0, 0))
if type == 1:
main = main.resize((700, 550))
main = ImageOps.expand(main, frame_width_1, frame_fill_1)
main = ImageOps.expand(main, frame_width_2, frame_fill_2)
w, h = main.size
h_up = expand_proc*(h//100)
im = Image.new("RGB", (w+(h_up*2), h+h_up), main_fill)
im.paste(main, (h_up, h_up))
return im
async def _draw_text(
text,
font_bytes,
font_size,
font_add = 20,
main_fill = (0, 0, 0),
text_fill = (255, 255, 255),
text_align = "center"
):
font = ImageFont.truetype(io.BytesIO(font_bytes), font_size)
w_txt, h_txt = ImageDraw.Draw(Image.new("RGB", (1, 1))).multiline_textsize(text=text, font=font)
txt = Image.new("RGB", (w_txt, h_txt+font_add), main_fill)
ImageDraw.Draw(txt).text((0, 0), text=text, font=font, fill=text_fill, align=text_align)
return txt
async def text_joiner(text_img_1, text_img_2, main_fill = (0, 0, 0)):
w_txt_1, h_txt_1 = text_img_1.size
w_txt_2, h_txt_2 = text_img_2.size
w = max(w_txt_1, w_txt_2)
h = h_txt_1 + h_txt_2
text = Image.new("RGB", (w, h), main_fill)
text.paste(text_img_1, ((w-w_txt_1)//2, 0))
text.paste(text_img_2, ((w-w_txt_2)//2, h_txt_1))
return text
async def draw_text(text, font_bytes, font_size):
text = await textwrap(text)
if len(text) == 1:
text = await _draw_text(text[0], font_bytes, font_size[0] )
else:
text_img_1 = await _draw_text(text[ 0], font_bytes, font_size[0])
text_img_2 = await _draw_text(text[-1], font_bytes, font_size[1])
text = await text_joiner(text_img_1, text_img_2)
return text
async def text_finaller(text, main, expand_width_proc = 25, main_fill = (0, 0, 0)):
x = min(main.size)
w_txt, h_txt = text.size
w_proc = expand_width_proc*(w_txt//100)
h_proc = expand_width_proc*(h_txt//100)
back = Image.new("RGB", (w_txt+(w_proc*2), h_txt+(h_proc*2)), main_fill)
back.paste(text, (w_proc, h_proc))
back.thumbnail((x, x))
return back
async def joiner(text_img, main_img, format_save="JPEG"):
w_im, h_im = main_img.size
w_txt, h_txt = text_img.size
text_img.thumbnail((min(w_im, h_im), min(w_im, h_im)))
w_txt, h_txt = text_img.size
main_img = main_img.crop((0, 0, w_im, h_im+h_txt))
main_img.paste(text_img, ((w_im-w_txt)//2, h_im))
output = io.BytesIO()
main_img.save(output, format_save)
output.seek(0)
return output.getvalue()
async def demotion(font_bytes, bytes_image, text, type):
main = await draw_main(bytes_image, type)
font_size = [20*(min(main.size)//100), 15*(min(main.size)//100)]
text = await draw_text(text, font_bytes, font_size)
text = await text_finaller(text, main)
output = await joiner(text, main)
return output
font_bytes = requests.get("https://raw.githubusercontent.com/KeyZenD/l/master/times.ttf").content
#######################
from .. import loader, utils
import logging
from PIL import Image, ImageDraw, ImageOps, ImageFont
from textwrap import wrap
import io
import requests
# https://t.me/KeyZenD
# https://t.me/SomeScripts
logger = logging.getLogger(__name__)
@loader.tds
class DeMoTiVaToRsMod(loader.Module):
"""Демотиваторы на картинки от @SomeScripts by @DneZyeK"""
strings = {
"name": "SuperDemotivator"
}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def demoticmd(self, message):
"""текст + фото или ответ на фото
не мнёт фотки"""
await cmds(message, 0)
async def demotcmd(self, message):
"""текст + фото или ответ на фото
мнёт фотки"""
await cmds(message, 1)
async def cmds(message, type):
event, is_reply = await check_media(message)
if not event:
await message.edit("<b>Ответ командой на картинку!</b>")
return
text = utils.get_args_raw(message)
if not text:
await message.edit("<b>Команду нужно использовать с текстом!</b>")
return
await message.edit("<b>Демотивирую...</b>")
bytes_image = await event.download_media(bytes)
demotivator = await demotion(font_bytes, bytes_image, text, type)
if is_reply:
a = await event.reply(file=demotivator)
await message.delete()
return a
else:
return await event.edit(file=demotivator, text="")
async def check_media(message):
reply = await message.get_reply_message()
is_reply = True
if not reply:
reply = message
is_reply = False
if not reply.file:
return False, ...
mime = reply.file.mime_type.split("/")[0].lower()
if mime != "image":
return False, ...
return reply, is_reply
async def textwrap(text, length=50, splitter = "\n\n"):
out = []
lines = text.rsplit(splitter, 1)
for text in lines:
txt = []
parts = text.split("\n")
for part in parts:
part = "\n".join(wrap(part, length))
txt.append(part)
text = "\n".join(txt)
out.append(text)
return out
async def draw_main(
bytes_image,
type,
frame_width_1 = 5,
frame_fill_1 = (0, 0, 0),
frame_width_2 = 3,
frame_fill_2 = (255, 255, 255),
expand_proc = 10,
main_fill = (0, 0, 0)
):
main_ = Image.open(io.BytesIO(bytes_image))
main = Image.new("RGB", main_.size, "black")
main.paste(main_, (0, 0))
if type == 1:
main = main.resize((700, 550))
main = ImageOps.expand(main, frame_width_1, frame_fill_1)
main = ImageOps.expand(main, frame_width_2, frame_fill_2)
w, h = main.size
h_up = expand_proc*(h//100)
im = Image.new("RGB", (w+(h_up*2), h+h_up), main_fill)
im.paste(main, (h_up, h_up))
return im
async def _draw_text(
text,
font_bytes,
font_size,
font_add = 20,
main_fill = (0, 0, 0),
text_fill = (255, 255, 255),
text_align = "center"
):
font = ImageFont.truetype(io.BytesIO(font_bytes), font_size)
w_txt, h_txt = ImageDraw.Draw(Image.new("RGB", (1, 1))).multiline_textsize(text=text, font=font)
txt = Image.new("RGB", (w_txt, h_txt+font_add), main_fill)
ImageDraw.Draw(txt).text((0, 0), text=text, font=font, fill=text_fill, align=text_align)
return txt
async def text_joiner(text_img_1, text_img_2, main_fill = (0, 0, 0)):
w_txt_1, h_txt_1 = text_img_1.size
w_txt_2, h_txt_2 = text_img_2.size
w = max(w_txt_1, w_txt_2)
h = h_txt_1 + h_txt_2
text = Image.new("RGB", (w, h), main_fill)
text.paste(text_img_1, ((w-w_txt_1)//2, 0))
text.paste(text_img_2, ((w-w_txt_2)//2, h_txt_1))
return text
async def draw_text(text, font_bytes, font_size):
text = await textwrap(text)
if len(text) == 1:
text = await _draw_text(text[0], font_bytes, font_size[0] )
else:
text_img_1 = await _draw_text(text[ 0], font_bytes, font_size[0])
text_img_2 = await _draw_text(text[-1], font_bytes, font_size[1])
text = await text_joiner(text_img_1, text_img_2)
return text
async def text_finaller(text, main, expand_width_proc = 25, main_fill = (0, 0, 0)):
x = min(main.size)
w_txt, h_txt = text.size
w_proc = expand_width_proc*(w_txt//100)
h_proc = expand_width_proc*(h_txt//100)
back = Image.new("RGB", (w_txt+(w_proc*2), h_txt+(h_proc*2)), main_fill)
back.paste(text, (w_proc, h_proc))
back.thumbnail((x, x))
return back
async def joiner(text_img, main_img, format_save="JPEG"):
w_im, h_im = main_img.size
w_txt, h_txt = text_img.size
text_img.thumbnail((min(w_im, h_im), min(w_im, h_im)))
w_txt, h_txt = text_img.size
main_img = main_img.crop((0, 0, w_im, h_im+h_txt))
main_img.paste(text_img, ((w_im-w_txt)//2, h_im))
output = io.BytesIO()
main_img.save(output, format_save)
output.seek(0)
return output.getvalue()
async def demotion(font_bytes, bytes_image, text, type):
main = await draw_main(bytes_image, type)
font_size = [20*(min(main.size)//100), 15*(min(main.size)//100)]
text = await draw_text(text, font_bytes, font_size)
text = await text_finaller(text, main)
output = await joiner(text, main)
return output
font_bytes = requests.get("https://raw.githubusercontent.com/KeyZenD/l/master/times.ttf").content
#######################

View File

@@ -1,110 +1,110 @@
from .. import loader, utils
import logging
from PIL import Image, ImageOps
import io
logger = logging.getLogger(__name__)
@loader.tds
class SwiperMod(loader.Module):
"""Swiper"""
strings = {
"name": "Swiper"
}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def sl2rcmd(self, message):
"""swipe left to right"""
await presser(message, 0)
@loader.owner
async def sr2lcmd(self, message):
"""swipe right to left"""
await presser(message, 1)
@loader.owner
async def su2dcmd(self, message):
"""swipe up to down"""
await presser(message, 2)
@loader.owner
async def sd2ucmd(self, message):
"""swipe down to up"""
await presser(message, 3)
async def check_media(message):
reply = await message.get_reply_message()
if not reply:
return False
if not reply.file:
return False
mime = reply.file.mime_type.split("/")[0].lower()
if mime != "image":
return False
return reply
async def presser(message, way):
reply = await check_media(message)
if not reply:
await message.edit("<b>Senpai... please reply to image or not animated sticker!</b>")
return
im = io.BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
out = []
await message.edit("<b>Working hard...</b>")
if way == 0:
for x in range(1, w, w//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = im1.resize((x, h))
im2 = im2.resize((w-x, h))
temp.paste(im1, (0, 0))
temp.paste(im2, (x, 0))
out.append(temp)
if way == 1:
for x in range(1, w, w//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = ImageOps.mirror(im1.resize((x, h)))
im2 = ImageOps.mirror(im2.resize((w-x, h)))
temp.paste(im1, (0, 0))
temp.paste(im2, (x, 0))
temp = ImageOps.mirror(temp)
out.append(temp)
if way == 2:
for y in range(1, h, h//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = im1.resize((w, y))
im2 = im2.resize((w, h-y))
temp.paste(im1, (0, 0))
temp.paste(im2, (0, y))
out.append(temp)
if way == 3:
for y in range(1, h, h//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = ImageOps.flip(im1.resize((w, y)))
im2 = ImageOps.flip(im2.resize((w, h-y)))
temp.paste(im1, (0, 0))
temp.paste(im2, (0, y))
temp = ImageOps.flip(temp)
out.append(temp)
output = io.BytesIO()
output.name = "output.gif"
out[0].save(output, save_all=True, append_images=out[1:], duration=1)
output.seek(0)
await reply.reply(file=output)
await message.delete()
from .. import loader, utils
import logging
from PIL import Image, ImageOps
import io
logger = logging.getLogger(__name__)
@loader.tds
class SwiperMod(loader.Module):
"""Swiper"""
strings = {
"name": "Swiper"
}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def sl2rcmd(self, message):
"""swipe left to right"""
await presser(message, 0)
@loader.owner
async def sr2lcmd(self, message):
"""swipe right to left"""
await presser(message, 1)
@loader.owner
async def su2dcmd(self, message):
"""swipe up to down"""
await presser(message, 2)
@loader.owner
async def sd2ucmd(self, message):
"""swipe down to up"""
await presser(message, 3)
async def check_media(message):
reply = await message.get_reply_message()
if not reply:
return False
if not reply.file:
return False
mime = reply.file.mime_type.split("/")[0].lower()
if mime != "image":
return False
return reply
async def presser(message, way):
reply = await check_media(message)
if not reply:
await message.edit("<b>Senpai... please reply to image or not animated sticker!</b>")
return
im = io.BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
out = []
await message.edit("<b>Working hard...</b>")
if way == 0:
for x in range(1, w, w//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = im1.resize((x, h))
im2 = im2.resize((w-x, h))
temp.paste(im1, (0, 0))
temp.paste(im2, (x, 0))
out.append(temp)
if way == 1:
for x in range(1, w, w//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = ImageOps.mirror(im1.resize((x, h)))
im2 = ImageOps.mirror(im2.resize((w-x, h)))
temp.paste(im1, (0, 0))
temp.paste(im2, (x, 0))
temp = ImageOps.mirror(temp)
out.append(temp)
if way == 2:
for y in range(1, h, h//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = im1.resize((w, y))
im2 = im2.resize((w, h-y))
temp.paste(im1, (0, 0))
temp.paste(im2, (0, y))
out.append(temp)
if way == 3:
for y in range(1, h, h//30):
im1 = im2 = im.copy()
temp = Image.new("RGB", (w, h))
im1 = ImageOps.flip(im1.resize((w, y)))
im2 = ImageOps.flip(im2.resize((w, h-y)))
temp.paste(im1, (0, 0))
temp.paste(im2, (0, y))
temp = ImageOps.flip(temp)
out.append(temp)
output = io.BytesIO()
output.name = "output.gif"
out[0].save(output, save_all=True, append_images=out[1:], duration=1)
output.seek(0)
await reply.reply(file=output)
await message.delete()

View File

@@ -1,66 +1,66 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 @DneZyeK | sub to @KeyZenD
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from .. import loader, utils
import telethon
logger = logging.getLogger(__name__)
async def register(cb):
cb(KeyboardSwitcherMod())
@loader.tds
class KeyboardSwitcherMod(loader.Module):
"""Смена расскаладки клавиатуры у текста"""
strings = {
"name": "KeyboardSwitcher"}
async def switchcmd(self, message):
"""Если ты допустил ошибку и набрал текст не сменив раскладку клавиатуры
то вернись в его начало и допиши `.switch` и твой текст станет читабельным.
Если ты всё же отправил сообщение не в той расскладке, то просто ответь на него этой командой и он измениться.
если же твой собеседник допустил ошибку, то просто ответь на его сообщение и сообщение с командой измениться."""
RuKeys = """ёйцукенгшщзхъфывапролджэячсмитьбю.Ё"№;%:?ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭ/ЯЧСМИТЬБЮ,"""
EnKeys = """`qwertyuiop[]asdfghjkl;'zxcvbnm,./~@#$%^&QWERTYUIOP{}ASDFGHJKL:"|ZXCVBNM<>?"""
if message.is_reply:
reply = await message.get_reply_message()
text = reply.raw_text
if not text:
await message.edit('Тут текста нету...')
return
change = str.maketrans(RuKeys + EnKeys, EnKeys + RuKeys)
text = str.translate(text, change)
if message.sender_id != reply.sender_id:
await message.edit(text)
else:
await message.delete()
await reply.edit(text)
else:
text = utils.get_args_raw(message)
if not text:
await message.edit('Тут текста нету...')
return
change = str.maketrans(RuKeys + EnKeys, EnKeys + RuKeys)
text = str.translate(text, change)
await message.edit(text)
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 @DneZyeK | sub to @KeyZenD
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from .. import loader, utils
import telethon
logger = logging.getLogger(__name__)
async def register(cb):
cb(KeyboardSwitcherMod())
@loader.tds
class KeyboardSwitcherMod(loader.Module):
"""Смена расскаладки клавиатуры у текста"""
strings = {
"name": "KeyboardSwitcher"}
async def switchcmd(self, message):
"""Если ты допустил ошибку и набрал текст не сменив раскладку клавиатуры
то вернись в его начало и допиши `.switch` и твой текст станет читабельным.
Если ты всё же отправил сообщение не в той расскладке, то просто ответь на него этой командой и он измениться.
если же твой собеседник допустил ошибку, то просто ответь на его сообщение и сообщение с командой измениться."""
RuKeys = """ёйцукенгшщзхъфывапролджэячсмитьбю.Ё"№;%:?ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭ/ЯЧСМИТЬБЮ,"""
EnKeys = """`qwertyuiop[]asdfghjkl;'zxcvbnm,./~@#$%^&QWERTYUIOP{}ASDFGHJKL:"|ZXCVBNM<>?"""
if message.is_reply:
reply = await message.get_reply_message()
text = reply.raw_text
if not text:
await message.edit('Тут текста нету...')
return
change = str.maketrans(RuKeys + EnKeys, EnKeys + RuKeys)
text = str.translate(text, change)
if message.sender_id != reply.sender_id:
await message.edit(text)
else:
await message.delete()
await reply.edit(text)
else:
text = utils.get_args_raw(message)
if not text:
await message.edit('Тут текста нету...')
return
change = str.maketrans(RuKeys + EnKeys, EnKeys + RuKeys)
text = str.translate(text, change)
await message.edit(text)

View File

@@ -0,0 +1,11 @@
# Python code obfuscated by www.development-tools.net
import base64, codecs
magic = 'aW1wb3J0IGFzeW5jaW8NCmltcG9ydCBsb2dnaW5nDQpmcm9tIC4uIGltcG9ydCBsb2FkZXIsIHV0aWxzDQoNCmxvZ2dlciA9IGxvZ2dpbmcuZ2V0TG9nZ2VyKF9fbmFtZV9fKQ0KDQpAbG9hZGVyLnRkcw0KY2xhc3MgVmlkZW9EaXN0b3J0aW9ydE1vZChsb2FkZXIuTW9kdWxlKToNCgkiIiLQltC80YvRhSDQtNC70Y8g0LLQuNC00LXQviIiIg0KCXN0cmluZ3MgPSB7Im5hbWUiOiAiVmlkZW9EaXN0b3J0aW9uIn0NCg0KCUBsb2FkZXIudW5yZXN0cmljdGVkDQoJYXN5bmMgZGVmIHZkaXN0b3J0Y21kKHNlbGYsIG1lc3NhZ2UpOg0KCQkiIiIudmRpc3RvcnQgPHJlcGx5IHRvIHZpZGVvPiIiIg0KCQlhd2FpdCBtZXNzYWdlLmVkaXQoIjxiPtCX0LDQs9GA0YPQttCw0Y4g0LLQuNC00LXQvi4uLjwvYj4iKQ0KCQlhd2FpdCBhc3luY2lvLnNsZWVwKDUpDQoJCWF3YWl0IG1lc3NhZ2UuZWRpdCgiPGI+0JTQvtGB0YLQsNGOINC60LDQtNGA0YsuLi48L2'
love = 'V+VvxAPtxWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPH0YKDh9Pj0L4t0YoDiATY0LHhYv48Y2V+VvxAPtxWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPu0Y7DfqP40LQDfATBVAP60YQDgATN0LfhYv48Y2V+VvxAPtxWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPr0LYDi9TN0YQDfgP70L/EwvQDfgP40YGDgqP+Yv4hCP9vCvVcQDbWPJS3LJy0VTSmrJ5wnJ8hp2kyMKNbAFxAPtxWLKqunKDtoJImp2SaMF5woTyyoaDhp2IhMS9znJkyXT1yp3AuM2HhL2uuqPjtVzu0qUN6Yl94rJI0LF5goP9zY05yqzIlE29hozSUnKMyJJ91IKNhoKN0VvjtL2SjqTyiow0vCTV+GzI2MKVtE29hozRtE2y2MFOMo3HtIKNuCP9vCvVcQDbWPJS3LJy0VT1yp3AuM2HhMJEcqPtvJJ91VUquplOlnJAepz9foTIxVFVcQDbWPD0XVvVv'
god = 'DQppbXBvcnQgYXN5bmNpbw0KaW1wb3J0IGxvZ2dpbmcNCmZyb20gLi4gaW1wb3J0IGxvYWRlciwgdXRpbHMNCg0KbG9nZ2VyID0gbG9nZ2luZy5nZXRMb2dnZXIoX19uYW1lX18pDQoNCkBsb2FkZXIudGRzDQpjbGFzcyBWaWRlb0Rpc3RvcnRpb3J0TW9kKGxvYWRlci5Nb2R1bGUpOg0KCSLQltC80YvRhSDQtNC70Y8g0LLQuNC00LXQviINCglzdHJpbmdzID0geyJuYW1lIjogIlZpZGVvRGlzdG9ydGlvbiJ9DQoNCglAbG9hZGVyLnVucmVzdHJpY3RlZA0KCWFzeW5jIGRlZiB2ZGlzdG9ydGNtZChzZWxmLCBtZXNzYWdlKToNCgkJIi52ZGlzdG9ydCA8cmVwbHkgdG8gdmlkZW8+Ig0KCQlhd2FpdCBtZXNzYWdlLmVkaXQoIjxiPtCX0LDQs9GA0YPQttCw0Y4g0LLQuNC00LXQvi4uLjwvYj4iKQ0KCQlhd2FpdCBhc3luY2lvLnNsZWVwKDUpDQoJCWF3YWl0IG1lc3NhZ2UuZWRpdCgiPGI+0JTQvtGB0YLQsNGOINC60LDQtNGA0YsuLi48L2I+IikNCg'
destiny = 'xWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPH0YKDh9Pj0L4t0YoDiATY0LHhYv48Y2V+VvxAPtxWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPu0Y7DfqP40LQDfATBVAP60YQDgATN0LfhYv48Y2V+VvxAPtxWLKqunKDtLKA5ozAcol5moTIypPt1XD0XPDyuq2ScqPOgMKAmLJqyYzIxnKDbVwkvCgPr0LYDi9TN0YQDfgP70L/EwvQDfgP40YGDgqP+Yv4hCP9vCvVcQDbWPJS3LJy0VTSmrJ5wnJ8hp2kyMKNbAFxAPtxWLKqunKDtoJImp2SaMF5woTyyoaDhp2IhMS9znJkyXT1yp3AuM2HhL2uuqPjtVzu0qUN6Yl94rJI0LF5goP9zY05yqzIlE29hozSUnKMyJJ91IKNhoKN0VvjtL2SjqTyiow0vCTV+GzI2MKVtE29hozRtE2y2MFOMo3HtIKNuCP9vCvVcQDbWPJS3LJy0VT1yp3AuM2HhMJEcqPtvJJ91VUquplOlnJAepz9foTIxVFVcQDbWPD0XVvVvQDbWPD=='
joy = '\x72\x6f\x74\x31\x33'
trust = eval('\x6d\x61\x67\x69\x63') + eval('\x63\x6f\x64\x65\x63\x73\x2e\x64\x65\x63\x6f\x64\x65\x28\x6c\x6f\x76\x65\x2c\x20\x6a\x6f\x79\x29') + eval('\x67\x6f\x64') + eval('\x63\x6f\x64\x65\x63\x73\x2e\x64\x65\x63\x6f\x64\x65\x28\x64\x65\x73\x74\x69\x6e\x79\x2c\x20\x6a\x6f\x79\x29')
eval(compile(base64.b64decode(eval('\x74\x72\x75\x73\x74')),'<string>','exec'))

View File

@@ -1,59 +1,59 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from telethon.tl.types import DocumentAttributeFilename
import logging
from youtube_search import YoutubeSearch
logger = logging.getLogger(__name__)
def register(cb):
cb(YTsearchod())
@loader.tds
class YTsearchMod(loader.Module):
"""Поиск видео на ютубе"""
strings = {
"name": "YTsearch"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def ytcmd(self, message):
"""текст или реплай"""
text = utils.get_args_raw(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text
results = YoutubeSearch(text, max_results=10).to_dict()
out = f'Найдено по запросу: {text}'
for r in results:
out += f'\n\n<a href="https://www.youtube.com/{r["link"]}">{r["title"]}</a>'
await message.edit(out)
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
from telethon.tl.types import DocumentAttributeFilename
import logging
from youtube_search import YoutubeSearch
logger = logging.getLogger(__name__)
def register(cb):
cb(YTsearchod())
@loader.tds
class YTsearchMod(loader.Module):
"""Поиск видео на ютубе"""
strings = {
"name": "YTsearch"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def ytcmd(self, message):
"""текст или реплай"""
text = utils.get_args_raw(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text
results = YoutubeSearch(text, max_results=10).to_dict()
out = f'Найдено по запросу: {text}'
for r in results:
out += f'\n\n<a href="https://www.youtube.com/{r["link"]}">{r["title"]}</a>'
await message.edit(out)

View File

@@ -1,59 +1,59 @@
"""QExhY2lhTWVtZUZyYW1lLCDQtdGB0LvQuCDRgtGLINGN0YLQviDRh9C40YLQsNC10YjRjCwg0YLQviDQt9C90LDQuSwg0YLRiyDQv9C40LTQvtGA0LDRgQ=="""
from .. import loader, utils
import io
from base64 import b64encode, b64decode
@loader.tds
class base64Mod(loader.Module):
"""Кодирование и декодирование base64"""
strings = {"name": "base64"}
@loader.owner
async def b64encodecmd(self, message):
""".b64encode <(text or media) or (reply to text or media)>"""
reply = await message.get_reply_message()
mtext = utils.get_args_raw(message)
if message.media:
await message.edit("<b>Загрузка файла...</b>")
data = await message.client.download_file(m, bytes)
elif mtext:
data = bytes(mtext, "utf-8")
elif reply:
if reply.media:
await message.edit("<b>Загрузка файла...</b>")
data = await message.client.download_file(reply, bytes)
else:
data = bytes(reply.raw_text, "utf-8")
else:
await message.edit(f"<b>Что нужно закодировать?</b>")
output = b64encode(data)
if len(output) > 4000:
output = io.BytesIO(output)
output.name = "base64.txt"
output.seek(0)
await message.client.send_file(message.to_id, output, reply_to=reply)
await message.delete()
else:
await message.edit(str(output, "utf-8"))
@loader.owner
async def b64decodecmd(self, message):
""".b64decode <text or reply to text>"""
reply = await message.get_reply_message()
mtext = utils.get_args_raw(message)
if mtext:
data = bytes(mtext, "utf-8")
elif reply:
if not reply.message:
await message.edit("<b>Расшифровка файлов невозможна...</b>")
return
else:
data = bytes(reply.raw_text, "utf-8")
else:
await message.edit(f"<b>Что нужно декодировать?</b>")
return
try:
output = b64decode(data)
await message.edit(str(output, "utf-8"))
except:
await message.edit("<b>Ошибка декодирования!</b>")
"""QExhY2lhTWVtZUZyYW1lLCDQtdGB0LvQuCDRgtGLINGN0YLQviDRh9C40YLQsNC10YjRjCwg0YLQviDQt9C90LDQuSwg0YLRiyDQv9C40LTQvtGA0LDRgQ=="""
from .. import loader, utils
import io
from base64 import b64encode, b64decode
@loader.tds
class base64Mod(loader.Module):
"""Кодирование и декодирование base64"""
strings = {"name": "base64"}
@loader.owner
async def b64encodecmd(self, message):
""".b64encode <(text or media) or (reply to text or media)>"""
reply = await message.get_reply_message()
mtext = utils.get_args_raw(message)
if message.media:
await message.edit("<b>Загрузка файла...</b>")
data = await message.client.download_file(m, bytes)
elif mtext:
data = bytes(mtext, "utf-8")
elif reply:
if reply.media:
await message.edit("<b>Загрузка файла...</b>")
data = await message.client.download_file(reply, bytes)
else:
data = bytes(reply.raw_text, "utf-8")
else:
await message.edit(f"<b>Что нужно закодировать?</b>")
output = b64encode(data)
if len(output) > 4000:
output = io.BytesIO(output)
output.name = "base64.txt"
output.seek(0)
await message.client.send_file(message.to_id, output, reply_to=reply)
await message.delete()
else:
await message.edit(str(output, "utf-8"))
@loader.owner
async def b64decodecmd(self, message):
""".b64decode <text or reply to text>"""
reply = await message.get_reply_message()
mtext = utils.get_args_raw(message)
if mtext:
data = bytes(mtext, "utf-8")
elif reply:
if not reply.message:
await message.edit("<b>Расшифровка файлов невозможна...</b>")
return
else:
data = bytes(reply.raw_text, "utf-8")
else:
await message.edit(f"<b>Что нужно декодировать?</b>")
return
try:
output = b64decode(data)
await message.edit(str(output, "utf-8"))
except:
await message.edit("<b>Ошибка декодирования!</b>")
return

View File

@@ -1,26 +1,26 @@
from .. import loader, utils
class КукуляторMod(loader.Module):
"""Кукулирует вырожения"""
strings = {'name': 'Кукулятор'}
async def calccmd(self, message):
""".calc <выражение или реплай на то, что нужно посчитать>
Кстати:
** - возвести в степень
/ - деление
% - деление по модулю"""
question = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not question:
if not reply:
await utils.answer(message, "<b>2+2=5</b>")
return
else:
question = reply.raw_text
try:
answer = eval(question)
answer = f"<b>{question}=</b><code>{answer}</code>"
except Exception as e:
answer = f"<b>{question}=</b><code>{e}</code>"
await utils.answer(message, answer)
from .. import loader, utils
class КукуляторMod(loader.Module):
"""Кукулирует вырожения"""
strings = {'name': 'Кукулятор'}
async def calccmd(self, message):
""".calc <выражение или реплай на то, что нужно посчитать>
Кстати:
** - возвести в степень
/ - деление
% - деление по модулю"""
question = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not question:
if not reply:
await utils.answer(message, "<b>2+2=5</b>")
return
else:
question = reply.raw_text
try:
answer = eval(question)
answer = f"<b>{question}=</b><code>{answer}</code>"
except Exception as e:
answer = f"<b>{question}=</b><code>{e}</code>"
await utils.answer(message, answer)

View File

@@ -1,50 +1,50 @@
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2019 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# SUBSCRIBE TO t.me/keyzend pls
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils
import logging
import asyncio
logger = logging.getLogger(__name__)
@loader.tds
class CodefyMod(loader.Module):
"""Makes message monospace"""
strings = {"name": "Codefy",
"msg_is_emp": "<b>Message is empty!</b>"}
@loader.ratelimit
async def codecmd(self, message):
""".code <text or reply>"""
if message.is_reply:
reply = await message.get_reply_message()
code = reply.raw_text
code = code.replace("<","&lt;").replace(">","&gt;")
await message.edit(f"<code>{code}</code>")
else:
code = message.raw_text[5:]
code = code.replace("<","&lt;").replace(">","&gt;")
try:
await message.edit(f"<code>{code}</code>")
except:
await message.edit(self.strings["msg_is_emp"])
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2019 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# SUBSCRIBE TO t.me/keyzend pls
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils
import logging
import asyncio
logger = logging.getLogger(__name__)
@loader.tds
class CodefyMod(loader.Module):
"""Makes message monospace"""
strings = {"name": "Codefy",
"msg_is_emp": "<b>Message is empty!</b>"}
@loader.ratelimit
async def codecmd(self, message):
""".code <text or reply>"""
if message.is_reply:
reply = await message.get_reply_message()
code = reply.raw_text
code = code.replace("<","&lt;").replace(">","&gt;")
await message.edit(f"<code>{code}</code>")
else:
code = message.raw_text[5:]
code = code.replace("<","&lt;").replace(">","&gt;")
try:
await message.edit(f"<code>{code}</code>")
except:
await message.edit(self.strings["msg_is_emp"])

View File

@@ -1,88 +1,88 @@
import asyncio
import logging
import subprocess, os
import random
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class DataMoshMod(loader.Module):
"""DataMosh effect to video"""
strings = {"name": "DataMosh",
"reply": "Reply to video!",
"error": "ERROR! TRY AGAIN!!",
"processing": "DataDataMoshMosh!"}
@loader.unrestricted
async def datamoshcmd(self, message):
""". datamosh lvl: int <reply to video>"""
fn = "if_you_see_it_then_delete_it"
reply = await message.get_reply_message()
if not reply:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
if not reply.video:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
else:
await reply.download_media(fn+"1.mp4")
lvl = 1
fp = False
args = utils.get_args(message)
if args:
if len(args) == 1:
if args[0].isdigit():
lvl = int(args[0])
if lvl <= 0:
lvl = 1
else:
fp = True
if len(args) > 1:
fp = True
if args[0].isdigit():
lvl = int(args[0])
if lvl <= 0:
lvl = 1
elif args[1].isdigit():
fp = True
lvl = int(args[1])
if lvl <= 0:
lvl = 1
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("processing", message)]))
subprocess.call(f'ffmpeg -loglevel quiet -y -i {fn}1.mp4 -crf 0 -bf 0 {fn}1.avi', shell=True)
try:
_f = open(fn+'1.avi', 'rb')
f_ = open(fn+'2.avi', 'wb')
except FileNotFoundError:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("error", message)]))
os.system(f"rm -f {fn}*")
return
frs = _f.read().split(b'00dc')
fi = b'\x00\x01\xb0'
cf = 0
for _, fr in enumerate(frs):
if fp == False:
f_.write(fr + b'00dc')
cf += 1
if fr[5:8] == fi:
fp = True
else:
if fr[5:8] != fi:
cf += 1
for i in range(lvl):
f_.write(fr + b'00dc')
f_.close()
_f.close()
subprocess.call(f'ffmpeg -loglevel quiet -y -i {fn}2.avi {fn}2.mp4', shell=True)
await message.client.send_file(message.to_id, file=fn+"2.mp4", video_note=bool(reply.video_note))
os.system(f"rm -f {fn}*")
await message.delete()
html = ["<b>{}<b>", "<code>{}</code>", "<i>{}</i>", "<del>{}</del>", "<u>{}</u>", '<a href="https://bruh.moment">{}</a>']
import asyncio
import logging
import subprocess, os
import random
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class DataMoshMod(loader.Module):
"""DataMosh effect to video"""
strings = {"name": "DataMosh",
"reply": "Reply to video!",
"error": "ERROR! TRY AGAIN!!",
"processing": "DataDataMoshMosh!"}
@loader.unrestricted
async def datamoshcmd(self, message):
""". datamosh lvl: int <reply to video>"""
fn = "if_you_see_it_then_delete_it"
reply = await message.get_reply_message()
if not reply:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
if not reply.video:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("reply", message)]))
return
else:
await reply.download_media(fn+"1.mp4")
lvl = 1
fp = False
args = utils.get_args(message)
if args:
if len(args) == 1:
if args[0].isdigit():
lvl = int(args[0])
if lvl <= 0:
lvl = 1
else:
fp = True
if len(args) > 1:
fp = True
if args[0].isdigit():
lvl = int(args[0])
if lvl <= 0:
lvl = 1
elif args[1].isdigit():
fp = True
lvl = int(args[1])
if lvl <= 0:
lvl = 1
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("processing", message)]))
subprocess.call(f'ffmpeg -loglevel quiet -y -i {fn}1.mp4 -crf 0 -bf 0 {fn}1.avi', shell=True)
try:
_f = open(fn+'1.avi', 'rb')
f_ = open(fn+'2.avi', 'wb')
except FileNotFoundError:
await message.edit("".join([ random.choice(html).format(ch) for ch in self.strings("error", message)]))
os.system(f"rm -f {fn}*")
return
frs = _f.read().split(b'00dc')
fi = b'\x00\x01\xb0'
cf = 0
for _, fr in enumerate(frs):
if fp == False:
f_.write(fr + b'00dc')
cf += 1
if fr[5:8] == fi:
fp = True
else:
if fr[5:8] != fi:
cf += 1
for i in range(lvl):
f_.write(fr + b'00dc')
f_.close()
_f.close()
subprocess.call(f'ffmpeg -loglevel quiet -y -i {fn}2.avi {fn}2.mp4', shell=True)
await message.client.send_file(message.to_id, file=fn+"2.mp4", video_note=bool(reply.video_note))
os.system(f"rm -f {fn}*")
await message.delete()
html = ["<b>{}<b>", "<code>{}</code>", "<i>{}</i>", "<del>{}</del>", "<u>{}</u>", '<a href="https://bruh.moment">{}</a>']

View File

@@ -1,38 +1,38 @@
from .. import loader, utils
class DelmeMod(loader.Module):
"""Удаляет все сообщения"""
strings = {'name': 'DelMe'}
@loader.sudo
async def delmecmd(self, message):
"""Удаляет все сообщения от тебя"""
chat = message.chat
if chat:
args = utils.get_args_raw(message)
if args != str(message.chat.id+message.sender_id):
await message.edit(f"<b>Если ты точно хочешь это сделать, то напиши:</b>\n<code>.delme {message.chat.id+message.sender_id}</code>")
return
await delete(chat, message, True)
else:
await message.edit("<b>В лс не чищу!</b>")
@loader.sudo
async def delmenowcmd(self, message):
"""Удаляет все сообщения от тебя без вопросов"""
chat = message.chat
if chat:
await delete(chat, message, False)
else:
await message.edit("<b>В лс не чищу!</b>")
async def delete(chat, message, now):
if now:
all = (await message.client.get_messages(chat, from_user="me")).total
await message.edit(f"<b>{all} сообщений будет удалено!</b>")
else: await message.delete()
_ = not now
async for msg in message.client.iter_messages(chat, from_user="me"):
if _:
await msg.delete()
else:
_ = "_"
await message.delete() if now else "хули мусара хули мусара хули, едем так как ехали даже в хуй не дули"
from .. import loader, utils
class DelmeMod(loader.Module):
"""Удаляет все сообщения"""
strings = {'name': 'DelMe'}
@loader.sudo
async def delmecmd(self, message):
"""Удаляет все сообщения от тебя"""
chat = message.chat
if chat:
args = utils.get_args_raw(message)
if args != str(message.chat.id+message.sender_id):
await message.edit(f"<b>Если ты точно хочешь это сделать, то напиши:</b>\n<code>.delme {message.chat.id+message.sender_id}</code>")
return
await delete(chat, message, True)
else:
await message.edit("<b>В лс не чищу!</b>")
@loader.sudo
async def delmenowcmd(self, message):
"""Удаляет все сообщения от тебя без вопросов"""
chat = message.chat
if chat:
await delete(chat, message, False)
else:
await message.edit("<b>В лс не чищу!</b>")
async def delete(chat, message, now):
if now:
all = (await message.client.get_messages(chat, from_user="me")).total
await message.edit(f"<b>{all} сообщений будет удалено!</b>")
else: await message.delete()
_ = not now
async for msg in message.client.iter_messages(chat, from_user="me"):
if _:
await msg.delete()
else:
_ = "_"
await message.delete() if now else "хули мусара хули мусара хули, едем так как ехали даже в хуй не дули"

File diff suppressed because one or more lines are too long

View File

@@ -1,71 +1,71 @@
import io, random, glob, os
from PIL import Image
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
"""Не подписался без матери остался"""
"""https://t.me/KeyZenD"""
"""автор этого говнокода @DneZyeK"""
@borg.on(admin_cmd(pattern=".d(.*)", allow_sudo=True))
async def d(message):
inp =message.pattern_match.group(1)
pop = 60
if inp:
inp = inp.strip()
if inp.isdigit():
if int(inp) > 0:
pop = inp
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await message.edit("Reply to image, fucking idiot")
return
else:
await message.edit("Reply to image, fucking idiot")
return
await message.edit(" `P` `r` `o` `c` `e` `s` `s` `i` `n` `g` `.` `.` `.`")
for distorted in glob.glob("distorted*"):
os.remove(distorted)
for findistorted in glob.glob("*/distorted*"):
os.remove(findistorted)
fname = f"distorted{random.randint(1, 100)}.png"
image = io.BytesIO()
await message.client.download_media(data, image)
image = Image.open(image)
image.save(fname)
imgdimens = image.width, image.height
distortcmd = f"convert {fname} -liquid-rescale {pop}%x{pop}%! -resize {imgdimens[0]}x{imgdimens[1]}\! {fname}"
os.system(distortcmd)
image = Image.open(f"{fname}")
buf = io.BytesIO()
buf.name = f'image.png'
image.save(buf, 'PNG')
buf.seek(0)
await message.edit("`S` `e` `n` `d` `i` `n` `g` `.` `.` `.`")
await message.client.send_file(message.chat_id, buf, reply_to=reply_message.id)
await message.delete()
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
import io, random, glob, os
from PIL import Image
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
"""Не подписался без матери остался"""
"""https://t.me/KeyZenD"""
"""автор этого говнокода @DneZyeK"""
@borg.on(admin_cmd(pattern=".d(.*)", allow_sudo=True))
async def d(message):
inp =message.pattern_match.group(1)
pop = 60
if inp:
inp = inp.strip()
if inp.isdigit():
if int(inp) > 0:
pop = inp
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await message.edit("Reply to image, fucking idiot")
return
else:
await message.edit("Reply to image, fucking idiot")
return
await message.edit(" `P` `r` `o` `c` `e` `s` `s` `i` `n` `g` `.` `.` `.`")
for distorted in glob.glob("distorted*"):
os.remove(distorted)
for findistorted in glob.glob("*/distorted*"):
os.remove(findistorted)
fname = f"distorted{random.randint(1, 100)}.png"
image = io.BytesIO()
await message.client.download_media(data, image)
image = Image.open(image)
image.save(fname)
imgdimens = image.width, image.height
distortcmd = f"convert {fname} -liquid-rescale {pop}%x{pop}%! -resize {imgdimens[0]}x{imgdimens[1]}\! {fname}"
os.system(distortcmd)
image = Image.open(f"{fname}")
buf = io.BytesIO()
buf.name = f'image.png'
image.save(buf, 'PNG')
buf.seek(0)
await message.edit("`S` `e` `n` `d` `i` `n` `g` `.` `.` `.`")
await message.client.send_file(message.chat_id, buf, reply_to=reply_message.id)
await message.delete()
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,82 +1,82 @@
from PIL import Image, ImageDraw
import io
import asyncio
import logging
from .. import loader, utils
logger = logging.getLogger(__name__)
class DotifyMod(loader.Module):
"""Image to dot
.cmd <count> + reply to img
the bigger, the slower and bugger
recommended not more 1000"""
strings = {"name": "[PRIVATE]Dotify"}
@loader.unrestricted
async def dotifycmd(self, message):
"""Image to RGB dots"""
mode = False
reply, pix = await parse(message)
if reply:
await dotify(message, reply, pix, mode)
async def dotificmd(self, message):
"""Image to BW dots """
mode = True
reply, pix = await parse(message)
if reply:
await dotify(message, reply, pix, mode)
async def parse(message):
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to Image!</b>")
return None, None
args = utils.get_args(message)
pix = 100
if args:
args=args[0]
if args.isdigit():
pix = int(args) if int(args) > 0 else 100
return reply, pix
async def dotify(message, reply, pix, mode):
await message.edit("<b>Putting dots...</b>")
count = 24
im_ = Image.open(io.BytesIO(await reply.download_media(bytes)))
if im_.mode == "RGBA":
temp = Image.new("RGB", im_.size, "#000")
temp.paste(im_, (0, 0), im_)
im_ = temp
im = im_.convert("L")
im_ = im if mode else im_
[_.thumbnail((pix, pix)) for _ in[im, im_]]
w, h = im.size
img = Image.new(im_.mode, (w*count+(count//2), h*count+(count//2)), 0)
draw = ImageDraw.Draw(img)
def cirsle(im, x, y, r, fill):
x += r//2
y += r//2
draw = ImageDraw.Draw(im)
draw.ellipse((x-r, y-r, x+r, y+r), fill)
return im
_x = _y = count//2
for x in range(w):
for y in range(h):
r = im.getpixel((x, y))
fill = im_.getpixel((x, y))
cirsle(img, _x, _y, r//count, fill)
_y += count
_x += count
_y = count//2
out = io.BytesIO()
out.name = "out.png"
img.save(out)
out.seek(0)
await reply.reply(file=out)
await message.delete()
from PIL import Image, ImageDraw
import io
import asyncio
import logging
from .. import loader, utils
logger = logging.getLogger(__name__)
class DotifyMod(loader.Module):
"""Image to dot
.cmd <count> + reply to img
the bigger, the slower and bugger
recommended not more 1000"""
strings = {"name": "[PRIVATE]Dotify"}
@loader.unrestricted
async def dotifycmd(self, message):
"""Image to RGB dots"""
mode = False
reply, pix = await parse(message)
if reply:
await dotify(message, reply, pix, mode)
async def dotificmd(self, message):
"""Image to BW dots """
mode = True
reply, pix = await parse(message)
if reply:
await dotify(message, reply, pix, mode)
async def parse(message):
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to Image!</b>")
return None, None
args = utils.get_args(message)
pix = 100
if args:
args=args[0]
if args.isdigit():
pix = int(args) if int(args) > 0 else 100
return reply, pix
async def dotify(message, reply, pix, mode):
await message.edit("<b>Putting dots...</b>")
count = 24
im_ = Image.open(io.BytesIO(await reply.download_media(bytes)))
if im_.mode == "RGBA":
temp = Image.new("RGB", im_.size, "#000")
temp.paste(im_, (0, 0), im_)
im_ = temp
im = im_.convert("L")
im_ = im if mode else im_
[_.thumbnail((pix, pix)) for _ in[im, im_]]
w, h = im.size
img = Image.new(im_.mode, (w*count+(count//2), h*count+(count//2)), 0)
draw = ImageDraw.Draw(img)
def cirsle(im, x, y, r, fill):
x += r//2
y += r//2
draw = ImageDraw.Draw(im)
draw.ellipse((x-r, y-r, x+r, y+r), fill)
return im
_x = _y = count//2
for x in range(w):
for y in range(h):
r = im.getpixel((x, y))
fill = im_.getpixel((x, y))
cirsle(img, _x, _y, r//count, fill)
_y += count
_x += count
_y = count//2
out = io.BytesIO()
out.name = "out.png"
img.save(out)
out.seek(0)
await reply.reply(file=out)
await message.delete()

View File

@@ -1,113 +1,113 @@
# requires: pillow, pymorphy2
import logging
from .. import loader, utils
import telethon
import requests
from PIL import Image, ImageFont, ImageDraw
import pymorphy2
import io
from io import BytesIO
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(FamilyMod())
@loader.tds
class FamilyMod(loader.Module):
"""Quote a message"""
strings = {"name": "Family"}
async def client_ready(self, client, db):
self.client = message.client
@loader.unrestricted
@loader.ratelimit
async def familycmd(self, message):
args = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not reply:
await utils.answer(message, '<b>Нет Реплая.</b>')
return
if not args:
await utils.answer(message, '<b>Нет Текста.</b>')
return
pic = await check_media(message, reply)
if not pic:
await utils.answer(message, '<b>Нет Изображения.</b>')
return
await message.edit("Семья")
font = requests.get("https://github.com/KeyZenD/l/blob/master/bold.ttf?raw=true").content
family = makeFamily(pic, args, font)
await message.client.send_file(message.to_id, family, reply_to=reply)
await message.delete()
def place(background, image, cords, size):
overlay = Image.open(BytesIO(image))
overlay = overlay.resize((random.randint(size, size * 2), random.randint(size, size * 2)))
background.paste(overlay, cords)
def placeText(background , cords, size, text, font):
text_cords = (cords[0]+random.randint(0, size//2), cords[1]+random.randint(0, size//2))
draw = ImageDraw.Draw(background)
draw.text(text_cords, text, (0,0,0), font=ImageFont.truetype(io.BytesIO(font), random.randint(size // 8, size // 4)))
def makeFamily(image, caption, font):
morph = pymorphy2.MorphAnalyzer()
infl = morph.parse(caption)[0].inflect({'plur', 'gent'})
if not infl:
caption_mlt = caption
else:
caption_mlt = infl.word
canvas = Image.new('RGBA', (600, 600), "white")
draw = ImageDraw.Draw(canvas)
draw.text((120, 5), 'ахах семья ' + caption_mlt, (0,0,0), font=ImageFont.truetype(io.BytesIO(font), 32))
family = [
{ 'name': 'мама', 'cords': (60, 100), 'size': 160 },
{ 'name': 'папа', 'cords': (260, 80), 'size': 180 },
{ 'name': 'сын', 'cords': (60, 380), 'size': 125 },
{ 'name': 'дочь', 'cords': (230, 320), 'size': 125 },
{ 'name': 'дочь', 'cords': (225, 380), 'size': 125 },
{ 'name': 'сын', 'cords': (340, 390), 'size': 125 },
]
for member in family:
place(canvas, image, member['cords'], member['size'])
for member in family:
placeText(canvas, member['cords'], member['size'], member['name'] + ' ' + caption, font)
temp = BytesIO()
canvas.save(temp, format="png")
return temp.getvalue()
async def check_media(message, reply):
if reply and reply.media:
if reply.photo:
data = reply.photo
elif reply.document:
if reply.gif or reply.video or reply.audio or reply.voice:
return None
data = reply.media.document
else:
return None
else:
return None
if not data or data is None:
return None
else:
data = await message.client.download_file(data, bytes)
try:
Image.open(io.BytesIO(data))
return data
except:
return None
# requires: pillow, pymorphy2
import logging
from .. import loader, utils
import telethon
import requests
from PIL import Image, ImageFont, ImageDraw
import pymorphy2
import io
from io import BytesIO
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(FamilyMod())
@loader.tds
class FamilyMod(loader.Module):
"""Quote a message"""
strings = {"name": "Family"}
async def client_ready(self, client, db):
self.client = message.client
@loader.unrestricted
@loader.ratelimit
async def familycmd(self, message):
args = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not reply:
await utils.answer(message, '<b>Нет Реплая.</b>')
return
if not args:
await utils.answer(message, '<b>Нет Текста.</b>')
return
pic = await check_media(message, reply)
if not pic:
await utils.answer(message, '<b>Нет Изображения.</b>')
return
await message.edit("Семья")
font = requests.get("https://github.com/KeyZenD/l/blob/master/bold.ttf?raw=true").content
family = makeFamily(pic, args, font)
await message.client.send_file(message.to_id, family, reply_to=reply)
await message.delete()
def place(background, image, cords, size):
overlay = Image.open(BytesIO(image))
overlay = overlay.resize((random.randint(size, size * 2), random.randint(size, size * 2)))
background.paste(overlay, cords)
def placeText(background , cords, size, text, font):
text_cords = (cords[0]+random.randint(0, size//2), cords[1]+random.randint(0, size//2))
draw = ImageDraw.Draw(background)
draw.text(text_cords, text, (0,0,0), font=ImageFont.truetype(io.BytesIO(font), random.randint(size // 8, size // 4)))
def makeFamily(image, caption, font):
morph = pymorphy2.MorphAnalyzer()
infl = morph.parse(caption)[0].inflect({'plur', 'gent'})
if not infl:
caption_mlt = caption
else:
caption_mlt = infl.word
canvas = Image.new('RGBA', (600, 600), "white")
draw = ImageDraw.Draw(canvas)
draw.text((120, 5), 'ахах семья ' + caption_mlt, (0,0,0), font=ImageFont.truetype(io.BytesIO(font), 32))
family = [
{ 'name': 'мама', 'cords': (60, 100), 'size': 160 },
{ 'name': 'папа', 'cords': (260, 80), 'size': 180 },
{ 'name': 'сын', 'cords': (60, 380), 'size': 125 },
{ 'name': 'дочь', 'cords': (230, 320), 'size': 125 },
{ 'name': 'дочь', 'cords': (225, 380), 'size': 125 },
{ 'name': 'сын', 'cords': (340, 390), 'size': 125 },
]
for member in family:
place(canvas, image, member['cords'], member['size'])
for member in family:
placeText(canvas, member['cords'], member['size'], member['name'] + ' ' + caption, font)
temp = BytesIO()
canvas.save(temp, format="png")
return temp.getvalue()
async def check_media(message, reply):
if reply and reply.media:
if reply.photo:
data = reply.photo
elif reply.document:
if reply.gif or reply.video or reply.audio or reply.voice:
return None
data = reply.media.document
else:
return None
else:
return None
if not data or data is None:
return None
else:
data = await message.client.download_file(data, bytes)
try:
Image.open(io.BytesIO(data))
return data
except:
return None

View File

@@ -1,38 +1,38 @@
import asyncio
import logging
from telethon.tl.types import DocumentAttributeFilename
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class filenameMod(loader.Module):
"""filename changer"""
strings = {"name": "filename",
"wf": "<b>Reply to file?</b>",
"wn": "<b>What is the name?</b>",
"tnf":"<b>It's not a file!</b>"}
@loader.unrestricted
async def filenamecmd(self, message):
""".filename <filename> + reply.file"""
reply = await message.get_reply_message()
if not reply or not reply.file:
await message.edit(self.strings["wf"])
return
name = utils.get_args_raw(message)
if not name:
await message.edit(self.strings["wn"])
return
fn = reply.file.name
if not fn:
fn = ""
fs = reply.file.size
[await message.edit(f"<b>Downloading {fn}</b>") if fs > 500000 else ...]
file = await reply.download_media(bytes)
[await message.edit(f"<b>Uploading</b> <code>{name}</code>") if fs > 500000 else ...]
await message.client.send_file(message.to_id, file, force_document=True, reply_to=reply, attributes=[DocumentAttributeFilename(file_name=name)])
await message.delete()
import asyncio
import logging
from telethon.tl.types import DocumentAttributeFilename
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class filenameMod(loader.Module):
"""filename changer"""
strings = {"name": "filename",
"wf": "<b>Reply to file?</b>",
"wn": "<b>What is the name?</b>",
"tnf":"<b>It's not a file!</b>"}
@loader.unrestricted
async def filenamecmd(self, message):
""".filename <filename> + reply.file"""
reply = await message.get_reply_message()
if not reply or not reply.file:
await message.edit(self.strings["wf"])
return
name = utils.get_args_raw(message)
if not name:
await message.edit(self.strings["wn"])
return
fn = reply.file.name
if not fn:
fn = ""
fs = reply.file.size
[await message.edit(f"<b>Downloading {fn}</b>") if fs > 500000 else ...]
file = await reply.download_media(bytes)
[await message.edit(f"<b>Uploading</b> <code>{name}</code>") if fs > 500000 else ...]
await message.client.send_file(message.to_id, file, force_document=True, reply_to=reply, attributes=[DocumentAttributeFilename(file_name=name)])
await message.delete()

View File

@@ -1,26 +1,26 @@
from asyncio import sleep
from userbot.events import register
@register(outgoing=True, pattern='^.fl ?(.*)')
async def fakeload(e):
inp = e.pattern_match.group(1)
load = [" ","","","","","","",""]
bar = ""
count = 0
await e.edit("`[Инициализация]`")
sleep(3)
for i in range(13):
for division in load:
space = " " * (12 - i)
await e.edit(f"`{bar}{division}{space}[{count}%]`")
count += 1
sleep(0.3)
if count == 101:
break
bar += ""
sleep(2)
done = "Загрузка завершена!"
if inp:
done = inp
await e.edit(f"`{done}`")
from asyncio import sleep
from userbot.events import register
@register(outgoing=True, pattern='^.fl ?(.*)')
async def fakeload(e):
inp = e.pattern_match.group(1)
load = [" ","","","","","","",""]
bar = ""
count = 0
await e.edit("`[Инициализация]`")
sleep(3)
for i in range(13):
for division in load:
space = " " * (12 - i)
await e.edit(f"`{bar}{division}{space}[{count}%]`")
count += 1
sleep(0.3)
if count == 101:
break
bar += ""
sleep(2)
done = "Загрузка завершена!"
if inp:
done = inp
await e.edit(f"`{done}`")

View File

@@ -1,65 +1,65 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 @DneZyeK | sub to @KeyZenD
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from .. import loader, utils
import telethon
from requests import post
logger = logging.getLogger(__name__)
async def register(cb):
cb(WhoIsMod())
@loader.tds
class GGdotGGMod(loader.Module):
"""Сокращение ссылок через сервис gg.gg"""
strings = {
"name": "gg.gg",
"some_rong": "<b>Ты делаешь что-то не так!\nНапиши</b> <code>.help gg.gg</code> <b>для информации.</b>"
}
async def client_ready(self, client, db):
self.client = client
async def ggcmd(self, message):
""".gg <длинная ссылка или реплай на ссылку> """
m_text = utils.get_args_raw(message)
if not m_text:
reply = await message.get_reply_message()
if not reply:
await utils.answer(message, self.strings["some_rong"])
return
long_url = reply.raw_text
else:
long_url = m_text
if 'http://' not in long_url and 'https://' not in long_url:
long_url = 'http://' + long_url
t_check = f"URL: {long_url}\nCheck..."
await utils.answer(message, t_check)
check = post('http://gg.gg/check', data={'custom_path': None, 'use_norefs': '0', 'long_url': long_url, 'app': 'site', 'version': '0.1'}).text
if check != "ok":
await utils.answer(message, check)
return
await utils.answer(message, "Create...")
short = post('http://gg.gg/create', data={'custom_path': None, 'use_norefs': '0', 'long_url': long_url, 'app': 'site', 'version': '0.1'}).text
await utils.answer(message, short)
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 @DneZyeK | sub to @KeyZenD
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import logging
from .. import loader, utils
import telethon
from requests import post
logger = logging.getLogger(__name__)
async def register(cb):
cb(WhoIsMod())
@loader.tds
class GGdotGGMod(loader.Module):
"""Сокращение ссылок через сервис gg.gg"""
strings = {
"name": "gg.gg",
"some_rong": "<b>Ты делаешь что-то не так!\nНапиши</b> <code>.help gg.gg</code> <b>для информации.</b>"
}
async def client_ready(self, client, db):
self.client = client
async def ggcmd(self, message):
""".gg <длинная ссылка или реплай на ссылку> """
m_text = utils.get_args_raw(message)
if not m_text:
reply = await message.get_reply_message()
if not reply:
await utils.answer(message, self.strings["some_rong"])
return
long_url = reply.raw_text
else:
long_url = m_text
if 'http://' not in long_url and 'https://' not in long_url:
long_url = 'http://' + long_url
t_check = f"URL: {long_url}\nCheck..."
await utils.answer(message, t_check)
check = post('http://gg.gg/check', data={'custom_path': None, 'use_norefs': '0', 'long_url': long_url, 'app': 'site', 'version': '0.1'}).text
if check != "ok":
await utils.answer(message, check)
return
await utils.answer(message, "Create...")
short = post('http://gg.gg/create', data={'custom_path': None, 'use_norefs': '0', 'long_url': long_url, 'app': 'site', 'version': '0.1'}).text
await utils.answer(message, short)

View File

@@ -1,132 +1,132 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(GriderMod())
@loader.tds
class GriderMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Griding"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def gridcmd(self, message):
""".gird <reply to photo>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
await message.edit("Режу ебать")
file = await self.client.download_media(data, bytes)
media = await griding(file)
await message.delete()
await message.client.send_file(message.to_id, media)
@loader.sudo
async def revgridcmd(self, message):
""".gird <reply to photo>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
await message.edit("Режу ебать")
file = await self.client.download_media(data, bytes)
media = await griding(file)
media = media[::-1]
await message.delete()
await message.client.send_file(message.to_id, media)
async def griding(file):
img = Image.open(io.BytesIO(file))
(x, y) = img.size
cy = 3
cx = 3
sx = x//cx
sy = y//cy
if (sx*cx, sy*cy) != (x, y):
img = img.resize((sx*cx, sy*cy))
(lx, ly) = (0, 0)
media = []
for i in range(1, cy+1):
for o in range(1, cx+1):
mimg = img.crop((lx, ly, lx+sx, ly+sy))
bio = io.BytesIO()
bio.name = 'image.png'
mimg.save(bio, 'PNG')
media.append(bio.getvalue())
lx = lx + sx
lx = 0
ly = ly + sy
return media
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(GriderMod())
@loader.tds
class GriderMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Griding"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def gridcmd(self, message):
""".gird <reply to photo>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
await message.edit("Режу ебать")
file = await self.client.download_media(data, bytes)
media = await griding(file)
await message.delete()
await message.client.send_file(message.to_id, media)
@loader.sudo
async def revgridcmd(self, message):
""".gird <reply to photo>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
await message.edit("Режу ебать")
file = await self.client.download_media(data, bytes)
media = await griding(file)
media = media[::-1]
await message.delete()
await message.client.send_file(message.to_id, media)
async def griding(file):
img = Image.open(io.BytesIO(file))
(x, y) = img.size
cy = 3
cx = 3
sx = x//cx
sy = y//cy
if (sx*cx, sy*cy) != (x, y):
img = img.resize((sx*cx, sy*cy))
(lx, ly) = (0, 0)
media = []
for i in range(1, cy+1):
for o in range(1, cx+1):
mimg = img.crop((lx, ly, lx+sx, ly+sy))
bio = io.BytesIO()
bio.name = 'image.png'
mimg.save(bio, 'PNG')
media.append(bio.getvalue())
lx = lx + sx
lx = 0
ly = ly + sy
return media
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,11 +1,11 @@
from .. import loader
from asyncio import sleep
@loader.tds
class HeartsMod(loader.Module):
strings = {"name": "Heart's"}
@loader.owner
async def heartscmd(self, message):
for _ in range(10):
for heart in ['', '️🧡', '💛', '💚', '💙', '💜']:
await message.edit(heart)
from .. import loader
from asyncio import sleep
@loader.tds
class HeartsMod(loader.Module):
strings = {"name": "Heart's"}
@loader.owner
async def heartscmd(self, message):
for _ in range(10):
for heart in ['', '️🧡', '💛', '💚', '💙', '💜']:
await message.edit(heart)
await sleep(0.3)

View File

@@ -1,109 +1,109 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(Ебал_я_в_рот_ваш_пеп_8_Mod())
@loader.tds
class Ебал_я_в_рот_ваш_пеп_8_Mod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Хуификатор"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def хуйcmd(self, message):
text = utils.get_args(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text.split()
async def huify(word):
word = word.lower().strip()
vowels = 'аеёиоуыэюя'
rules = {
'а': 'я',
'о': 'ё',
'у': 'ю',
'ы': 'и',
'э': 'е',
}
for letter in word:
if letter in vowels:
if letter in rules:
word = rules[letter] + word[1:]
break
else:
word = word[1:]
return 'Ху' + word if word else 'Хуй'
out = []
for word in text:
хуй = await huify(word)
out.append(хуй)
await message.edit(" ".join(out))
async def хуйняcmd(self, message):
text = utils.get_args(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text.split()
async def huify(word):
word = word.lower().strip()
vowels = 'аеёиоуыэюя'
rules = {
'а': 'я',
'о': 'ё',
'у': 'ю',
'ы': 'и',
'э': 'е',
}
for letter in word:
if letter in vowels:
if letter in rules:
word = rules[letter] + word[1:]
break
else:
word = word[1:]
return 'Ху' + word if word else 'Хуй'
out = []
for word in text:
хуй = await huify(word)
out.append(f"{word}-{хуй}")
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(Ебал_я_в_рот_ваш_пеп_8_Mod())
@loader.tds
class Ебал_я_в_рот_ваш_пеп_8_Mod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Хуификатор"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def хуйcmd(self, message):
text = utils.get_args(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text.split()
async def huify(word):
word = word.lower().strip()
vowels = 'аеёиоуыэюя'
rules = {
'а': 'я',
'о': 'ё',
'у': 'ю',
'ы': 'и',
'э': 'е',
}
for letter in word:
if letter in vowels:
if letter in rules:
word = rules[letter] + word[1:]
break
else:
word = word[1:]
return 'Ху' + word if word else 'Хуй'
out = []
for word in text:
хуй = await huify(word)
out.append(хуй)
await message.edit(" ".join(out))
async def хуйняcmd(self, message):
text = utils.get_args(message)
if not text:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
text = reply.raw_text.split()
async def huify(word):
word = word.lower().strip()
vowels = 'аеёиоуыэюя'
rules = {
'а': 'я',
'о': 'ё',
'у': 'ю',
'ы': 'и',
'э': 'е',
}
for letter in word:
if letter in vowels:
if letter in rules:
word = rules[letter] + word[1:]
break
else:
word = word[1:]
return 'Ху' + word if word else 'Хуй'
out = []
for word in text:
хуй = await huify(word)
out.append(f"{word}-{хуй}")
await message.edit(" ".join(out))

View File

@@ -1,93 +1,93 @@
import asyncio
import logging
from PIL import Image, ImageDraw, ImageFont, ImageOps
import io
from requests import get
from string import digits
from random import choice
from .. import loader, utils
logger = logging.getLogger(__name__)
font_ = get("https://github.com/KeyZenD/l/blob/master/mono.otf?raw=true").content
@loader.tds
class Im2BinaryMod(loader.Module):
"""Картинки в текст. что?"""
strings = {"name": "Im2Bin"}
@loader.unrestricted
async def bincmd(self, message):
""".bin <картинка или реплай> + слова (дефолт на рандоме) (не мешает слова)"""
img, words, me = await prepare(message)
if not img:
await message.delete()
return await message.client.send_file(message.chat.id, get("https://thiscatdoesnotexist.com").content, caption=choice(["<b>Тебе картинок мало?</b>"]+[None]*100))
await message.edit("<b>Processing...</b>")
img = await image_to_text(words, img, False)
[await message.delete(), await (await message.get_reply_message()).reply(file=img)] if not me else await message.edit(file=img, text="")
@loader.unrestricted
async def rbincmd(self, message):
""".rbin <картинка или реплай> + слова (дефолт на рандоме) (мешает слова)"""
img, words, me = await prepare(message)
if not img:
await message.delete()
return await message.client.send_file(message.chat.id, get("https://thiscatdoesnotexist.com").content, caption=choice(["<b>Тебе картинок мало?</b>"]+[None]*100))
await message.edit("<b>Processing...</b>")
img = await image_to_text(words, img, True)
[await message.delete(), await (await message.get_reply_message()).reply(file=img)] if not me else await message.edit(file=img, text="")
async def getimg(m):
if not m.file:
return False
if not "image" in m.file.mime_type.lower():
return False
return True
async def prepare(message):
if not await getimg(message):
reply = await message.get_reply_message()
if not reply or not await getimg(reply):
return False, False, False
else:
me = False
img = await reply.download_media(bytes)
else:
me = True
img = await message.download_media(bytes)
args = utils.get_args(message)
words = [f"{x} " for x in args] if args else list("01")
return img, words, me
async def image_to_text(words, img, rand):
inp = Image.open(io.BytesIO(img))
img = Image.new("RGBA", inp.size, "#000")
res = img.copy()
img.paste(inp, (0, 0), inp if inp.mode == "RGBA" else None)
w, h = img.size
font = ImageFont.truetype(io.BytesIO(font_), 15)
mw = min(map(lambda x: font.getsize(x)[0], "".join(words)))
mh = min(map(lambda x: font.getsize(x)[1], "".join(words)))
rand_ = 0
text = []
while len(text)*mh <= h:
row = []
while len("".join(row))*mw <= w:
word = choice(words) if rand else words[rand_%len(words)]
rand_ += 1
row.append(word)
rand_ -= 1
text.append("".join(row))
text = "\n".join(text)
wt, ht = ImageDraw.Draw(Image.new("L", (0, 0))).multiline_textsize(font=font, text=text, spacing=0)
im = Image.new("L", (wt, ht), 0)
ImageDraw.Draw(im).multiline_text((0, -3), font=font, text=text, spacing=0, fill=255)
im = im.crop((0, 0, w, h))
im = Image.frombytes("L", (w, h), bytes([255 if x > 150 else 0 for x in im.tobytes()]))
img.putalpha(im)
res.paste(img, (0, 0), img)
out = io.BytesIO()
out.name = words[0] + ".png"
res.save(out)
out.seek(0)
return out
import asyncio
import logging
from PIL import Image, ImageDraw, ImageFont, ImageOps
import io
from requests import get
from string import digits
from random import choice
from .. import loader, utils
logger = logging.getLogger(__name__)
font_ = get("https://github.com/KeyZenD/l/blob/master/mono.otf?raw=true").content
@loader.tds
class Im2BinaryMod(loader.Module):
"""Картинки в текст. что?"""
strings = {"name": "Im2Bin"}
@loader.unrestricted
async def bincmd(self, message):
""".bin <картинка или реплай> + слова (дефолт на рандоме) (не мешает слова)"""
img, words, me = await prepare(message)
if not img:
await message.delete()
return await message.client.send_file(message.chat.id, get("https://thiscatdoesnotexist.com").content, caption=choice(["<b>Тебе картинок мало?</b>"]+[None]*100))
await message.edit("<b>Processing...</b>")
img = await image_to_text(words, img, False)
[await message.delete(), await (await message.get_reply_message()).reply(file=img)] if not me else await message.edit(file=img, text="")
@loader.unrestricted
async def rbincmd(self, message):
""".rbin <картинка или реплай> + слова (дефолт на рандоме) (мешает слова)"""
img, words, me = await prepare(message)
if not img:
await message.delete()
return await message.client.send_file(message.chat.id, get("https://thiscatdoesnotexist.com").content, caption=choice(["<b>Тебе картинок мало?</b>"]+[None]*100))
await message.edit("<b>Processing...</b>")
img = await image_to_text(words, img, True)
[await message.delete(), await (await message.get_reply_message()).reply(file=img)] if not me else await message.edit(file=img, text="")
async def getimg(m):
if not m.file:
return False
if not "image" in m.file.mime_type.lower():
return False
return True
async def prepare(message):
if not await getimg(message):
reply = await message.get_reply_message()
if not reply or not await getimg(reply):
return False, False, False
else:
me = False
img = await reply.download_media(bytes)
else:
me = True
img = await message.download_media(bytes)
args = utils.get_args(message)
words = [f"{x} " for x in args] if args else list("01")
return img, words, me
async def image_to_text(words, img, rand):
inp = Image.open(io.BytesIO(img))
img = Image.new("RGBA", inp.size, "#000")
res = img.copy()
img.paste(inp, (0, 0), inp if inp.mode == "RGBA" else None)
w, h = img.size
font = ImageFont.truetype(io.BytesIO(font_), 15)
mw = min(map(lambda x: font.getsize(x)[0], "".join(words)))
mh = min(map(lambda x: font.getsize(x)[1], "".join(words)))
rand_ = 0
text = []
while len(text)*mh <= h:
row = []
while len("".join(row))*mw <= w:
word = choice(words) if rand else words[rand_%len(words)]
rand_ += 1
row.append(word)
rand_ -= 1
text.append("".join(row))
text = "\n".join(text)
wt, ht = ImageDraw.Draw(Image.new("L", (0, 0))).multiline_textsize(font=font, text=text, spacing=0)
im = Image.new("L", (wt, ht), 0)
ImageDraw.Draw(im).multiline_text((0, -3), font=font, text=text, spacing=0, fill=255)
im = im.crop((0, 0, w, h))
im = Image.frombytes("L", (w, h), bytes([255 if x > 150 else 0 for x in im.tobytes()]))
img.putalpha(im)
res.paste(img, (0, 0), img)
out = io.BytesIO()
out.name = words[0] + ".png"
res.save(out)
out.seek(0)
return out

View File

@@ -1,48 +1,48 @@
from PIL import Image
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
import io
@borg.on(admin_cmd(pattern=".jpeg?(.*)", allow_sudo=True))
async def shacal(event):
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.delete()
return
else:
await event.delete()
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
fried_io = io.BytesIO()
fried_io.name = "image.jpeg"
image = image.convert("RGB")
image.save(fried_io, "JPEG", quality=0)
fried_io.seek(0)
await event.delete()
await event.client.send_file(event.chat_id, fried_io, reply_to=reply_message.id)
from PIL import Image
from telethon.tl.types import DocumentAttributeFilename
from uniborg.util import admin_cmd
import io
@borg.on(admin_cmd(pattern=".jpeg?(.*)", allow_sudo=True))
async def shacal(event):
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data
if event.is_reply:
reply_message = await event.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await event.delete()
return
else:
await event.delete()
return
image = io.BytesIO()
await event.client.download_media(data, image)
image = Image.open(image)
fried_io = io.BytesIO()
fried_io.name = "image.jpeg"
image = image.convert("RGB")
image.save(fried_io, "JPEG", quality=0)
fried_io.seek(0)
await event.delete()
await event.client.send_file(event.chat_id, fried_io, reply_to=reply_message.id)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,23 +1,23 @@
from .. import loader, utils
from asyncio import sleep
from telethon.tl.functions.channels import LeaveChannelRequest
@loader.tds
class LeaveMod(loader.Module):
strings = {"name": "Just leave"}
@loader.sudo
async def leavecmd(self, message):
""".leave"""
if not message.chat:
await message.edit("<b>Дурка блять</b>")
return
text = utils.get_args_raw(message)
if not text:
text = "До связи."
if text.lower() == "del":
await message.delete()
else:
await message.edit(f"<b>{text}</b>")
await sleep(1)
await message.client(LeaveChannelRequest(message.chat_id))
from .. import loader, utils
from asyncio import sleep
from telethon.tl.functions.channels import LeaveChannelRequest
@loader.tds
class LeaveMod(loader.Module):
strings = {"name": "Just leave"}
@loader.sudo
async def leavecmd(self, message):
""".leave"""
if not message.chat:
await message.edit("<b>Дурка блять</b>")
return
text = utils.get_args_raw(message)
if not text:
text = "До связи."
if text.lower() == "del":
await message.delete()
else:
await message.edit(f"<b>{text}</b>")
await sleep(1)
await message.client(LeaveChannelRequest(message.chat_id))

View File

@@ -1,61 +1,61 @@
from .. import loader, utils
import asyncio
import requests
from telethon.tl.types import DocumentAttributeFilename
def register(cb):
cb(UploadPHMod())
# @KeyZenD pls sub :3
class UploadPHMod(loader.Module):
"""Upload video and photo to telegra.ph"""
strings = {"name": "UploadPH"}
def __init__(self):
self.name = self.strings['name']
async def phcmd(self, message):
""".ph <reply photo or video>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await message.edit("<b>Reply to photo or video/gif</b>")
return
else:
await message.edit("<b>Reply to photo or video/gif</b>")
return
file = await message.client.download_media(data, bytes)
path = requests.post('https://te.legra.ph/upload', files={'file': ('file', file, None)}).json()
try:
link = 'https://te.legra.ph'+path[0]['src']
except KeyError:
link = path["error"]
await message.edit("<b>"+link+"</b>")
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data
from .. import loader, utils
import asyncio
import requests
from telethon.tl.types import DocumentAttributeFilename
def register(cb):
cb(UploadPHMod())
# @KeyZenD pls sub :3
class UploadPHMod(loader.Module):
"""Upload video and photo to telegra.ph"""
strings = {"name": "UploadPH"}
def __init__(self):
self.name = self.strings['name']
async def phcmd(self, message):
""".ph <reply photo or video>"""
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await message.edit("<b>Reply to photo or video/gif</b>")
return
else:
await message.edit("<b>Reply to photo or video/gif</b>")
return
file = await message.client.download_media(data, bytes)
path = requests.post('https://te.legra.ph/upload', files={'file': ('file', file, None)}).json()
try:
link = 'https://te.legra.ph'+path[0]['src']
except KeyError:
link = path["error"]
await message.edit("<b>"+link+"</b>")
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,125 +1,125 @@
from telethon import events
from telethon.errors.rpcerrorlist import YouBlockedUserError
from .. import loader, utils
import string
import random
from PIL import Image
import io
from asyncio import sleep
def register(cb):
cb(pic2packMod())
class pic2packMod(loader.Module):
"""pic2pack"""
strings = {'name': 'pic2pack'}
def __init__(self):
self.name = self.strings['name']
self._me = None
self._ratelimit = []
async def client_ready(self, client, db):
self._db = db
self._client = client
self.me = await client.get_me()
async def pic2packcmd(self, message):
""".pic2pack {packname} + <reply to photo>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to photo❗</b>")
return
args = utils.get_args_raw(message)
if not args:
await message.edit("<b>Packname</b>❓")
return
chat = '@Stickers'
name = "".join([random.choice(list(string.ascii_lowercase+string.ascii_uppercase)) for _ in range(16)])
emoji = "▫️"
image = io.BytesIO()
await message.client.download_file(reply, image)
image = Image.open(image)
w, h = image.size
www = max(w, h)
await message.edit("🔪<b>Cropping...</b>")
img = Image.new("RGBA", (www,www), (0,0,0,0))
img.paste(image, ((www-w)//2, 0))
face = img.resize((100,100))
fface = io.BytesIO()
fface.name = name+".png"
images = await cropping(img)
face.save(fface)
fface.seek(0)
await message.edit("<b>📤Uploading...</b>")
async with message.client.conversation(chat) as conv:
try:
x = await message.client.send_message(chat, "/cancel")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, "/newpack")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, args)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
for im in images:
blank = io.BytesIO(im)
blank.name = name+".png"
blank.seek(0)
x = await message.client.send_file(chat, blank, force_document=True)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, emoji)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, "/publish")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_file(chat, fface, force_document=True)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, name)
ending = await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))
await x.delete()
await ending.delete()
for part in ending.raw_text.split():
if part.startswith("https://t.me/"):
break
await message.edit('✅<b>Uploaded successful!</b>\n'+part)
except YouBlockedUserError:
await message.edit('<b>@Stickers BLOCKED⛔</b>')
return
async def cropping(img):
(x, y) = img.size
cy = 5
cx = 5
sx = x//cx
sy = y//cy
if (sx*cx, sy*cy) != (x, y):
img = img.resize((sx*cx, sy*cy))
(lx, ly) = (0, 0)
media = []
for i in range(1, cy+1):
for o in range(1, cx+1):
mimg = img.crop((lx, ly, lx+sx, ly+sy))
mimg = mimg.resize((512,512))
bio = io.BytesIO()
bio.name = 'image.png'
mimg.save(bio, 'PNG')
media.append(bio.getvalue())
lx = lx + sx
lx = 0
ly = ly + sy
from telethon import events
from telethon.errors.rpcerrorlist import YouBlockedUserError
from .. import loader, utils
import string
import random
from PIL import Image
import io
from asyncio import sleep
def register(cb):
cb(pic2packMod())
class pic2packMod(loader.Module):
"""pic2pack"""
strings = {'name': 'pic2pack'}
def __init__(self):
self.name = self.strings['name']
self._me = None
self._ratelimit = []
async def client_ready(self, client, db):
self._db = db
self._client = client
self.me = await client.get_me()
async def pic2packcmd(self, message):
""".pic2pack {packname} + <reply to photo>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>Reply to photo❗</b>")
return
args = utils.get_args_raw(message)
if not args:
await message.edit("<b>Packname</b>❓")
return
chat = '@Stickers'
name = "".join([random.choice(list(string.ascii_lowercase+string.ascii_uppercase)) for _ in range(16)])
emoji = "▫️"
image = io.BytesIO()
await message.client.download_file(reply, image)
image = Image.open(image)
w, h = image.size
www = max(w, h)
await message.edit("🔪<b>Cropping...</b>")
img = Image.new("RGBA", (www,www), (0,0,0,0))
img.paste(image, ((www-w)//2, 0))
face = img.resize((100,100))
fface = io.BytesIO()
fface.name = name+".png"
images = await cropping(img)
face.save(fface)
fface.seek(0)
await message.edit("<b>📤Uploading...</b>")
async with message.client.conversation(chat) as conv:
try:
x = await message.client.send_message(chat, "/cancel")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, "/newpack")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, args)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
for im in images:
blank = io.BytesIO(im)
blank.name = name+".png"
blank.seek(0)
x = await message.client.send_file(chat, blank, force_document=True)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, emoji)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, "/publish")
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_file(chat, fface, force_document=True)
await (await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))).delete()
await x.delete()
x = await message.client.send_message(chat, name)
ending = await conv.wait_event(events.NewMessage(incoming=True, from_users=chat))
await x.delete()
await ending.delete()
for part in ending.raw_text.split():
if part.startswith("https://t.me/"):
break
await message.edit('✅<b>Uploaded successful!</b>\n'+part)
except YouBlockedUserError:
await message.edit('<b>@Stickers BLOCKED⛔</b>')
return
async def cropping(img):
(x, y) = img.size
cy = 5
cx = 5
sx = x//cx
sy = y//cy
if (sx*cx, sy*cy) != (x, y):
img = img.resize((sx*cx, sy*cy))
(lx, ly) = (0, 0)
media = []
for i in range(1, cy+1):
for o in range(1, cx+1):
mimg = img.crop((lx, ly, lx+sx, ly+sy))
mimg = mimg.resize((512,512))
bio = io.BytesIO()
bio.name = 'image.png'
mimg.save(bio, 'PNG')
media.append(bio.getvalue())
lx = lx + sx
lx = 0
ly = ly + sy
return media

View File

@@ -1,23 +1,23 @@
from .. import loader, utils
from asyncio import sleep
@loader.tds
class PrintMod(loader.Module):
"""Аналог модуля typewriter"""
strings = {"name": "print"}
@loader.owner
async def printcmd(self, message):
""".print <text or reply>"""
text = utils.get_args_raw(message)
if not text:
reply = await message.get_reply_message()
if not reply or not reply.message:
await message.edit("<b>Текста нет!</b>")
return
text = reply.message
out = ""
for ch in text:
out += ch
if ch not in [" ", "\n"]:
await message.edit(out+"\u2060")
await sleep(0.3)
from .. import loader, utils
from asyncio import sleep
@loader.tds
class PrintMod(loader.Module):
"""Аналог модуля typewriter"""
strings = {"name": "print"}
@loader.owner
async def printcmd(self, message):
""".print <text or reply>"""
text = utils.get_args_raw(message)
if not text:
reply = await message.get_reply_message()
if not reply or not reply.message:
await message.edit("<b>Текста нет!</b>")
return
text = reply.message
out = ""
for ch in text:
out += ch
if ch not in [" ", "\n"]:
await message.edit(out+"\u2060")
await sleep(0.3)

View File

@@ -1,43 +1,43 @@
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import logging
import pygments
from pygments.lexers import Python3Lexer
from pygments.formatters import ImageFormatter
import os
logger = logging.getLogger(__name__)
def register(cb):
cb(py2pngMod())
@loader.tds
class py2pngMod(loader.Module):
"""Uploader"""
strings = {
"name": "pypng"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def pypngcmd(self, message):
"""reply to text code or py file"""
await message.edit("<b>Py to PNG</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>reply to file.py</b>")
return
media = reply.media
if not media:
await message.edit("<b>reply to file.py</b>")
return
file = await message.client.download_file(media)
text = file.decode('utf-8')
pygments.highlight(text, Python3Lexer(), ImageFormatter(font_name='DejaVu Sans Mono', line_numbers=True), 'out.png')
await message.client.send_file(message.to_id, 'out.png', force_document=True)
os.remove("out.png")
await message.delete()
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import logging
import pygments
from pygments.lexers import Python3Lexer
from pygments.formatters import ImageFormatter
import os
logger = logging.getLogger(__name__)
def register(cb):
cb(py2pngMod())
@loader.tds
class py2pngMod(loader.Module):
"""Uploader"""
strings = {
"name": "pypng"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def pypngcmd(self, message):
"""reply to text code or py file"""
await message.edit("<b>Py to PNG</b>")
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>reply to file.py</b>")
return
media = reply.media
if not media:
await message.edit("<b>reply to file.py</b>")
return
file = await message.client.download_file(media)
text = file.decode('utf-8')
pygments.highlight(text, Python3Lexer(), ImageFormatter(font_name='DejaVu Sans Mono', line_numbers=True), 'out.png')
await message.client.send_file(message.to_id, 'out.png', force_document=True)
os.remove("out.png")
await message.delete()

View File

@@ -1,24 +1,24 @@
import io
from .. import loader, utils
@loader.tds
class SavedMod(loader.Module):
"""Соxранятель в избранное"""
strings = {"name": "SavedMessages", "to":"me"}
@loader.unrestricted
async def savedcmd(self, message):
""".saved реплай на медиа"""
await message.delete()
reply = await message.get_reply_message()
name = utils.get_args_raw(message)
if not reply or not reply.file:
return
media = reply.media
if media.ttl_seconds or name:
file = await reply.download_media(bytes)
file = io.BytesIO(file)
file.name = name or str(reply.sender_id) + reply.file.ext
file.seek(0)
await message.client.send_file(self.strings["to"], file)
else:
await reply.forward_to(self.strings["to"])
import io
from .. import loader, utils
@loader.tds
class SavedMod(loader.Module):
"""Соxранятель в избранное"""
strings = {"name": "SavedMessages", "to":"me"}
@loader.unrestricted
async def savedcmd(self, message):
""".saved реплай на медиа"""
await message.delete()
reply = await message.get_reply_message()
name = utils.get_args_raw(message)
if not reply or not reply.file:
return
media = reply.media
if media.ttl_seconds or name:
file = await reply.download_media(bytes)
file = io.BytesIO(file)
file.name = name or str(reply.sender_id) + reply.file.ext
file.seek(0)
await message.client.send_file(self.strings["to"], file)
else:
await reply.forward_to(self.strings["to"])

View File

@@ -1,106 +1,106 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(SoaperMod())
@loader.tds
class SoaperMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Soaping"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def soapcmd(self, message):
""".soap <reply to photo>"""
soap = 3
a = utils.get_args(message)
if a:
if a[0].isdigit():
soap = int(a[0])
if soap <= 0:
soap = 3
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Reply to pic or stick!</code>")
return
else:
await utils.answer(message, "<code>Reply to pic or stick!</code>")
return
await message.edit("Soaping...")
file = await self.client.download_media(data, bytes)
media = await Soaping(file, soap)
await message.delete()
await message.client.send_file(message.to_id, media)
async def Soaping(file, soap):
img = Image.open(io.BytesIO(file))
(x, y) = img.size
img = img.resize((x//soap, y//soap), Image.ANTIALIAS)
img = img.resize((x, y))
soap_io = io.BytesIO()
soap_io.name = "image.jpeg"
img = img.convert("RGB")
img.save(soap_io, "JPEG", quality=100)
soap_io.seek(0)
return soap_io
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# если не подписан на t.me/keyzend
# твоя мама шлюха
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(SoaperMod())
@loader.tds
class SoaperMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Soaping"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def soapcmd(self, message):
""".soap <reply to photo>"""
soap = 3
a = utils.get_args(message)
if a:
if a[0].isdigit():
soap = int(a[0])
if soap <= 0:
soap = 3
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Reply to pic or stick!</code>")
return
else:
await utils.answer(message, "<code>Reply to pic or stick!</code>")
return
await message.edit("Soaping...")
file = await self.client.download_media(data, bytes)
media = await Soaping(file, soap)
await message.delete()
await message.client.send_file(message.to_id, media)
async def Soaping(file, soap):
img = Image.open(io.BytesIO(file))
(x, y) = img.size
img = img.resize((x//soap, y//soap), Image.ANTIALIAS)
img = img.resize((x, y))
soap_io = io.BytesIO()
soap_io.name = "image.jpeg"
img = img.convert("RGB")
img.save(soap_io, "JPEG", quality=100)
soap_io.seek(0)
return soap_io
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,123 +1,123 @@
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(SpinnerMod())
@loader.tds
class SpinnerMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Spinner"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def spincmd(self, message):
"""you spin me round..."""
args = utils.get_args(message)
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
image = io.BytesIO()
await self.client.download_media(data, image)
image = Image.open(image)
image.thumbnail((512, 512), Image.ANTIALIAS)
img = Image.new("RGB", (512, 512), "black")
img.paste(image, ((512-image.width)//2, (512-image.height)//2))
image = img
way = random.choice([1, -1])
frames = []
for i in range(1, 60):
im = image.rotate(i*6*way)
frames.append(im)
frames.remove(im)
image_stream = io.BytesIO()
image_stream.name = "spin.gif"
im.save(image_stream, "GIF", save_all=True, append_images=frames, duration = 10)
image_stream.seek(0)
await utils.answer(message, image_stream)
@loader.sudo
async def epilepsycmd(self, message):
"""ПРИВЕТ ЭПИЛЕТИКИ АХАХАХХА"""
args = utils.get_args(message)
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
image = io.BytesIO()
await self.client.download_media(data, image)
image = Image.open(image).convert("RGB")
invert = ImageOps.invert(image)
image_stream = io.BytesIO()
image_stream.name = "epilepsy.gif"
image.save(image_stream, "GIF", save_all=True, append_images=[invert], duration = 1)
image_stream.seek(0)
await utils.answer(message, image_stream)
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
# -*- coding: utf-8 -*-
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2020 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils # pylint: disable=relative-beyond-top-level
import io
from PIL import Image, ImageOps
from telethon.tl.types import DocumentAttributeFilename
import logging
import random
logger = logging.getLogger(__name__)
def register(cb):
cb(SpinnerMod())
@loader.tds
class SpinnerMod(loader.Module):
"""Гавно залупное"""
strings = {
"name": "Spinner"
}
async def client_ready(self, client, db):
self.client = client
@loader.sudo
async def spincmd(self, message):
"""you spin me round..."""
args = utils.get_args(message)
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
image = io.BytesIO()
await self.client.download_media(data, image)
image = Image.open(image)
image.thumbnail((512, 512), Image.ANTIALIAS)
img = Image.new("RGB", (512, 512), "black")
img.paste(image, ((512-image.width)//2, (512-image.height)//2))
image = img
way = random.choice([1, -1])
frames = []
for i in range(1, 60):
im = image.rotate(i*6*way)
frames.append(im)
frames.remove(im)
image_stream = io.BytesIO()
image_stream.name = "spin.gif"
im.save(image_stream, "GIF", save_all=True, append_images=frames, duration = 10)
image_stream.seek(0)
await utils.answer(message, image_stream)
@loader.sudo
async def epilepsycmd(self, message):
"""ПРИВЕТ ЭПИЛЕТИКИ АХАХАХХА"""
args = utils.get_args(message)
if message.is_reply:
reply_message = await message.get_reply_message()
data = await check_media(reply_message)
if isinstance(data, bool):
await utils.answer(message, "<code>Реплай на пикчу или стикер блять!</code>")
return
else:
await utils.answer(message, "`Реплай на пикчу или стикер блять`")
return
image = io.BytesIO()
await self.client.download_media(data, image)
image = Image.open(image).convert("RGB")
invert = ImageOps.invert(image)
image_stream = io.BytesIO()
image_stream.name = "epilepsy.gif"
image.save(image_stream, "GIF", save_all=True, append_images=[invert], duration = 1)
image_stream.seek(0)
await utils.answer(message, image_stream)
async def check_media(reply_message):
if reply_message and reply_message.media:
if reply_message.photo:
data = reply_message.photo
elif reply_message.document:
if DocumentAttributeFilename(file_name='AnimatedSticker.tgs') in reply_message.media.document.attributes:
return False
if reply_message.gif or reply_message.video or reply_message.audio or reply_message.voice:
return False
data = reply_message.media.document
else:
return False
else:
return False
if not data or data is None:
return False
else:
return data

View File

@@ -1,63 +1,63 @@
from .. import loader, utils
import io
import logging
import requests
from textwrap import wrap
from PIL import Image, ImageDraw, ImageFont
bytes_font = requests.get("https://github.com/KeyZenD/l/blob/master/bold.ttf?raw=true").content
logger = logging.getLogger(__name__)
def register(cb):
cb(Text2stickMod())
@loader.tds
class Text2stickMod(loader.Module):
"""Text to sticker"""
strings = {"name": "StickText"}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def stextcmd(self, message):
""".stext <reply to photo>"""
await message.delete()
text = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not text:
if not reply:
text = "#ffffff .stext <text or reply>"
elif not reply.message:
text = "#ffffff .stext <text or reply>"
else:
text = reply.raw_text
color = text.split(" ", 1)[0]
if color.startswith("#") and len(color) == 7:
for ch in color.lower()[1:]:
if ch not in "0123456789abcdef":
break
if len(text.split(" ", 1)) > 1:
text = text.split(" ", 1)[1]
else:
if reply:
if reply.message:
text = reply.raw_text
else:
color = "#FFFFFF"
txt = []
for line in text.split("\n"):
txt.append("\n".join(wrap(line, 30)))
text = "\n".join(txt)
font = io.BytesIO(bytes_font)
font = ImageFont.truetype(font, 100)
image = Image.new("RGBA", (1, 1), (0,0,0,0))
draw = ImageDraw.Draw(image)
w, h = draw.multiline_textsize(text=text, font=font)
image = Image.new("RGBA", (w+100, h+100), (0,0,0,0))
draw = ImageDraw.Draw(image)
draw.multiline_text((50,50), text=text, font=font, fill=color, align="center")
output = io.BytesIO()
output.name = color+".webp"
image.save(output, "WEBP")
output.seek(0)
await self.client.send_file(message.to_id, output, reply_to=reply)
from .. import loader, utils
import io
import logging
import requests
from textwrap import wrap
from PIL import Image, ImageDraw, ImageFont
bytes_font = requests.get("https://github.com/KeyZenD/l/blob/master/bold.ttf?raw=true").content
logger = logging.getLogger(__name__)
def register(cb):
cb(Text2stickMod())
@loader.tds
class Text2stickMod(loader.Module):
"""Text to sticker"""
strings = {"name": "StickText"}
async def client_ready(self, client, db):
self.client = client
@loader.owner
async def stextcmd(self, message):
""".stext <reply to photo>"""
await message.delete()
text = utils.get_args_raw(message)
reply = await message.get_reply_message()
if not text:
if not reply:
text = "#ffffff .stext <text or reply>"
elif not reply.message:
text = "#ffffff .stext <text or reply>"
else:
text = reply.raw_text
color = text.split(" ", 1)[0]
if color.startswith("#") and len(color) == 7:
for ch in color.lower()[1:]:
if ch not in "0123456789abcdef":
break
if len(text.split(" ", 1)) > 1:
text = text.split(" ", 1)[1]
else:
if reply:
if reply.message:
text = reply.raw_text
else:
color = "#FFFFFF"
txt = []
for line in text.split("\n"):
txt.append("\n".join(wrap(line, 30)))
text = "\n".join(txt)
font = io.BytesIO(bytes_font)
font = ImageFont.truetype(font, 100)
image = Image.new("RGBA", (1, 1), (0,0,0,0))
draw = ImageDraw.Draw(image)
w, h = draw.multiline_textsize(text=text, font=font)
image = Image.new("RGBA", (w+100, h+100), (0,0,0,0))
draw = ImageDraw.Draw(image)
draw.multiline_text((50,50), text=text, font=font, fill=color, align="center")
output = io.BytesIO()
output.name = color+".webp"
image.save(output, "WEBP")
output.seek(0)
await self.client.send_file(message.to_id, output, reply_to=reply)

View File

@@ -1,52 +1,52 @@
from .. import loader, utils
import logging
logger = logging.getLogger(__name__)
def register(cb):
cb(TagallMod())
@loader.tds
class TagallMod(loader.Module):
"""Tagall"""
strings = {
"name": "TagAll", "subscribe to": "https://t.me/KeyZenD"
}
async def client_ready(self, client, db):
self.client = client
def __init__(self):
self.name = self.strings['name']
@loader.sudo
async def tagallcmd(self, message):
args = utils.get_args(message)
tag_ = 5
notext = False
if args:
if args[0].isdigit():
tag_ = int(args[0])
if len(args) > 1:
notext = True
text = " ".join(args[1:])
await message.delete()
all = message.client.iter_participants(message.to_id)
chunk = []
async for user in all:
if not user.deleted:
name = f"{user.first_name} {user.last_name}" if user.last_name else user.first_name
name = name.replace("<","&lt;").replace(">","&gt;")
name = name[:30]+"..." if len(name) > 33 else name
tag = f'<a href="tg://user?id={user.id}">{name}</a>' if not notext else f'<a href="tg://user?id={user.id}">{text}</a>'
chunk.append(tag)
if len(chunk) == tag_:
await message.client.send_message(message.to_id, "\n".join(chunk))
chunk = []
if len(chunk) != 0:
from .. import loader, utils
import logging
logger = logging.getLogger(__name__)
def register(cb):
cb(TagallMod())
@loader.tds
class TagallMod(loader.Module):
"""Tagall"""
strings = {
"name": "TagAll", "subscribe to": "https://t.me/KeyZenD"
}
async def client_ready(self, client, db):
self.client = client
def __init__(self):
self.name = self.strings['name']
@loader.sudo
async def tagallcmd(self, message):
args = utils.get_args(message)
tag_ = 5
notext = False
if args:
if args[0].isdigit():
tag_ = int(args[0])
if len(args) > 1:
notext = True
text = " ".join(args[1:])
await message.delete()
all = message.client.iter_participants(message.to_id)
chunk = []
async for user in all:
if not user.deleted:
name = f"{user.first_name} {user.last_name}" if user.last_name else user.first_name
name = name.replace("<","&lt;").replace(">","&gt;")
name = name[:30]+"..." if len(name) > 33 else name
tag = f'<a href="tg://user?id={user.id}">{name}</a>' if not notext else f'<a href="tg://user?id={user.id}">{text}</a>'
chunk.append(tag)
if len(chunk) == tag_:
await message.client.send_message(message.to_id, "\n".join(chunk))
chunk = []
if len(chunk) != 0:
await message.client.send_message(message.to_id, "\n".join(chunk))

View File

@@ -1,45 +1,45 @@
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2019 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# SUBSCRIBE TO t.me/keyzend pls
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils
import logging
import asyncio
logger = logging.getLogger(__name__)
@loader.tds
class TickerMod(loader.Module):
"""Makes your messages type slower"""
strings = {"name": "Ticker",
"no_message": "<b>.ticker [any text?]</b>",
"delay_typer_cfg_doc": "How long to delay showing?"}
def __init__(self):
self.config = loader.ModuleConfig("DELAY_TICKER", 0.04, lambda m: self.strings("delay_tikcer_cfg_doc", m))
@loader.ratelimit
async def tickercmd(self, message):
""".ticker <message>"""
a = utils.get_args_raw(message)
if not a:
await utils.answer(message, self.strings("no_message", message))
return
for c in a:
a = a[-1]+a[0:-1]
message = await utils.answer(message, f" {a} ")
# Friendly Telegram (telegram userbot)
# Copyright (C) 2018-2019 The Authors
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# SUBSCRIBE TO t.me/keyzend pls
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from .. import loader, utils
import logging
import asyncio
logger = logging.getLogger(__name__)
@loader.tds
class TickerMod(loader.Module):
"""Makes your messages type slower"""
strings = {"name": "Ticker",
"no_message": "<b>.ticker [any text?]</b>",
"delay_typer_cfg_doc": "How long to delay showing?"}
def __init__(self):
self.config = loader.ModuleConfig("DELAY_TICKER", 0.04, lambda m: self.strings("delay_tikcer_cfg_doc", m))
@loader.ratelimit
async def tickercmd(self, message):
""".ticker <message>"""
a = utils.get_args_raw(message)
if not a:
await utils.answer(message, self.strings("no_message", message))
return
for c in a:
a = a[-1]+a[0:-1]
message = await utils.answer(message, f" {a} ")
await asyncio.sleep(0.3)

View File

@@ -1,31 +1,31 @@
from requests import head,get
from urllib.parse import urlsplit as E,parse_qs as H
import json,io,re
from .. import loader as A,utils
class TikTokDlMod(A.Module):
strings={'name':'TikTokDl'}
async def ttcmd(J,message):
A=message;B=await A.get_reply_message();F=utils.get_args_raw(A);C=lambda x:f"<b>{x}</b>"
if F:D=F
elif B and B.raw_text:D=B.raw_text
else:return await A.edit(C('No url.'))
if'.tiktok.com'not in D:return await A.edit(C('Bad url.'))
await A.edit(C('Loading...'));G,K=await I(D)
try:await A.client.send_file(A.to_id,file=G,reply_to=B);await A.delete()
except:
try:await A.edit(C('DownLoading...'));H=get(G).content;E=io.BytesIO(H);E.name='video.mp4';E.seek(0);await A.client.send_file(A.to_id,file=E,reply_to=B);await A.delete()
except:await A.edit(C('я чёт нихуя не могу загрузить...'))
async def I(url):
A=url
async def F(video_id,_):
A=f"https://api-va.tiktokv.com/aweme/v1/multi/aweme/detail/?aweme_ids=%5B{video_id}%5D";A=get(A);B=A.json().get('aweme_details')
if not B:return 0,0,A
return B,True,A
A=head(A).headers;A=A.get('Location')
try:
I=H(E(A).query);B=I.get('share_item_id')[0];G,C,D=await F(B,1)
if not C:raise
except:
B=''.join(re.findall('[0-9]',E(A).path.split('/')[-1]));G,C,D=await F(B,2)
if not C:return False,D
return G[0]['video']['bit_rate'][0]['play_addr']['url_list'][-1],D
from requests import head,get
from urllib.parse import urlsplit as E,parse_qs as H
import json,io,re
from .. import loader as A,utils
class TikTokDlMod(A.Module):
strings={'name':'TikTokDl'}
async def ttcmd(J,message):
A=message;B=await A.get_reply_message();F=utils.get_args_raw(A);C=lambda x:f"<b>{x}</b>"
if F:D=F
elif B and B.raw_text:D=B.raw_text
else:return await A.edit(C('No url.'))
if'.tiktok.com'not in D:return await A.edit(C('Bad url.'))
await A.edit(C('Loading...'));G,K=await I(D)
try:await A.client.send_file(A.to_id,file=G,reply_to=B);await A.delete()
except:
try:await A.edit(C('DownLoading...'));H=get(G).content;E=io.BytesIO(H);E.name='video.mp4';E.seek(0);await A.client.send_file(A.to_id,file=E,reply_to=B);await A.delete()
except:await A.edit(C('я чёт нихуя не могу загрузить...'))
async def I(url):
A=url
async def F(video_id,_):
A=f"https://api-va.tiktokv.com/aweme/v1/multi/aweme/detail/?aweme_ids=%5B{video_id}%5D";A=get(A);B=A.json().get('aweme_details')
if not B:return 0,0,A
return B,True,A
A=head(A).headers;A=A.get('Location')
try:
I=H(E(A).query);B=I.get('share_item_id')[0];G,C,D=await F(B,1)
if not C:raise
except:
B=''.join(re.findall('[0-9]',E(A).path.split('/')[-1]));G,C,D=await F(B,2)
if not C:return False,D
return G[0]['video']['bit_rate'][0]['play_addr']['url_list'][-1],D

View File

@@ -1,41 +1,41 @@
import asyncio
import logging
from requests import get
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class ValitesMod(loader.Module):
"""Valute converter"""
strings = {"name": "Valutes"}
@loader.unrestricted
async def valutecmd(self, message):
""".valute <Valute char code (optional)>"""
valutes = get("https://www.cbr-xml-daily.ru/daily_json.js").json()
names = valutes["Valute"].keys()
args = utils.get_args(message)
req = []
if args:
for val in args:
val = val.upper()
if val in names:
req.append(val)
valutes["Valute"] = {val: valutes["Valute"][val] for val in req}
text = []
temp = "<b>{}</b>\n{} <code>{}</code>: {}₽ ({}{}₽)"
for val in valutes["Valute"].values():
name = val["Name"]
code = val["CharCode"]
nom = int(val["Nominal"])
now = round(float(val["Value"]), 3)
pre = round(float(val["Previous"]), 3)
way = "🔹" if now == pre else "🔻" if now < pre else "🔺"
text.append(temp.format(name, nom, code, now, way, pre))
if not text:
return await utils.answer(message, "<b>Запрос неверен - ответ пуст!</b>")
await utils.answer(message, "\n".join(text))
import asyncio
import logging
from requests import get
from .. import loader, utils
logger = logging.getLogger(__name__)
@loader.tds
class ValitesMod(loader.Module):
"""Valute converter"""
strings = {"name": "Valutes"}
@loader.unrestricted
async def valutecmd(self, message):
""".valute <Valute char code (optional)>"""
valutes = get("https://www.cbr-xml-daily.ru/daily_json.js").json()
names = valutes["Valute"].keys()
args = utils.get_args(message)
req = []
if args:
for val in args:
val = val.upper()
if val in names:
req.append(val)
valutes["Valute"] = {val: valutes["Valute"][val] for val in req}
text = []
temp = "<b>{}</b>\n{} <code>{}</code>: {}₽ ({}{}₽)"
for val in valutes["Valute"].values():
name = val["Name"]
code = val["CharCode"]
nom = int(val["Nominal"])
now = round(float(val["Value"]), 3)
pre = round(float(val["Previous"]), 3)
way = "🔹" if now == pre else "🔻" if now < pre else "🔺"
text.append(temp.format(name, nom, code, now, way, pre))
if not text:
return await utils.answer(message, "<b>Запрос неверен - ответ пуст!</b>")
await utils.answer(message, "\n".join(text))

View File

@@ -1,48 +1,48 @@
from .. import loader, utils
import logging
from requests import get
import io
logger = logging.getLogger(__name__)
def register(cb):
cb(WebShotMod())
@loader.tds
class WebShotMod(loader.Module):
"""link to screen"""
strings = {
"name": "WebShot"
}
async def client_ready(self, client, db):
self.client = client
def __init__(self):
self.name = self.strings['name']
@loader.sudo
async def webshotcmd(self, message):
reply = None
link = utils.get_args_raw(message)
if not link:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
link = reply.raw_text
await message.edit("<b>S c r e e n s h o t i n g . . .</b>")
url = "https://webshot.deam.io/{}/?width=1920&height=1080?type=png"
file = get(url.format(link))
if not file.ok:
await message.edit("<b>Something went wrong...</b>")
return
file = io.BytesIO(file.content)
file.name = "webshot.png"
file.seek(0)
await message.client.send_file(message.to_id, file, reply_to=reply)
await message.delete()
from .. import loader, utils
import logging
from requests import get
import io
logger = logging.getLogger(__name__)
def register(cb):
cb(WebShotMod())
@loader.tds
class WebShotMod(loader.Module):
"""link to screen"""
strings = {
"name": "WebShot"
}
async def client_ready(self, client, db):
self.client = client
def __init__(self):
self.name = self.strings['name']
@loader.sudo
async def webshotcmd(self, message):
reply = None
link = utils.get_args_raw(message)
if not link:
reply = await message.get_reply_message()
if not reply:
await message.delete()
return
link = reply.raw_text
await message.edit("<b>S c r e e n s h o t i n g . . .</b>")
url = "https://webshot.deam.io/{}/?width=1920&height=1080?type=png"
file = get(url.format(link))
if not file.ok:
await message.edit("<b>Something went wrong...</b>")
return
file = io.BytesIO(file.content)
file.name = "webshot.png"
file.seek(0)
await message.client.send_file(message.to_id, file, reply_to=reply)
await message.delete()

View File

@@ -1,37 +1,37 @@
from .. import loader, utils
from PIL import Image, ImageDraw
from random import randint
from io import BytesIO
@loader.tds
class WhatMod(loader.Module):
"""wow, what is it there?"""
strings = {"name": "What?"}
async def whatcmd(self, message):
"""Draw circle in random place"""
args = utils.get_args_raw(message)
scale = int(args) if args and args.isdigit() else 50
scale = 10 if scale < 0 else scale
scale = 100 if scale > 100 else scale
reply = await message.get_reply_message()
if not reply or not reply.file.mime_type.split("/")[0].lower() == "image":
await message.edit("<b>Reply to img!</b>")
return
await message.edit("<b>What is it?</b>")
im = BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
f = (min(w,h)//100)*scale
draw = ImageDraw.Draw(im)
x, y = randint(0, w-f), randint(0, h-f)
draw.ellipse((x, y, x+randint(f//2, f), y+randint(f//2, f)), fill=None, outline="red", width=randint(3, 10))
out = BytesIO()
out.name = "what.png"
im.save(out)
out.seek(0)
await message.delete()
return await reply.reply(file=out)
from .. import loader, utils
from PIL import Image, ImageDraw
from random import randint
from io import BytesIO
@loader.tds
class WhatMod(loader.Module):
"""wow, what is it there?"""
strings = {"name": "What?"}
async def whatcmd(self, message):
"""Draw circle in random place"""
args = utils.get_args_raw(message)
scale = int(args) if args and args.isdigit() else 50
scale = 10 if scale < 0 else scale
scale = 100 if scale > 100 else scale
reply = await message.get_reply_message()
if not reply or not reply.file.mime_type.split("/")[0].lower() == "image":
await message.edit("<b>Reply to img!</b>")
return
await message.edit("<b>What is it?</b>")
im = BytesIO()
await reply.download_media(im)
im = Image.open(im)
w, h = im.size
f = (min(w,h)//100)*scale
draw = ImageDraw.Draw(im)
x, y = randint(0, w-f), randint(0, h-f)
draw.ellipse((x, y, x+randint(f//2, f), y+randint(f//2, f)), fill=None, outline="red", width=randint(3, 10))
out = BytesIO()
out.name = "what.png"
im.save(out)
out.seek(0)
await message.delete()
return await reply.reply(file=out)

View File

@@ -1,111 +1,111 @@
from .. import loader, utils
import os
import urllib.parse
from uuid import uuid4
ztd = 'zip-temp-dir'
@loader.tds
class ZipMod(loader.Module):
'''Запаковывает/распаковывает файлы'''
strings = {'name': 'ZIP'}
@loader.unrestricted
async def zipaddcmd(self, message):
""".zipadd <file/reply to file> - сохраняет файл во временную папку"""
reply = await message.get_reply_message()
event = reply or message
if not event.file:
await message.edit('<b>[ZIP]Добавить что?<b>')
return
if not os.path.exists(ztd):
os.mkdir(ztd)
fn = _fn = event.file.name
if not fn:
date = event.date
kind = event.file.mime_type.split('/')[0]
ext = event.file.ext
fn = _fn = '{}_{}-{:02}-{:02}_{:02}-{:02}-{:02}{}'.format(kind, date.year, date.month, date.day, date.hour, date.minute, date.second, ext)
files = os.listdir(ztd)
copy = 1
while fn in files:
fn = f"({copy}).{_fn}"
copy += 1
await message.edit(f'<b>[ZIP]Загружаю файл \'</b><code>{fn}</code>\'...')
await event.download_media(f'{ztd}/{fn}')
await message.edit(f"<b>[ZIP]Файл \"</b><code>{fn}</code><b>\" загружен!</b>")
@loader.unrestricted
async def ziplistcmd(self, message):
"""список сохраненных файлов"""
if not os.path.exists(ztd):
await message.edit('<b>[ZIP]В папке пусто!</b>')
return
files = os.listdir(ztd)
files = '\n'.join([f'<a href="tg://msg?text=.zipshow+{urllib.parse.quote(fn)}">{num+1})</a> <code>{fn}</code>' for num, fn in enumerate(files)])
await message.edit('<b>[ZIP]Список файлов:</b>\n'+files)
@loader.unrestricted
async def zipshowcmd(self, message):
""".zipshow <name> - показывает сохранённый файл"""
if not os.path.exists(ztd):
await message.edit('<b>[ZIP]В папке пусто!</b>')
return
files = os.listdir(ztd)
file = utils.get_args_raw(message)
if not file:
await message.edit('<b>[ZIP]Пустой запрос!</b>')
return
if file not in files:
await message.edit('<b>[ZIP]Такого файла нет!</b>')
return
await message.edit(f"<b>[ZIP]Отправляю \"</b><code>{file}</code><b>\"...")
await message.respond(file=ztd+"/"+file)
await message.delete()
@loader.unrestricted
async def zipdelcmd(self, message):
""".zipdel <name> - удаляет сохранённый файл"""
file = utils.get_args_raw(message)
try:
os.remove(ztd+"/"+file)
except FileNotFoundError:
await message.edit("<b>[ZIP]Такого файла нет!</b>")
return
await message.edit(f"<b>[ZIP]Файл \"</b><code>{file}</code><b>\" удалён!</b>")
@loader.unrestricted
async def zipcmd(self, message):
""".zip <name> (-s) - пакует в архив name. если есть флаг -s то сохраняет папку с фацлами"""
if not os.path.exists(ztd):
await message.edit("<b>[ZIP]Файлов для запаковки не найдено!</b>")
return
name = utils.get_args_raw(message)
save = False
if "-s" in name:
save = True
name = name.replace("-s","").strip()
if not name:
name = str(uuid4()).split("-")[-1]+".zip"
name = name + (".zip" if ".zip" not in name else "")
await message.edit(f'<b>[ZIP]Запаковываю {len(os.listdir(ztd))} файл(ов) в </b>"<code>{name}</code>"')
os.system(f"zip {name} {ztd}/*")
await message.edit(f'<b>[ZIP]Отправляю </b>"<code>{name}</code>"')
await message.respond(file=open(name, "rb"))
await message.delete()
os.system("rm -rf {name}")
if not save:
os.system("rm -rf zip-temp-dir")
@loader.unrestricted
async def zipcleancmd(self, message):
""".zipclear - очищает папку с файлами"""
os.system("rm -rf zip-temp-dir")
await message.edit('<b>[ZIP]Очищено!</b>')
os.mkdir(ztd)
from .. import loader, utils
import os
import urllib.parse
from uuid import uuid4
ztd = 'zip-temp-dir'
@loader.tds
class ZipMod(loader.Module):
'''Запаковывает/распаковывает файлы'''
strings = {'name': 'ZIP'}
@loader.unrestricted
async def zipaddcmd(self, message):
""".zipadd <file/reply to file> - сохраняет файл во временную папку"""
reply = await message.get_reply_message()
event = reply or message
if not event.file:
await message.edit('<b>[ZIP]Добавить что?<b>')
return
if not os.path.exists(ztd):
os.mkdir(ztd)
fn = _fn = event.file.name
if not fn:
date = event.date
kind = event.file.mime_type.split('/')[0]
ext = event.file.ext
fn = _fn = '{}_{}-{:02}-{:02}_{:02}-{:02}-{:02}{}'.format(kind, date.year, date.month, date.day, date.hour, date.minute, date.second, ext)
files = os.listdir(ztd)
copy = 1
while fn in files:
fn = f"({copy}).{_fn}"
copy += 1
await message.edit(f'<b>[ZIP]Загружаю файл \'</b><code>{fn}</code>\'...')
await event.download_media(f'{ztd}/{fn}')
await message.edit(f"<b>[ZIP]Файл \"</b><code>{fn}</code><b>\" загружен!</b>")
@loader.unrestricted
async def ziplistcmd(self, message):
"""список сохраненных файлов"""
if not os.path.exists(ztd):
await message.edit('<b>[ZIP]В папке пусто!</b>')
return
files = os.listdir(ztd)
files = '\n'.join([f'<a href="tg://msg?text=.zipshow+{urllib.parse.quote(fn)}">{num+1})</a> <code>{fn}</code>' for num, fn in enumerate(files)])
await message.edit('<b>[ZIP]Список файлов:</b>\n'+files)
@loader.unrestricted
async def zipshowcmd(self, message):
""".zipshow <name> - показывает сохранённый файл"""
if not os.path.exists(ztd):
await message.edit('<b>[ZIP]В папке пусто!</b>')
return
files = os.listdir(ztd)
file = utils.get_args_raw(message)
if not file:
await message.edit('<b>[ZIP]Пустой запрос!</b>')
return
if file not in files:
await message.edit('<b>[ZIP]Такого файла нет!</b>')
return
await message.edit(f"<b>[ZIP]Отправляю \"</b><code>{file}</code><b>\"...")
await message.respond(file=ztd+"/"+file)
await message.delete()
@loader.unrestricted
async def zipdelcmd(self, message):
""".zipdel <name> - удаляет сохранённый файл"""
file = utils.get_args_raw(message)
try:
os.remove(ztd+"/"+file)
except FileNotFoundError:
await message.edit("<b>[ZIP]Такого файла нет!</b>")
return
await message.edit(f"<b>[ZIP]Файл \"</b><code>{file}</code><b>\" удалён!</b>")
@loader.unrestricted
async def zipcmd(self, message):
""".zip <name> (-s) - пакует в архив name. если есть флаг -s то сохраняет папку с фацлами"""
if not os.path.exists(ztd):
await message.edit("<b>[ZIP]Файлов для запаковки не найдено!</b>")
return
name = utils.get_args_raw(message)
save = False
if "-s" in name:
save = True
name = name.replace("-s","").strip()
if not name:
name = str(uuid4()).split("-")[-1]+".zip"
name = name + (".zip" if ".zip" not in name else "")
await message.edit(f'<b>[ZIP]Запаковываю {len(os.listdir(ztd))} файл(ов) в </b>"<code>{name}</code>"')
os.system(f"zip {name} {ztd}/*")
await message.edit(f'<b>[ZIP]Отправляю </b>"<code>{name}</code>"')
await message.respond(file=open(name, "rb"))
await message.delete()
os.system("rm -rf {name}")
if not save:
os.system("rm -rf zip-temp-dir")
@loader.unrestricted
async def zipcleancmd(self, message):
""".zipclear - очищает папку с файлами"""
os.system("rm -rf zip-temp-dir")
await message.edit('<b>[ZIP]Очищено!</b>')
os.mkdir(ztd)

View File

@@ -1,32 +1,32 @@
from asyncio import sleep
from .. import loader, utils
def register(cb):
cb(ЗаёбушкаMod())
class ЗаёбушкаMod(loader.Module):
"""Заебет любого"""
strings = {'name': 'Заёбушка'}
async def заебуcmd(self, message):
""".заебу <колличество> <реплай на того, кого заебать>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>А кого заёбывать-то?</b>")
return
id = reply.sender_id
args = utils.get_args(message)
count = 50
if args:
if args[0].isdigit():
if int(args[0]) < 0:
count = 50
else:
count = int(args[0])
txt = '<a href="tg://user?id={}">Заёбушка :3</a>'.format(id)
await message.delete()
for _ in range(count):
await sleep(0.3)
msg = await message.client.send_message(message.to_id, txt)
await sleep(0.3)
await msg.delete()
from asyncio import sleep
from .. import loader, utils
def register(cb):
cb(ЗаёбушкаMod())
class ЗаёбушкаMod(loader.Module):
"""Заебет любого"""
strings = {'name': 'Заёбушка'}
async def заебуcmd(self, message):
""".заебу <колличество> <реплай на того, кого заебать>"""
reply = await message.get_reply_message()
if not reply:
await message.edit("<b>А кого заёбывать-то?</b>")
return
id = reply.sender_id
args = utils.get_args(message)
count = 50
if args:
if args[0].isdigit():
if int(args[0]) < 0:
count = 50
else:
count = int(args[0])
txt = '<a href="tg://user?id={}">Заёбушка :3</a>'.format(id)
await message.delete()
for _ in range(count):
await sleep(0.3)
msg = await message.client.send_message(message.to_id, txt)
await sleep(0.3)
await msg.delete()