Improve IRCLogin slightly and add extra symlinks to ease use of the Web features

This commit is contained in:
Terence Simpson 2008-11-26 14:34:47 +00:00
parent d7aa038d05
commit 7fc67de3d6
8 changed files with 53 additions and 23 deletions

View File

@ -77,7 +77,6 @@ launchpad"""
irc.reply('Running...') irc.reply('Running...')
user2nick = {} user2nick = {}
nick2user = {} nick2user = {}
#TODO: Make the team configurable, just needs a config entry
users = lp.getUsers() users = lp.getUsers()
for user in users: for user in users:
lpuser = lp.getIRCNick(user, False) lpuser = lp.getIRCNick(user, False)
@ -98,7 +97,9 @@ launchpad"""
return return
fd = open(uf, 'rb') fd = open(uf, 'rb')
up = Unpickler(fd) up = Unpickler(fd)
(user2nick, nick2user) = up.load() (self.user2nick, self.nick2user) = up.load()
nick2user = self.nick2user
user2nick = self.user2nick
self.knownusers = [i.lower() for i in nick2user.keys()] self.knownusers = [i.lower() for i in nick2user.keys()]
allusers = [u.name.lower() for u in ircdb.users.itervalues()] allusers = [u.name.lower() for u in ircdb.users.itervalues()]
to_add = [x for x in self.knownusers if x not in allusers] to_add = [x for x in self.knownusers if x not in allusers]
@ -115,7 +116,6 @@ launchpad"""
for u in nick2user.keys(): for u in nick2user.keys():
try: try:
user = ircdb.users.getUser(u.lower()) user = ircdb.users.getUser(u.lower())
#Add bantracker capability to all users from launchpad team
if not 'bantracker' in user.capabilities: if not 'bantracker' in user.capabilities:
user.addCapability('bantracker') user.addCapability('bantracker')
except Exception, e: except Exception, e:
@ -142,13 +142,27 @@ launchpad"""
if not msg.tagged('identified'): if not msg.tagged('identified'):
irc.error('You are not identified') irc.error('You are not identified')
return return
nick = msg.nick.lower()
user = None
try: try:
user = ircdb.users.getUser(msg.prefix[:msg.prefix.find('!')].lower()) user = self.nick2user.get(nick, None)
if user:
user = ircdb.users.getUser(user)
except:
user = None
pass
if not user:
try:
user = ircdb.users.getUser(msg.prefix)
except: except:
self.loadUsers() self.loadUsers()
try: try:
user = ircdb.users.getUser(msg.prefix[:msg.prefix.find('!')].lower()) user = ircdb.users.getUser(msg.prefix)
except: except:
for (id, obj) in ircdb.users.users.iteritems():
if obj.name.lower() == nick:
user = obj
if not user:
irc.error(conf.supybot.replies.incorrectAuthentication()) irc.error(conf.supybot.replies.incorrectAuthentication())
return return
user.addAuth(msg.prefix) user.addAuth(msg.prefix)
@ -161,23 +175,26 @@ launchpad"""
return return
if chr(1) in msg.args[1]: if chr(1) in msg.args[1]:
return return
to = msg.args[0]
cmd = msg.args[1]
try: try:
user = ircdb.users.getUser(msg.prefix) user = ircdb.users.getUser(msg.prefix)
if user.checkHostmask(msg.prefix): if user.checkHostmask(msg.prefix):
#self.log.info("%s is a known user: %r" % (msg.prefix, user))
return return
except: except:
pass pass
if to.lower() == irc.nick.lower():
if cmd != "login": text = callbacks.addressed(irc.nick, msg)
return if not text or text != "login":
elif msg.args[1][0] in conf.supybot.reply.whenAddressedBy.chars(): if msg.args[1]:
if msg.args[1][0] == '@':
cmd = msg.args[1][1:] cmd = msg.args[1][1:]
else:
cmd = msg.args[1]
if cmd != "login": if cmd != "login":
return return
else: else:
return return
self.log.info("Calling login for %s" % msg.prefix)
self._callCommand(["login"], irc, msg, []) self._callCommand(["login"], irc, msg, [])
def do290(self, irc, msg): def do290(self, irc, msg):
@ -190,12 +207,18 @@ launchpad"""
irc.queueMsg(ircmsgs.IrcMsg('CAPAB IDENTIFY-MSG')) irc.queueMsg(ircmsgs.IrcMsg('CAPAB IDENTIFY-MSG'))
def inFilter(self, irc, msg): def inFilter(self, irc, msg):
if not msg.command == "PRIVMSG":
return msg
if getattr(irc,'_Freenode_capabed',None) and msg.command == 'PRIVMSG': if getattr(irc,'_Freenode_capabed',None) and msg.command == 'PRIVMSG':
if msg.tagged('identified') == None:
first = msg.args[1][0] first = msg.args[1][0]
rest = msg.args[1][1:] rest = msg.args[1][1:]
msg.tag('identified', first == '+') msg.tag('identified', first == '+')
if first in ('+', '-'):
msg = ircmsgs.privmsg(msg.args[0], rest, msg=msg) msg = ircmsgs.privmsg(msg.args[0], rest, msg=msg)
assert msg.receivedAt and msg.receivedOn and msg.receivedBy assert msg.receivedAt and msg.receivedOn and msg.receivedBy
if len(msg.args) >= 2 and msg.args[1] and msg.args[1][0] in ('+', '-'):
self.do376(irc, msg)
return msg return msg
Class = IRCLogin Class = IRCLogin

1
bans.cgi Symbolic link
View File

@ -0,0 +1 @@
Bantracker/bans.cgi

1
bans.tmpl Symbolic link
View File

@ -0,0 +1 @@
Bantracker/bans.tmpl

1
empty.tmpl Symbolic link
View File

@ -0,0 +1 @@
Bantracker/empty.tmpl

1
factoids.cgi Symbolic link
View File

@ -0,0 +1 @@
Encyclopedia/factoids.cgi

1
factoids.tmpl Symbolic link
View File

@ -0,0 +1 @@
Encyclopedia/factoids.tmpl

1
logs.tmpl Symbolic link
View File

@ -0,0 +1 @@
Encyclopedia/logs.tmpl

1
timezones.html Symbolic link
View File

@ -0,0 +1 @@
Webcal/timezones.html