Skip to content

Instantly share code, notes, and snippets.

@x0x8x
Created August 29, 2019 00:14
Show Gist options
  • Select an option

  • Save x0x8x/8d6653bf4a722b9038ebdbd11967b554 to your computer and use it in GitHub Desktop.

Select an option

Save x0x8x/8d6653bf4a722b9038ebdbd11967b554 to your computer and use it in GitHub Desktop.
from telethon import events
import asyncio
from collections import deque
import random
import string
import command
import module
class TextModule(module.Module):
name = "Text"
@command.desc("Unicode character from hex codepoint")
@command.alias("cp", "chr", "uc")
async def cmd_uni(self, msg, codepoint):
if not codepoint:
return "__Hex codepoint required.__"
return chr(int(codepoint, 16))
@command.desc("Get a character equivalent to a zero-width space that works on Telegram")
@command.alias("empty")
async def cmd_zwsp(self, msg):
return "\U000e0020"
@command.desc("Animated Moon")
@command.alias("moon")
async def cmd_moon(self, msg):
deq = deque(list("πŸŒ—πŸŒ˜πŸŒ‘πŸŒ’πŸŒ“πŸŒ”πŸŒ•πŸŒ–"))
for _ in range(count):
await asyncio.sleep(0.1)
await event.edit("".join(deq))
deq.rotate(1)
@command.desc("Apply a sarcasm/mocking filter to the given text")
@command.alias("sar", "sarc", "scm", "mock")
async def cmd_sarcasm(self, msg, text):
if not text:
if msg.is_reply:
reply_msg = await msg.get_reply_message()
text = reply_msg.text
else:
return "__Reply to a message with text or provide text to filter.__"
chars = list(text)
for idx, ch in enumerate(chars):
if random.choice((True, False)):
ch = ch.upper()
chars[idx] = ch
return "".join(chars)
@command.desc("Apply strike-through formatting to the given text")
@command.alias("str", "strikethrough")
async def cmd_strike(self, msg, text):
if not text:
return "__Text required.__"
return "\u0336".join(text) + "\u0336"
@command.desc("Generate fake Google Play-style codes (optional arguments: count, length)")
async def cmd_gencode(self, msg, *args):
count = 10
length = 23
if args:
try:
count = int(args[0])
except ValueError:
return "__Invalid number provided for count.__"
if len(args) >= 2:
try:
length = int(args[1])
except ValueError:
return "__Invalid number provided for length.__"
codes = []
alphabet = string.ascii_uppercase + string.digits
for _ in range(count):
code = "".join([random.choice(alphabet) for _ in range(length)])
codes.append(code)
codes_str = "\n".join(codes)
return f"```{codes_str}```"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment