diff --git a/FreenodeAuth/README.txt b/FreenodeAuth/README.txt new file mode 100644 index 0000000..e642e80 --- /dev/null +++ b/FreenodeAuth/README.txt @@ -0,0 +1,3 @@ +Allows any nickserv-identified user to login without password. Written +specifically for Freenode. Can also auto-create accounts from a list with +nicknames. diff --git a/LpLogin/__init__.py b/FreenodeAuth/__init__.py similarity index 78% rename from LpLogin/__init__.py rename to FreenodeAuth/__init__.py index 4d33fcf..e35bf81 100644 --- a/LpLogin/__init__.py +++ b/FreenodeAuth/__init__.py @@ -1,6 +1,5 @@ ### # Copyright (c) 2007, Dennis Kaarsemaker -# All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as @@ -14,17 +13,16 @@ ### """ -Add a description of the plugin (to be presented to the user inside the wizard) -here. This should describe *what* the plugin does. +Let nickserv-identified users log in without password """ import supybot import supybot.world as world -__version__ = "0.1" +__version__ = "0.2" __author__ = supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net") __contributors__ = {} -__url__ = 'http://bots.ubuntulinux.nl/' +__url__ = 'http://ubotu.ubuntu-nl.org/' import config reload(config) diff --git a/FreenodeAuth/config.py b/FreenodeAuth/config.py new file mode 100644 index 0000000..ffb05ec --- /dev/null +++ b/FreenodeAuth/config.py @@ -0,0 +1,24 @@ +### +# Copyright (c) 2007, Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### + +import supybot.conf as conf +import supybot.registry as registry + +def configure(advanced): + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('FreenodeAuth', True) + +FreenodeAuth = conf.registerPlugin('FreenodeAuth') +conf.registerGlobalValue(FreenodeAuth, 'UserList', + registry.String('', """Filename of file with list of users""",private=True)) diff --git a/LpLogin/plugin.py b/FreenodeAuth/plugin.py similarity index 70% rename from LpLogin/plugin.py rename to FreenodeAuth/plugin.py index 7caf83d..0dc4e66 100644 --- a/LpLogin/plugin.py +++ b/FreenodeAuth/plugin.py @@ -1,7 +1,14 @@ ### # Copyright (c) 2007, Dennis Kaarsemaker -# All rights reserved. # +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # ### @@ -16,20 +23,10 @@ import supybot.conf as conf import supybot.schedule as schedule import random, os -class LpLogin(callbacks.Plugin): - """Add the help for "@plugin help LpLogin" here - This should describe *how* to use this plugin.""" +class FreenodeAuth(callbacks.Plugin): + """Use @login to login""" threaded = True - def __init__(self, irc): - callbacks.Plugin.__init__(self, irc) - try: - schedule.removeEvent(self.name() + '.nickreload') - except: - pass - # Reload every 6 hours - #schedule.addPeriodicEvent(lambda: self.reportnewbugs(irc), 60*60*6, name=self.name() + '.nickreload') - def loadnicks(self): uf = self.registryValue('UserList') if not uf or not os.path.exists(uf): @@ -41,13 +38,7 @@ class LpLogin(callbacks.Plugin): knownusers = [x.lower() for x in users.split() if x] self.knownusers = knownusers allusers = [u.name.lower() for u in ircdb.users.itervalues()] - #print knownusers, allusers - if self.registryValue('DeleteUnknowns'): - to_delete = [x for x in allusers if x not in knownusers and not - ircdb.users.getUser(x)._checkCapability('owner')] - for u in to_delete: - self.log.info("Would delete %s" % u) to_add = [x for x in knownusers if x not in allusers] for a in to_add: self.log.info("Adding %s" % a) @@ -83,12 +74,13 @@ class LpLogin(callbacks.Plugin): try: user = ircdb.users.getUser(msg.prefix[:msg.prefix.find('!')]) except: - irc.error(conf.supybot.replies.incorrectAuthentication()) - return + self.loadnicks() + try: + user = ircdb.users.getUser(msg.prefix[:msg.prefix.find('!')]) + except: + irc.error(conf.supybot.replies.incorrectAuthentication()) + return user.addAuth(msg.prefix) ircdb.users.setUser(user, flush=False) login = wrap(login) -Class = LpLogin - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: +Class = FreenodeAuth diff --git a/FreenodeAuth/test.py b/FreenodeAuth/test.py new file mode 100644 index 0000000..e9b4c8d --- /dev/null +++ b/FreenodeAuth/test.py @@ -0,0 +1,18 @@ +### +# Copyright (c) 2007, Dennis Kaarsemaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +### + +from supybot.test import * + +class FreenodeAuthTestCase(PluginTestCase): + plugins = ('FreenodeAuth',) diff --git a/LpLogin/README.txt b/LpLogin/README.txt deleted file mode 100644 index d60b47a..0000000 --- a/LpLogin/README.txt +++ /dev/null @@ -1 +0,0 @@ -Insert a description of your plugin here, with any notes, etc. about using it. diff --git a/LpLogin/config.py b/LpLogin/config.py deleted file mode 100644 index 8090af2..0000000 --- a/LpLogin/config.py +++ /dev/null @@ -1,20 +0,0 @@ -### -# Copyright (c) 2007, Dennis Kaarsemaker -# All rights reserved. -# -# -### - -import supybot.conf as conf -import supybot.registry as registry - -def configure(advanced): - from supybot.questions import expect, anything, something, yn - conf.registerPlugin('LpLogin', True) - - -LpLogin = conf.registerPlugin('LpLogin') -conf.registerGlobalValue(LpLogin, 'UserList', - registry.String('', """Filename of file with list of users""")) -conf.registerGlobalValue(LpLogin, 'DeleteUnknowns', - registry.Boolean(True, """Unregister people not in the list""")) diff --git a/LpLogin/get_ircteam.py b/LpLogin/get_ircteam.py deleted file mode 100755 index ecf7e84..0000000 --- a/LpLogin/get_ircteam.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python - -import urllib, urllib2 -import xml.dom.minidom as dom -import re, sys, optparse - -usage = "Usage: %prog [options] launchpad_group" -parser = optparse.OptionParser(usage=usage) -parser.add_option("-o", "--output", dest='outfile', help="Output to FILE", - metavar="FILE") -(options, args) = parser.parse_args() -if len(args) < 1: - parser.error('No group specified') -lp_group = args[0] -if options.outfile: - outfd = open(options.outfile,'w') -else: - outfd = sys.stdout - -people_re = re.compile(r'href="/~([^/"]*)"') -nickname_re = re.compile(r'(.*?).*\n.*freenode',re.I) -def get_group_members(group): - nicks = [] - u = urllib2.urlopen('http://launchpad.net/~%s/+members' % urllib.quote(group)) - html = u.read().lower() - # Split into people and groups - p1 = html.find('active members') - p2 = html.find('pending members') - people = people_re.findall(html[p1:p2]) - for p in people: - u = urllib2.urlopen('http://launchpad.net/~%s' % urllib.quote(p)) - html = u.read() - n = nickname_re.findall(html) - nicks += n - return [x.lower() for x in nicks] - -outfd.write("\n".join(get_group_members(lp_group))) diff --git a/LpLogin/test.py b/LpLogin/test.py deleted file mode 100644 index e44ada9..0000000 --- a/LpLogin/test.py +++ /dev/null @@ -1,14 +0,0 @@ -### -# Copyright (c) 2007, Dennis Kaarsemaker -# All rights reserved. -# -# -### - -from supybot.test import * - -class LpLoginTestCase(PluginTestCase): - plugins = ('LpLogin',) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: