mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-26 20:24:34 +01:00
parent
7b2d1d8129
commit
f110ac15b0
@ -4,22 +4,22 @@ import utils
|
|||||||
from log import log
|
from log import log
|
||||||
import world
|
import world
|
||||||
|
|
||||||
# Handle KILLs sent to the PyLink client and respawn
|
|
||||||
def handle_kill(irc, source, command, args):
|
def handle_kill(irc, source, command, args):
|
||||||
|
"""Handle KILLs to the main PyLink client, respawning it as needed."""
|
||||||
if args['target'] == irc.pseudoclient.uid:
|
if args['target'] == irc.pseudoclient.uid:
|
||||||
irc.spawnMain()
|
irc.spawnMain()
|
||||||
utils.add_hook(handle_kill, 'KILL')
|
utils.add_hook(handle_kill, 'KILL')
|
||||||
|
|
||||||
# Handle KICKs to the PyLink client, rejoining the channels
|
|
||||||
def handle_kick(irc, source, command, args):
|
def handle_kick(irc, source, command, args):
|
||||||
|
"""Handle KICKs to the main PyLink client, rejoining channels as needed."""
|
||||||
kicked = args['target']
|
kicked = args['target']
|
||||||
channel = args['channel']
|
channel = args['channel']
|
||||||
if kicked == irc.pseudoclient.uid:
|
if kicked == irc.pseudoclient.uid:
|
||||||
irc.proto.joinClient(irc.pseudoclient.uid, channel)
|
irc.proto.joinClient(irc.pseudoclient.uid, channel)
|
||||||
utils.add_hook(handle_kick, 'KICK')
|
utils.add_hook(handle_kick, 'KICK')
|
||||||
|
|
||||||
# Handle commands sent to the PyLink client (PRIVMSG)
|
|
||||||
def handle_commands(irc, source, command, args):
|
def handle_commands(irc, source, command, args):
|
||||||
|
"""Handle commands sent to the PyLink client (PRIVMSG)."""
|
||||||
if args['target'] == irc.pseudoclient.uid:
|
if args['target'] == irc.pseudoclient.uid:
|
||||||
text = args['text'].strip()
|
text = args['text'].strip()
|
||||||
cmd_args = text.split(' ')
|
cmd_args = text.split(' ')
|
||||||
@ -39,8 +39,8 @@ def handle_commands(irc, source, command, args):
|
|||||||
irc.msg(source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
|
irc.msg(source, 'Uncaught exception in command %r: %s: %s' % (cmd, type(e).__name__, str(e)))
|
||||||
utils.add_hook(handle_commands, 'PRIVMSG')
|
utils.add_hook(handle_commands, 'PRIVMSG')
|
||||||
|
|
||||||
# Handle WHOIS queries, for IRCds that send them across servers (charybdis, UnrealIRCd; NOT InspIRCd).
|
|
||||||
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)."""
|
||||||
target = args['target']
|
target = args['target']
|
||||||
user = irc.users.get(target)
|
user = irc.users.get(target)
|
||||||
if user is None:
|
if user is None:
|
||||||
@ -109,3 +109,14 @@ def handle_whois(irc, source, command, args):
|
|||||||
# 318: End of WHOIS.
|
# 318: End of WHOIS.
|
||||||
f(server, 318, source, "%s :End of /WHOIS list" % nick)
|
f(server, 318, source, "%s :End of /WHOIS list" % nick)
|
||||||
utils.add_hook(handle_whois, 'WHOIS')
|
utils.add_hook(handle_whois, 'WHOIS')
|
||||||
|
|
||||||
|
def handle_mode(irc, source, command, args):
|
||||||
|
"""Protect against forced deoper attempts."""
|
||||||
|
target = args['target']
|
||||||
|
modes = args['modes']
|
||||||
|
# If the sender is not a PyLink client, and the target IS a protected
|
||||||
|
# client, revert any forced deoper attempts.
|
||||||
|
if utils.isInternalClient(irc, target) and not utils.isInternalClient(irc, source):
|
||||||
|
if ('-o', None) in modes and not utils.isManipulatableClient(irc, target):
|
||||||
|
irc.proto.modeServer(irc.sid, target, {('+o', None)})
|
||||||
|
utils.add_hook(handle_mode, 'MODE')
|
||||||
|
Loading…
Reference in New Issue
Block a user