mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Services: Disable most of the plugin on networks in the disabled list.
Notify the user when trying to use the commands on a disabled network, ignore
noJoinsUntilIdentified, and don't try communicating with services.
Closes: Sf#3018464
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
(cherry picked from commit 9e73f4482c
)
This commit is contained in:
parent
8d5e4ba624
commit
976567c1ac
@ -1,5 +1,6 @@
|
|||||||
###
|
###
|
||||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||||
|
# Copyright (c) 2010, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -62,6 +63,13 @@ class Services(callbacks.Plugin):
|
|||||||
self.identified = False
|
self.identified = False
|
||||||
self.waitingJoins = []
|
self.waitingJoins = []
|
||||||
|
|
||||||
|
def isDisabled(self, irc):
|
||||||
|
disabled = self.registryValue('disabledNetworks')
|
||||||
|
if irc.network in disabled or \
|
||||||
|
irc.state.supported.get('NETWORK', '') in disabled:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if msg.command == 'JOIN':
|
if msg.command == 'JOIN':
|
||||||
if not self.identified:
|
if not self.identified:
|
||||||
@ -75,9 +83,6 @@ class Services(callbacks.Plugin):
|
|||||||
def _getNick(self):
|
def _getNick(self):
|
||||||
return conf.supybot.nick()
|
return conf.supybot.nick()
|
||||||
|
|
||||||
## def _getNickServ(self, network):
|
|
||||||
## return self.registryValue('NickServ', network)
|
|
||||||
|
|
||||||
def _getNickServPassword(self, nick):
|
def _getNickServPassword(self, nick):
|
||||||
# This should later be nick-specific.
|
# This should later be nick-specific.
|
||||||
assert nick in self.registryValue('nicks')
|
assert nick in self.registryValue('nicks')
|
||||||
@ -89,6 +94,8 @@ class Services(callbacks.Plugin):
|
|||||||
self.setRegistryValue('NickServ.password.%s' % nick, password)
|
self.setRegistryValue('NickServ.password.%s' % nick, password)
|
||||||
|
|
||||||
def _doIdentify(self, irc, nick=None):
|
def _doIdentify(self, irc, nick=None):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
if nick is None:
|
if nick is None:
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick not in self.registryValue('nicks'):
|
if nick not in self.registryValue('nicks'):
|
||||||
@ -109,6 +116,8 @@ class Services(callbacks.Plugin):
|
|||||||
irc.sendMsg(ircmsgs.privmsg(nickserv, identify))
|
irc.sendMsg(ircmsgs.privmsg(nickserv, identify))
|
||||||
|
|
||||||
def _doGhost(self, irc, nick=None):
|
def _doGhost(self, irc, nick=None):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
if nick is None:
|
if nick is None:
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick not in self.registryValue('nicks'):
|
if nick not in self.registryValue('nicks'):
|
||||||
@ -135,11 +144,9 @@ class Services(callbacks.Plugin):
|
|||||||
self.sentGhost = time.time()
|
self.sentGhost = time.time()
|
||||||
|
|
||||||
def __call__(self, irc, msg):
|
def __call__(self, irc, msg):
|
||||||
disabled = self.registryValue('disabledNetworks')
|
|
||||||
if irc.network in disabled or \
|
|
||||||
irc.state.supported.get('NETWORK', '') in disabled:
|
|
||||||
return
|
|
||||||
self.__parent.__call__(irc, msg)
|
self.__parent.__call__(irc, msg)
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick not in self.registryValue('nicks'):
|
if nick not in self.registryValue('nicks'):
|
||||||
return
|
return
|
||||||
@ -160,6 +167,8 @@ class Services(callbacks.Plugin):
|
|||||||
self.sentGhost = None
|
self.sentGhost = None
|
||||||
|
|
||||||
def do376(self, irc, msg):
|
def do376(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick not in self.registryValue('nicks'):
|
if nick not in self.registryValue('nicks'):
|
||||||
return
|
return
|
||||||
@ -182,6 +191,8 @@ class Services(callbacks.Plugin):
|
|||||||
do422 = do377 = do376
|
do422 = do377 = do376
|
||||||
|
|
||||||
def do433(self, irc, msg):
|
def do433(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
if nick not in self.registryValue('nicks'):
|
if nick not in self.registryValue('nicks'):
|
||||||
return
|
return
|
||||||
@ -219,6 +230,8 @@ class Services(callbacks.Plugin):
|
|||||||
|
|
||||||
_chanRe = re.compile('\x02(.*?)\x02')
|
_chanRe = re.compile('\x02(.*?)\x02')
|
||||||
def doChanservNotice(self, irc, msg):
|
def doChanservNotice(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
s = msg.args[1].lower()
|
s = msg.args[1].lower()
|
||||||
channel = None
|
channel = None
|
||||||
m = self._chanRe.search(s)
|
m = self._chanRe.search(s)
|
||||||
@ -249,6 +262,8 @@ class Services(callbacks.Plugin):
|
|||||||
on, msg)
|
on, msg)
|
||||||
|
|
||||||
def doNickservNotice(self, irc, msg):
|
def doNickservNotice(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
nick = self._getNick()
|
nick = self._getNick()
|
||||||
s = ircutils.stripFormatting(msg.args[1].lower())
|
s = ircutils.stripFormatting(msg.args[1].lower())
|
||||||
on = 'on %s' % irc.network
|
on = 'on %s' % irc.network
|
||||||
@ -310,6 +325,8 @@ class Services(callbacks.Plugin):
|
|||||||
self.log.debug('Unexpected notice from NickServ %s: %q.', on, s)
|
self.log.debug('Unexpected notice from NickServ %s: %q.', on, s)
|
||||||
|
|
||||||
def checkPrivileges(self, irc, channel):
|
def checkPrivileges(self, irc, channel):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
on = 'on %s' % irc.network
|
on = 'on %s' % irc.network
|
||||||
if chanserv and self.registryValue('ChanServ.op', channel):
|
if chanserv and self.registryValue('ChanServ.op', channel):
|
||||||
@ -329,6 +346,8 @@ class Services(callbacks.Plugin):
|
|||||||
irc.sendMsg(ircmsgs.privmsg(chanserv, 'voice %s' % channel))
|
irc.sendMsg(ircmsgs.privmsg(chanserv, 'voice %s' % channel))
|
||||||
|
|
||||||
def doMode(self, irc, msg):
|
def doMode(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
on = 'on %s' % irc.network
|
on = 'on %s' % irc.network
|
||||||
if ircutils.strEqual(msg.nick, chanserv):
|
if ircutils.strEqual(msg.nick, chanserv):
|
||||||
@ -352,6 +371,12 @@ class Services(callbacks.Plugin):
|
|||||||
channel = msg.args[1] # nick is msg.args[0].
|
channel = msg.args[1] # nick is msg.args[0].
|
||||||
self.checkPrivileges(irc, channel)
|
self.checkPrivileges(irc, channel)
|
||||||
|
|
||||||
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
irc.error('Services plugin is disabled on this network',
|
||||||
|
Raise=True)
|
||||||
|
self.__parent.callCommand(command, irc, msg, *args, **kwargs)
|
||||||
|
|
||||||
def _chanservCommand(self, irc, channel, command, log=False):
|
def _chanservCommand(self, irc, channel, command, log=False):
|
||||||
chanserv = self.registryValue('ChanServ')
|
chanserv = self.registryValue('ChanServ')
|
||||||
if chanserv:
|
if chanserv:
|
||||||
@ -394,6 +419,8 @@ class Services(callbacks.Plugin):
|
|||||||
voice = wrap(voice, [('checkChannelCapability', 'op'), 'inChannel'])
|
voice = wrap(voice, [('checkChannelCapability', 'op'), 'inChannel'])
|
||||||
|
|
||||||
def do474(self, irc, msg):
|
def do474(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
channel = msg.args[1]
|
channel = msg.args[1]
|
||||||
on = 'on %s' % irc.network
|
on = 'on %s' % irc.network
|
||||||
self.log.info('Banned from %s, attempting ChanServ unban %s.',
|
self.log.info('Banned from %s, attempting ChanServ unban %s.',
|
||||||
@ -414,6 +441,8 @@ class Services(callbacks.Plugin):
|
|||||||
unban = wrap(unban, [('checkChannelCapability', 'op')])
|
unban = wrap(unban, [('checkChannelCapability', 'op')])
|
||||||
|
|
||||||
def do473(self, irc, msg):
|
def do473(self, irc, msg):
|
||||||
|
if self.isDisabled(irc):
|
||||||
|
return
|
||||||
channel = msg.args[1]
|
channel = msg.args[1]
|
||||||
on = 'on %s' % irc.network
|
on = 'on %s' % irc.network
|
||||||
self.log.info('%s is +i, attempting ChanServ invite %s.', channel, on)
|
self.log.info('%s is +i, attempting ChanServ invite %s.', channel, on)
|
||||||
|
Loading…
Reference in New Issue
Block a user