Co-Authored-By: Amit Sharma <48654350+buddhhu@users.noreply.github.com> Co-Authored-By: MMETMA <79155572+MMETMA@users.noreply.github.com> Co-Authored-By: Aditya <me@xditya.me> Co-Authored-By: marat2509 <93652988+marat2509@users.noreply.github.com> Co-Authored-By: smartman_ru <14003491+smartmanru@users.noreply.github.com> Co-Authored-By: Flasho <75789819+flashokillerify@users.noreply.github.com> Co-Authored-By: ÁÑÑÍHÌLÅTØR SPÄRK <75305464+annihilatorrrr@users.noreply.github.com>
141 lines
3.9 KiB
Python
141 lines
3.9 KiB
Python
# Ultroid - UserBot
|
|
# Copyright (C) 2021-2022 TeamUltroid
|
|
#
|
|
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
|
# PLease read the GNU Affero General Public License in
|
|
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
|
"""
|
|
✘ Commands Available -
|
|
|
|
• `{i}carbon <text/reply to msg/reply to document>`
|
|
Carbonise the text with default settings.
|
|
|
|
• `{i}rcarbon <text/reply to msg/reply to document>`
|
|
Carbonise the text, with random bg colours.
|
|
|
|
• `{i}ccarbon <color ><text/reply to msg/reply to document>`
|
|
Carbonise the text, with custom bg colours.
|
|
|
|
• `{i}rayso <opt-theme> <text>/<reply to message>`
|
|
`{i}rayso list` - `Get list of themes.`
|
|
"""
|
|
|
|
import random
|
|
|
|
from telethon.utils import get_display_name
|
|
|
|
from . import Carbon, eor, get_string, inline_mention, os, ultroid_cmd
|
|
|
|
_colorspath = "resources/colorlist.txt"
|
|
|
|
if os.path.exists(_colorspath):
|
|
with open(_colorspath, "r") as f:
|
|
all_col = f.read().split()
|
|
else:
|
|
all_col = []
|
|
|
|
|
|
@ultroid_cmd(
|
|
pattern="(rc|c)arbon",
|
|
)
|
|
async def crbn(event):
|
|
xxxx = await event.eor(get_string("com_1"))
|
|
te = event.pattern_match.group(1)
|
|
col = random.choice(all_col) if te[0] == "r" else "White"
|
|
if event.reply_to_msg_id:
|
|
temp = await event.get_reply_message()
|
|
if temp.media:
|
|
b = await event.client.download_media(temp)
|
|
with open(b) as a:
|
|
code = a.read()
|
|
os.remove(b)
|
|
else:
|
|
code = temp.message
|
|
else:
|
|
try:
|
|
code = event.text.split(" ", maxsplit=1)[1]
|
|
except IndexError:
|
|
return await eor(xxxx, get_string("carbon_2"))
|
|
xx = await Carbon(code=code, file_name="ultroid_carbon", backgroundColor=col)
|
|
await xxxx.delete()
|
|
await event.reply(
|
|
f"Carbonised by {inline_mention(event.sender)}",
|
|
file=xx,
|
|
)
|
|
|
|
|
|
@ultroid_cmd(
|
|
pattern="ccarbon( (.*)|$)",
|
|
)
|
|
async def crbn(event):
|
|
match = event.pattern_match.group(1).strip()
|
|
if not match:
|
|
return await event.eor(get_string("carbon_3"))
|
|
msg = await event.eor(get_string("com_1"))
|
|
if event.reply_to_msg_id:
|
|
temp = await event.get_reply_message()
|
|
if temp.media:
|
|
b = await event.client.download_media(temp)
|
|
with open(b) as a:
|
|
code = a.read()
|
|
os.remove(b)
|
|
else:
|
|
code = temp.message
|
|
else:
|
|
try:
|
|
match = match.split(" ", maxsplit=1)
|
|
code = match[1]
|
|
match = match[0]
|
|
except IndexError:
|
|
return await eor(msg, get_string("carbon_2"))
|
|
xx = await Carbon(code=code, backgroundColor=match)
|
|
await msg.delete()
|
|
await event.reply(
|
|
f"Carbonised by {inline_mention(event.sender)}",
|
|
file=xx,
|
|
)
|
|
|
|
|
|
RaySoTheme = [
|
|
"meadow",
|
|
"breeze",
|
|
"raindrop",
|
|
"candy",
|
|
"crimson",
|
|
"falcon",
|
|
"sunset",
|
|
"midnight",
|
|
]
|
|
|
|
|
|
@ultroid_cmd(pattern="rayso")
|
|
async def pass_on(ult):
|
|
spli = ult.text.split()
|
|
theme, dark, title, text = None, True, get_display_name(ult.chat), None
|
|
if len(spli) > 2:
|
|
if spli[1] in RaySoTheme:
|
|
theme = spli[1]
|
|
dark = bool(spli[2].lower().strip() in ["true", "t"])
|
|
elif len(spli) > 1:
|
|
if spli[1] in RaySoTheme:
|
|
theme = spli[1]
|
|
elif spli[1] == "list":
|
|
text = "**List of Rayso Themes:**\n"
|
|
text += "\n".join([f"- `{th_}`" for th_ in RaySoTheme])
|
|
await ult.eor(text)
|
|
return
|
|
else:
|
|
try:
|
|
text = ult.text.split(maxsplit=1)[1]
|
|
except IndexError:
|
|
pass
|
|
if not theme:
|
|
theme = random.choice(RaySoTheme)
|
|
if ult.is_reply:
|
|
msg = await ult.get_reply_message()
|
|
text = msg.text
|
|
title = get_display_name(msg.sender)
|
|
await ult.reply(
|
|
file=await Carbon(text, rayso=True, title=title, theme=theme, darkMode=dark)
|
|
)
|