mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
coremods: Move ServiceBot kill/kick/message handling into the right module
This also fixes the kill handler erroneously calling a spawn_service() that was never imported.
This commit is contained in:
parent
fbeb3a3747
commit
170de377ca
@ -1,38 +1,10 @@
|
|||||||
"""
|
"""
|
||||||
handlers.py - Implements IRC command handlers (PRIVMSG, KILL, KICK, WHOIS, etc.)
|
handlers.py - Implements miscellaneous IRC command handlers (WHOIS, services login, etc.)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pylinkirc import utils
|
from pylinkirc import utils
|
||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
|
|
||||||
def handle_kill(irc, source, command, args):
|
|
||||||
"""Handle KILLs to PyLink service bots, respawning them as needed."""
|
|
||||||
target = args['target']
|
|
||||||
sbot = irc.isServiceBot(target)
|
|
||||||
if sbot:
|
|
||||||
spawn_service(irc, source, command, {'name': sbot.name})
|
|
||||||
return
|
|
||||||
utils.add_hook(handle_kill, 'KILL')
|
|
||||||
|
|
||||||
def handle_kick(irc, source, command, args):
|
|
||||||
"""Handle KICKs to the PyLink service bots, rejoining channels as needed."""
|
|
||||||
kicked = args['target']
|
|
||||||
channel = args['channel']
|
|
||||||
if irc.isServiceBot(kicked):
|
|
||||||
irc.proto.join(kicked, channel)
|
|
||||||
utils.add_hook(handle_kick, 'KICK')
|
|
||||||
|
|
||||||
def handle_commands(irc, source, command, args):
|
|
||||||
"""Handle commands sent to the PyLink service bots (PRIVMSG)."""
|
|
||||||
target = args['target']
|
|
||||||
text = args['text']
|
|
||||||
|
|
||||||
sbot = irc.isServiceBot(target)
|
|
||||||
if sbot:
|
|
||||||
sbot.call_cmd(irc, source, text)
|
|
||||||
|
|
||||||
utils.add_hook(handle_commands, 'PRIVMSG')
|
|
||||||
|
|
||||||
def handle_whois(irc, source, command, args):
|
def handle_whois(irc, source, command, args):
|
||||||
"""Handle WHOIS queries, for IRCds that send them across servers (charybdis, UnrealIRCd; NOT InspIRCd)."""
|
"""Handle WHOIS queries, for IRCds that send them across servers (charybdis, UnrealIRCd; NOT InspIRCd)."""
|
||||||
target = args['target']
|
target = args['target']
|
||||||
|
@ -77,6 +77,34 @@ def handle_endburst(irc, source, command, args):
|
|||||||
|
|
||||||
utils.add_hook(handle_endburst, 'ENDBURST')
|
utils.add_hook(handle_endburst, 'ENDBURST')
|
||||||
|
|
||||||
|
def handle_kill(irc, source, command, args):
|
||||||
|
"""Handle KILLs to PyLink service bots, respawning them as needed."""
|
||||||
|
target = args['target']
|
||||||
|
sbot = irc.isServiceBot(target)
|
||||||
|
if sbot:
|
||||||
|
spawn_service(irc, source, command, {'name': sbot.name})
|
||||||
|
return
|
||||||
|
utils.add_hook(handle_kill, 'KILL')
|
||||||
|
|
||||||
|
def handle_kick(irc, source, command, args):
|
||||||
|
"""Handle KICKs to the PyLink service bots, rejoining channels as needed."""
|
||||||
|
kicked = args['target']
|
||||||
|
channel = args['channel']
|
||||||
|
if irc.isServiceBot(kicked):
|
||||||
|
irc.proto.join(kicked, channel)
|
||||||
|
utils.add_hook(handle_kick, 'KICK')
|
||||||
|
|
||||||
|
def handle_commands(irc, source, command, args):
|
||||||
|
"""Handle commands sent to the PyLink service bots (PRIVMSG)."""
|
||||||
|
target = args['target']
|
||||||
|
text = args['text']
|
||||||
|
|
||||||
|
sbot = irc.isServiceBot(target)
|
||||||
|
if sbot:
|
||||||
|
sbot.call_cmd(irc, source, text)
|
||||||
|
|
||||||
|
utils.add_hook(handle_commands, 'PRIVMSG')
|
||||||
|
|
||||||
# Register the main PyLink service. All command definitions MUST go after this!
|
# Register the main PyLink service. All command definitions MUST go after this!
|
||||||
mynick = conf.conf['bot'].get("nick", "PyLink")
|
mynick = conf.conf['bot'].get("nick", "PyLink")
|
||||||
myident = conf.conf['bot'].get("ident", "pylink")
|
myident = conf.conf['bot'].get("ident", "pylink")
|
||||||
|
Loading…
Reference in New Issue
Block a user