mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-23 10:44:09 +01:00
FANTASY support plugin (Closes #111)
This commit is contained in:
parent
822544e3cc
commit
4509e0757d
26
plugins/fantasy.py
Executable file
26
plugins/fantasy.py
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
# fantasy.py: Adds FANTASY command support, to allow calling commands in channels
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
|
||||||
|
import utils
|
||||||
|
from log import log
|
||||||
|
|
||||||
|
def handle_fantasy(irc, source, command, args):
|
||||||
|
"""Fantasy command handler."""
|
||||||
|
try:
|
||||||
|
prefix = irc.botdata["prefix"]
|
||||||
|
except KeyError:
|
||||||
|
log.warning("(%s) Fantasy prefix was not set in configuration - "
|
||||||
|
"fantasy commands will not work!", self.name)
|
||||||
|
return
|
||||||
|
channel = args['target']
|
||||||
|
text = args['text']
|
||||||
|
if utils.isChannel(channel) and text.startswith(prefix):
|
||||||
|
# Cut off the length of the prefix from the text.
|
||||||
|
text = text[len(prefix):]
|
||||||
|
# Set the last called in variable to the channel, so replies (from
|
||||||
|
# supporting plugins) get forwarded to it.
|
||||||
|
irc.called_by = channel
|
||||||
|
irc.callCommand(source, text)
|
||||||
|
utils.add_hook(handle_fantasy, 'PRIVMSG')
|
Loading…
Reference in New Issue
Block a user