3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-18 08:02:51 +01:00
PyLink/plugins/ctcp.py

55 lines
1.9 KiB
Python
Raw Normal View History

# ctcp.py: Handles basic CTCP requests.
2016-06-25 21:11:04 +02:00
import random
import datetime
from pylinkirc import utils
from pylinkirc.log import log
def handle_ctcpversion(irc, source, args):
"""
Handles CTCP version requests.
"""
irc.msg(source, '\x01VERSION %s\x01' % irc.version(), notice=True)
utils.add_cmd(handle_ctcpversion, '\x01version')
utils.add_cmd(handle_ctcpversion, '\x01version\x01')
2016-06-25 21:11:04 +02:00
def handle_ctcpping(irc, source, args):
"""
Handles CTCP ping requests.
"""
# CTCP PING 23152511
pingarg = ' '.join(args).strip('\x01')
irc.msg(source, '\x01PING %s\x01' % pingarg, notice=True)
2016-06-25 21:11:04 +02:00
utils.add_cmd(handle_ctcpping, '\x01ping')
def handle_ctcpeaster(irc, source, args):
"""
Secret easter egg.
"""
2017-01-21 07:32:32 +01:00
responses = ["Legends say the cord monster was born only %s years ago..." % \
2016-06-25 21:11:04 +02:00
(datetime.datetime.now().year - 2014),
"Hiss%s" % ('...' * random.randint(1, 5)),
"His%s%s" % ('s' * random.randint(1, 4), '...' * random.randint(1, 5)),
"It's Easter already? Where are the eggs?",
"Maybe later.",
2017-01-21 07:31:46 +01:00
"Janus? Never heard of it.",
irc.version(),
2016-06-25 21:11:04 +02:00
"Let me out of here, I'll give you cookies!",
2017-01-21 07:31:46 +01:00
"About as likely as pigs flying.",
"Request timed out.",
"No actual pie here, sorry.",
"Hey, no loitering!",
"Hey, can you keep a secret? \x031,1 %s" % " " * random.randint(1,20),
2016-06-25 21:11:04 +02:00
]
irc.msg(source, '\x01EASTER %s\x01' % random.choice(responses), notice=True)
utils.add_cmd(handle_ctcpeaster, '\x01easter')
utils.add_cmd(handle_ctcpeaster, '\x01easter\x01')
utils.add_cmd(handle_ctcpeaster, '\x01about')
utils.add_cmd(handle_ctcpeaster, '\x01about\x01')
utils.add_cmd(handle_ctcpeaster, '\x01pylink')
utils.add_cmd(handle_ctcpeaster, '\x01pylink\x01')