mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 03:33:11 +01:00
NickAuth: Add support for account-tag (not tested).
This commit is contained in:
parent
259457ae2f
commit
b405f998a5
@ -147,6 +147,13 @@ class NickAuth(callbacks.Plugin):
|
||||
irc.queueMsg(ircmsgs.whois(nick, nick))
|
||||
auth = wrap(auth, [])
|
||||
|
||||
def inFilter(self, irc, msg):
|
||||
"""If the messages has a server tag with account name, tries to
|
||||
authenticate it."""
|
||||
if msg.server_tags and 'account' in msg.server_tags:
|
||||
self._auth(irc, msg.prefix, msg.server_tags['account'])
|
||||
return msg
|
||||
|
||||
def do330(self, irc, msg):
|
||||
mynick, theirnick, theiraccount, garbage = msg.args
|
||||
# I would like to use a dict comprehension, but we have to support
|
||||
@ -176,18 +183,8 @@ class NickAuth(callbacks.Plugin):
|
||||
account = msg.args[0]
|
||||
user = ircdb.users.getUserFromNick(irc.network, account)
|
||||
|
||||
if not user:
|
||||
try:
|
||||
user = ircdb.users.getUser(msg.prefix)
|
||||
except KeyError:
|
||||
user = None
|
||||
|
||||
if user:
|
||||
if account == '*':
|
||||
user.clearAuth()
|
||||
else:
|
||||
user.addAuth(msg.prefix)
|
||||
ircdb.users.setUser(user, flush=False)
|
||||
if account != '*':
|
||||
self._auth(irc, msg.prefix, account)
|
||||
|
||||
|
||||
def doJoin(self, irc, msg):
|
||||
@ -196,18 +193,8 @@ class NickAuth(callbacks.Plugin):
|
||||
return
|
||||
|
||||
account = msg.args[1]
|
||||
user = ircdb.users.getUserFromNick(irc.network, account)
|
||||
|
||||
if not user:
|
||||
try:
|
||||
user = ircdb.users.getUser(msg.prefix)
|
||||
except KeyError:
|
||||
user = None
|
||||
|
||||
if user:
|
||||
if account != '*':
|
||||
user.addAuth(msg.prefix)
|
||||
ircdb.users.setUser(user, flush=False)
|
||||
if account != '*':
|
||||
self._auth(irc, msg.prefix, account)
|
||||
|
||||
def do354(self, irc, msg):
|
||||
if len(msg.args) != 6 or msg.args[1] != '1':
|
||||
@ -217,6 +204,12 @@ class NickAuth(callbacks.Plugin):
|
||||
prefix = '%s!%s@%s' % (nick, ident, host)
|
||||
user = ircdb.users.getUserFromNick(irc.network, account)
|
||||
|
||||
if account != '0':
|
||||
self._auth(irc, prefix, account)
|
||||
|
||||
def _auth(self, irc, prefix, account):
|
||||
user = ircdb.users.getUserFromNick(irc.network, account)
|
||||
|
||||
if not user:
|
||||
try:
|
||||
user = ircdb.users.getUser(prefix)
|
||||
@ -224,7 +217,6 @@ class NickAuth(callbacks.Plugin):
|
||||
user = None
|
||||
|
||||
if user:
|
||||
if account != '0':
|
||||
user.addAuth(prefix)
|
||||
ircdb.users.setUser(user, flush=False)
|
||||
|
||||
|
@ -967,7 +967,7 @@ class Irc(IrcCommandDispatcher):
|
||||
self.sasl = 'plain'
|
||||
|
||||
for cap in ('account-notify', 'extended-join', 'multi-prefix',
|
||||
'metadata-notify'):
|
||||
'metadata-notify', 'account-tag'):
|
||||
self.queueMsg(ircmsgs.IrcMsg(command='CAP', args=('REQ', cap)))
|
||||
|
||||
if self.sasl:
|
||||
|
@ -391,6 +391,10 @@ class IrcTestCase(SupyTestCase):
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
def testPingResponse(self):
|
||||
@ -492,6 +496,8 @@ class IrcCallbackTestCase(SupyTestCase):
|
||||
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-notify')),
|
||||
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'extended-join')),
|
||||
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'multi-prefix')),
|
||||
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'metadata-notify')),
|
||||
ircmsgs.IrcMsg(command='CAP', args=('REQ', 'account-tag')),
|
||||
ircmsgs.IrcMsg(command='CAP', args=('END',)),
|
||||
ircmsgs.user('limnoria', user)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user