irc plugin to turn text into zalgo text
This commit is contained in:
parent
3d5e6754e8
commit
6ab86f773c
1
text_manip/__init__.py
Normal file
1
text_manip/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
"""Various IRC plugins for messing with text."""
|
42
text_manip/zalgo.py
Normal file
42
text_manip/zalgo.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""Turn text into zalgo text."""
|
||||
import logging
|
||||
|
||||
import irc.client
|
||||
from zalgo_text import zalgo
|
||||
|
||||
from ircbot.lib import Plugin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Zalgo(Plugin):
|
||||
"""Zalgoify text on demand."""
|
||||
|
||||
zalgo_regex = r'^!zalgo\s+(.*)$'
|
||||
|
||||
def start(self):
|
||||
"""Set up the handlers."""
|
||||
logger.debug("%s starting up", __name__)
|
||||
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], self.zalgo_regex,
|
||||
self.zalgofy, 0)
|
||||
|
||||
super(Zalgo, self).start()
|
||||
|
||||
def stop(self):
|
||||
"""Tear down handlers."""
|
||||
logger.debug("%s shutting down", __name__)
|
||||
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.zalgofy)
|
||||
|
||||
super(Zalgo, self).stop()
|
||||
|
||||
def zalgofy(self, connection, event, match):
|
||||
"""Turn text into zalgo text."""
|
||||
who = irc.client.NickMask(event.source).nick
|
||||
what = match.group(1)
|
||||
logger.debug("%s requested zelgo text for %s", who, what)
|
||||
zalgoed = zalgo.zalgo().zalgofy(what)
|
||||
self.bot.reply(event, f"{zalgoed}")
|
||||
return 'NO MORE'
|
||||
|
||||
|
||||
plugin = Zalgo
|
Loading…
Reference in New Issue
Block a user