udf 2018-06-16 13:37:45 +00:00
commit dfd0e87735
3 changed files with 17 additions and 3 deletions

View File

@ -17,7 +17,7 @@ oops = "OOPSIE WOOPSIE!! Uwu We madea fucky wucky!! A wittle fucko boingo! " \
@borg.on(events.NewMessage)
async def on_pat(event):
if event.forward:
if event.fwd_from:
return
user = borg.me.username

View File

@ -32,6 +32,19 @@ def get_tag_parser(tag, entity):
return re.compile(tag + r'(.+?)' + tag, re.DOTALL), tag_parser
PRINTABLE_ASCII = range(0x21, 0x7f)
def parse_aesthetics(m):
def aesthetify(string):
for c in string:
c = ord(c)
if c in PRINTABLE_ASCII:
c += 0xFF00 - 0x20
elif c == ord(" "):
c = 0x3000
yield chr(c)
return "".join(aesthetify(m[1])), None
def parse_subreddit(m):
text = '/' + m.group(3)
entity = MessageEntityTextUrl(
@ -65,6 +78,7 @@ MATCHERS = [
(get_tag_parser('__', MessageEntityItalic)),
(get_tag_parser('```', partial(MessageEntityPre, language=''))),
(get_tag_parser('`', MessageEntityCode)),
(re.compile(r'\+\+(.+?)\+\+'), parse_aesthetics),
(re.compile(r'([^/\w]|^)(/?(r/\w+))'), parse_subreddit),
(re.compile(r'(!\w+)'), parse_snip)
]

View File

@ -38,7 +38,7 @@ class Uniborg(TelegramClient):
# precedence
self._event_builders = hacks.ReverseList()
self._loop.run_until_complete(self._async_init(bot_token=bot_token))
self.loop.run_until_complete(self._async_init(bot_token=bot_token))
core_plugin = Path(__file__).parent / "_core.py"
self.load_plugin_from_file(core_plugin)
@ -53,7 +53,7 @@ class Uniborg(TelegramClient):
self.uid = telethon.utils.get_peer_id(self.me)
def run(self):
self._loop.run_forever()
self.loop.run_forever()
def load_plugin(self, shortname):
self.load_plugin_from_file(f"{self._plugin_path}/{shortname}.py")