Update copyright/license/author/contributors information
Make sure all files have encoding set to utf-8 unless they already have an encoding Added COPYING with contense of GPL-2 Added plugin name prefix to all log output. This should take the form of self.log.severity("Plugin: message"), when not logging from plugin.py use: "Plugin/file_without_dot_py: message" Bantracker: Made the confgure() function do something, it also creates an initial database if it doesn't exist Encyclopedia: Made the configure() function do something, it also creates an initial database if it doesn't exist PackageInfo: Improve the configure() function, it also now creates some initial .list files and prompts to run update_apt and update_apt_file This goes some way to getting an "ubottu" package together, all we need to do is patch supybot-wizard to download the plugins from bzr and put them somewhere supybot will see them, then the wizard will do all the initial setup
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
"""
|
||||
This plugin can store all kick/ban/remove/mute actions
|
||||
"""
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
# Copyright (c) 2010 Elián Hanisch
|
||||
#
|
||||
# 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,14 +14,20 @@ This plugin can store all kick/ban/remove/mute actions
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
###
|
||||
"""
|
||||
This plugin can store all kick/ban/remove/mute actions
|
||||
"""
|
||||
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__version__ = "0.3.1"
|
||||
__author__ = supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net")
|
||||
__contributors__ = {supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com"): ['New maintainer']}
|
||||
__url__ = 'http://ubottu.com/'
|
||||
__author__ = supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Elián Hanisch", "m4v", "lambdae2@gmail.com"): ['Author', 'Maintainer'],
|
||||
supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ['Original Author']
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
@ -33,3 +39,4 @@ if world.testing:
|
||||
|
||||
Class = plugin.Class
|
||||
configure = config.configure
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006,2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
# Copyright (c) 2010 Elián Hanisch
|
||||
#
|
||||
# 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
|
||||
@ -15,7 +18,6 @@
|
||||
import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
|
||||
class ValidTypes(registry.OnlySomeStrings):
|
||||
"""Invalid type, valid types are: 'removal', 'ban' or 'quiet'."""
|
||||
validStrings = ('removal', 'ban', 'quiet')
|
||||
@ -26,8 +28,144 @@ class SpaceSeparatedListOfTypes(registry.SpaceSeparatedListOf):
|
||||
|
||||
|
||||
def configure(advanced):
|
||||
from supybot.question import yn, something, anything, output
|
||||
import sqlite
|
||||
import re
|
||||
import os
|
||||
from supybot.utils.str import format
|
||||
conf.registerPlugin('Bantracker', True)
|
||||
|
||||
def getReviewTime():
|
||||
output("How many days should the bot wait before requesting a ban/quiet review?")
|
||||
review = something("Can be an integer or decimal value. Zero disables reviews.", default=str(Bantracker.review._default))
|
||||
|
||||
try:
|
||||
review = float(review)
|
||||
if review < 0:
|
||||
raise TypeError
|
||||
except TypeError:
|
||||
output("%r is an invalid value, it must be an integer or float greater or equal to 0", review)
|
||||
return getReviewTime()
|
||||
else:
|
||||
return review
|
||||
|
||||
enabled = yn("Enable Bantracker for all channels?")
|
||||
database = something("Location of the Bantracker database", default=conf.supybot.directories.data.dirize('bans.db'))
|
||||
bansite = anything("URL of the Bantracker web interface, without the 'bans.cgi'. (leave this blank if you don't want to run a web server)")
|
||||
|
||||
request = yn("Enable review and comment requests from bot?", default=False)
|
||||
if request and advanced:
|
||||
output("Which types would you like the bot to request comments for?")
|
||||
output(format("The available request types are %L", type))
|
||||
types = anything("Separate types by spaces or commas:", default=', '.join(Bantracker.type._default))
|
||||
type = set([])
|
||||
for name in re.split(r',?\s+', types):
|
||||
name = name.lower()
|
||||
if name in ('removal', 'ban', 'quiet'):
|
||||
type.append(name)
|
||||
|
||||
output("Which nicks should be bot not requets comments from?")
|
||||
output("Is case insensitive and wildcards '*' and '?' are accepted.")
|
||||
ignores = anything("Separate types by spaces or commas:", default=', '.join(Bantracker.ignore._default))
|
||||
ignore = set([])
|
||||
for name in re.split(r',?\s+', ignores):
|
||||
name = name.lower()
|
||||
ignore.add(name)
|
||||
|
||||
output("You can set the comment and review requests for some nicks to be forwarded to specific nicks/channels")
|
||||
output("Which nicks should these requests be forwarded for?")
|
||||
output("Is case insensitive and wildcards '*' and '?' are accepted.")
|
||||
forwards = anything("Separate types by spaces or commas:", default=', '.join(Bantracker.forward._default))
|
||||
forward = set([])
|
||||
for name in re.split(r',?\s+', forwards):
|
||||
name = name.lower()
|
||||
forward.add(name)
|
||||
|
||||
output("Which nicks/channels should the requests be forwarded to?")
|
||||
output("Is case insensitive and wildcards '*' and '?' are accepted.")
|
||||
channels_i = anything("Separate types by spaces or commas:", default=', '.join(Bantracker.channels._default))
|
||||
channels = set([])
|
||||
for name in re.split(r',?\s+', channel_i):
|
||||
name = name.lower()
|
||||
channels.add(name)
|
||||
|
||||
review = getReviewTime()
|
||||
|
||||
else:
|
||||
type = Bantracker.type._default
|
||||
ignore = Bantracker.ignore._default
|
||||
forward = Bantracker.forward._default
|
||||
channels = Bantracker.channels._default
|
||||
review = Bantracker.review._default
|
||||
|
||||
Bantracker.enabled.setValue(enabled)
|
||||
Bantracker.database.setValue(database)
|
||||
Bantracker.bansite.setValue(bansite)
|
||||
Bantracker.request.setValue(request)
|
||||
Bantracker.type.setValue(type)
|
||||
Bantracker.ignore.setValue(ignore)
|
||||
Bantracker.forward.setValue(forward)
|
||||
Bantracker.channels.setValue(channels)
|
||||
Bantracker.review.setValue(review)
|
||||
|
||||
# Create the initial database
|
||||
db_file = Bantracker.database()
|
||||
if not db_file:
|
||||
db_file = conf.supybot.directories.data.dirize('bans.db')
|
||||
output("supybot.plugins.Bantracker.database will be set to %r" % db_file)
|
||||
Bantracker.database.setValue(db_file)
|
||||
|
||||
if os.path.exists(db_file):
|
||||
return
|
||||
|
||||
output("Creating an initial database in %r" % db_file)
|
||||
con = sqlite.connect(db_file)
|
||||
cur = con.cursor()
|
||||
|
||||
try:
|
||||
con.begin()
|
||||
cur.execute("""CREATE TABLE 'bans' (
|
||||
id INTEGER PRIMARY KEY,
|
||||
channel VARCHAR(30) NOT NULL,
|
||||
mask VARCHAR(100) NOT NULL,
|
||||
operator VARCHAR(30) NOT NULL,
|
||||
time VARCHAR(300) NOT NULL,
|
||||
removal DATETIME,
|
||||
removal_op VARCHAR(30),
|
||||
log TEXT
|
||||
)""")
|
||||
#"""
|
||||
|
||||
cur.execute("""CREATE TABLE comments (
|
||||
ban_id INTEGER,
|
||||
who VARCHAR(100) NOT NULL,
|
||||
comment MEDIUMTEXT NOT NULL,
|
||||
time VARCHAR(300) NOT NULL
|
||||
)""")
|
||||
#"""
|
||||
|
||||
cur.execute("""CREATE TABLE sessions (
|
||||
session_id VARCHAR(50) PRIMARY KEY,
|
||||
user MEDIUMTEXT NOT NULL,
|
||||
time INT NOT NULL
|
||||
)""")
|
||||
#"""
|
||||
|
||||
cur.execute("""CREATE TABLE users (
|
||||
username VARCHAR(50) PRIMARY KEY,
|
||||
salt VARCHAR(8),
|
||||
password VARCHAR(50)
|
||||
)""")
|
||||
#"""
|
||||
|
||||
except:
|
||||
con.rollback()
|
||||
raise
|
||||
else:
|
||||
con.commit()
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
Bantracker = conf.registerPlugin('Bantracker')
|
||||
conf.registerChannelValue(Bantracker, 'enabled',
|
||||
registry.Boolean(False, """Enable the bantracker"""))
|
||||
|
@ -1,5 +1,8 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006,2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
# Copyright (c) 2010 Elián Hanisch
|
||||
#
|
||||
# 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
|
||||
@ -11,6 +14,7 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
###
|
||||
###
|
||||
# Based on the standard supybot logging plugin, which has the following
|
||||
# copyright:
|
||||
#
|
||||
@ -407,7 +411,7 @@ class Bantracker(callbacks.Plugin):
|
||||
cur = self.db.cursor()
|
||||
cur.execute(query, parms)
|
||||
except:
|
||||
self.log.error("Error while trying to access the Bantracker database.")
|
||||
self.log.error("Bantracker: Error while trying to access the Bantracker database.")
|
||||
return None
|
||||
data = None
|
||||
if expect_result and cur: data = cur.fetchall()
|
||||
@ -1029,7 +1033,7 @@ class Bantracker(callbacks.Plugin):
|
||||
bans.remove(ban)
|
||||
|
||||
for ban in remove_bans:
|
||||
self.log.info("Removing ban %s from %s" % (ban.replace('%', '%%'), chan))
|
||||
self.log.info("Bantracker: Removing ban %s from %s" % (ban.replace('%', '%%'), chan))
|
||||
self.doUnban(irc, channel, "Automated-Removal", ban)
|
||||
|
||||
return len(remove_bans)
|
||||
@ -1046,7 +1050,7 @@ class Bantracker(callbacks.Plugin):
|
||||
nick = ban.who
|
||||
if nick.endswith('.freenode.net'):
|
||||
nick = "Automated-Addition"
|
||||
self.log.info("Adding ban %s to %s (%s)" % (str(ban).replace('%', '%%'), chan, nick))
|
||||
self.log.info("Bantracker: Adding ban %s to %s (%s)" % (str(ban).replace('%', '%%'), chan, nick))
|
||||
self.doLog(irc, channel.lower(), '*** Ban sync from channel: %s\n' % str(ban).replace('%', '%%'))
|
||||
self._doKickban(irc, chan, nick, ban.mask, use_time = ban.when)
|
||||
return len(add_bans)
|
||||
|
@ -1,3 +1,19 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
# Copyright (c) 2010 Elián Hanisch
|
||||
#
|
||||
# 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 *
|
||||
|
||||
import supybot.conf as conf
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -20,9 +22,11 @@ import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__version__ = "2.5.1"
|
||||
__author__ = supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net")
|
||||
__contributors__ = {supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com") : ['New maintainer']}
|
||||
__url__ = 'http://ubottu.com/'
|
||||
__author__ = supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ['Original Author']
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -101,7 +103,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
self.db[name] = defined_bugtrackers[group.trackertype()](name, group.url(), group.description())
|
||||
else:
|
||||
# raise BugtrackerError("Unknown trackertype: %s (%s)" % (group.trackertype(), name))
|
||||
self.log.warning("Unknown trackertype: %s (%s)" % (group.trackertype(), name))
|
||||
self.log.warning("Bugtracker: Unknown trackertype: %s (%s)" % (group.trackertype(), name))
|
||||
self.shorthand = utils.abbrev(self.db.keys())
|
||||
|
||||
# Schedule bug reporting
|
||||
@ -113,12 +115,12 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
pass
|
||||
schedule.addPeriodicEvent(lambda: self.reportnewbugs(irc), 60, name=self.name() + '.bugreporter')
|
||||
self.events += [self.name() + '.bugreporter']
|
||||
self.log.info('Adding scheduled event "%s.bugreporter"' % self.name())
|
||||
self.log.info('Bugtracker: Adding scheduled event "%s.bugreporter"' % self.name())
|
||||
|
||||
def die(self):
|
||||
try:
|
||||
for event in self.events:
|
||||
self.log.info('Removing scheduled event "%s"' % event)
|
||||
self.log.info('Bugtracker: Removing scheduled event "%s"' % event)
|
||||
schedule.removeEvent(event)
|
||||
schedule.removeEvent(self.name())
|
||||
except:
|
||||
@ -148,7 +150,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
|
||||
def reportnewbugs(self,irc):
|
||||
# Compile list of bugs
|
||||
self.log.info("Checking for new bugs")
|
||||
self.log.info("Bugtracker: Checking for new bugs")
|
||||
bugs = {}
|
||||
if self.registryValue('imap_ssl'):
|
||||
sc = imaplib.IMAP4_SSL(self.registryValue('imap_server'))
|
||||
@ -168,18 +170,18 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
tag = None
|
||||
|
||||
if 'X-Launchpad-Bug' not in bug.keys():
|
||||
self.log.info('Ignoring e-mail with no detectable bug (Not from Launchpad)')
|
||||
self.log.info('Bugtracker: Ignoring e-mail with no detectable bug (Not from Launchpad)')
|
||||
continue
|
||||
else:
|
||||
tag = bug['X-Launchpad-Bug']
|
||||
if 'distribution=' not in tag and 'product=' not in tag:
|
||||
self.log.info('Ignoring e-mail with no detectable bug (no distro/product)')
|
||||
self.log.info('Bugtracker: Ignoring e-mail with no detectable bug (no distro/product)')
|
||||
continue
|
||||
else:
|
||||
tag = tag.split(';')[0].strip().replace("product=",'').replace("distribution=","")
|
||||
|
||||
if not tag:
|
||||
self.log.info('Ignoring e-mail with no detectible bug (bad tag)')
|
||||
self.log.info('Bugtracker: Ignoring e-mail with no detectible bug (bad tag)')
|
||||
|
||||
tag = tag[tag.find('+')+1:tag.find('@')]
|
||||
if tag not in bugs:
|
||||
@ -207,10 +209,10 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
if '[apport]' in bugs[tag][id]:
|
||||
bugs[tag].pop(id)
|
||||
except:
|
||||
self.log.info("Unable to get new bug %d" % id)
|
||||
self.log.info("Bugtracker: Unable to get new bug %d" % id)
|
||||
pass
|
||||
else:
|
||||
self.log.info('Ignoring e-mail with no detectable bug')
|
||||
self.log.info('Bugtracker: Ignoring e-mail with no detectable bug')
|
||||
|
||||
reported_bugs = 0
|
||||
|
||||
@ -361,7 +363,7 @@ class Bugtracker(callbacks.PluginRegexp):
|
||||
if not name:
|
||||
snarfTarget = self.registryValue('snarfTarget', msg.args[0]).lower()
|
||||
if not snarfTarget:
|
||||
self.log.warning("no snarfTarget for Bugtracker")
|
||||
self.log.warning("Bugtracker: no snarfTarget for Bugtracker")
|
||||
return
|
||||
try:
|
||||
name = self.shorthand[snarfTarget.lower()]
|
||||
|
@ -1,3 +1,17 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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 BugtrackerTestCase(PluginTestCase):
|
||||
plugins = ('Bugtracker',)
|
||||
|
349
COPYING
Normal file
349
COPYING
Normal file
@ -0,0 +1,349 @@
|
||||
Most of the code in this package is licensed under the GNU GPL Version 2,
|
||||
the exception is the Lart plugin, which has a BSD-style license.
|
||||
See Lart/__init__.py for the license.
|
||||
|
||||
NOTE! The GPL below is copyrighted by the Free Software Foundation, but
|
||||
the instance of code that it refers to (the kde programs) are copyrighted
|
||||
by the authors who actually wrote it.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
@ -52,20 +52,3 @@ The web interface is a simple cgi script with some templates, css and the
|
||||
commoncgi.py file from the bzr tree. Make sure you set the variables datadir and
|
||||
database in factoids.cgi to the correct values. Also set default_db to the one
|
||||
you want to show by default.
|
||||
|
||||
To get package lookup working, you need to set the variable
|
||||
supybot.plugins.encyclopedia.aptdir to the name of a new, empty directory. In
|
||||
this directory, you create sources.list files for every distrorelease you want to
|
||||
search. The name of the file is important, since the filename (without the .list
|
||||
suffix) is the name that is used to refer to the distrorelease.
|
||||
|
||||
Whenever you create a new .list file, it is important to run the update_apt
|
||||
and update_apt_file scripts that comes with this plugin. Before you run these,
|
||||
you have to edit them to point to your apt dir. It's also useful to run them
|
||||
periodically from cron (say, once per week for update_apt and once per moth for
|
||||
update_apt_file). You also need to reload the plugin to make it pick up the new
|
||||
releases.
|
||||
|
||||
It is very useful to set the supybot.plugins.encyclopedia.searchorder value to a
|
||||
space separated list of release names. That way you can limit the (expensive)
|
||||
searching for packages to a small set of releases.
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -21,9 +23,11 @@ import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__version__ = "2.3"
|
||||
__author__ = supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net")
|
||||
__contributors__ = {supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com"): ['New Maintainer']}
|
||||
__url__ = 'http://ubottu.com'
|
||||
__author__ = supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com")
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ['Original Author']
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -16,46 +18,178 @@ import supybot.conf as conf
|
||||
import supybot.registry as registry
|
||||
|
||||
def configure(advanced):
|
||||
from supybot.questions import expect, anything, something, yn
|
||||
conf.registerPlugin('Encyclopedia', True)
|
||||
from supybot.questions import yn, something, anything, output
|
||||
from supybot.utils.str import format
|
||||
import sqlite
|
||||
import re
|
||||
Encyclopedia = conf.registerPlugin('Encyclopedia', True)
|
||||
|
||||
enabled = yn("Enable Encyclopedia for all channels?", default=Encyclopedia.enabled._default)
|
||||
if advanced:
|
||||
datadir = something("Which directory should the factoids database be in?", default=Encyclopedia.datadir._default)
|
||||
database = something("What should be the name of the default database (without the .db extension)?", default=Encyclopedia.database._default)
|
||||
prefixchar = something("What prefix character should the bot respond to factoid requests with?", default=Encyclopedia.prefixchar._default)
|
||||
ignores = set([])
|
||||
output("This plugin can be configured to always ignore certain factoid requests, this is useful when you want another plugin to handle them")
|
||||
output("For instance, the PackageInfo plugin responds to !info and !find, so those should be ignored in Encyclopedia to allow this to work")
|
||||
ignores_i = anythnig("Which factoid requets should the bot always ignore?", default=', '.join(Encyclopedia.ignores._default))
|
||||
for name in re.split(r',?\s', +ignore_i):
|
||||
ignores.add(name.lower())
|
||||
|
||||
curStabel = something("What is short name of the current stable release?", default=Encyclopedia.curStable._default)
|
||||
curStableLong = something("What is long name of the current stable release?", default=Encyclopedia.curStableLong._default)
|
||||
curStableNum = something("What is version number of the current stable release?", default=Encyclopedia.curStableNum._default)
|
||||
|
||||
curDevel = something("What is short name of the current development release?", default=Encyclopedia.curDevel._default)
|
||||
curDevelLong = something("What is long name of the current development release?", default=Encyclopedia.curDevelLong._default)
|
||||
curDevelNum = something("What is version number of the current development release?", default=Encyclopedia.curDevelNum._default)
|
||||
|
||||
curLTS = something("What is short name of the current LTS release?", default=Encyclopedia.curLTS._default)
|
||||
curLTSong = something("What is long name of the current LTS release?", default=Encyclopedia.curLTSLoong._default)
|
||||
curLTSNum = something("What is version number of the current LTS release?", default=Encyclopedia.curLTSNum._default)
|
||||
else:
|
||||
datadir = Encyclopedia.datadir._default
|
||||
database = Encyclopedia.database._default
|
||||
prefixchar = Encyclopedia.prefixchar._default
|
||||
ignores = Encyclopedia.ignores._default
|
||||
curStabel = Encyclopedia.curStable._default
|
||||
curStableLong = Encyclopedia.curStableLong._default
|
||||
curStableNum = Encyclopedia.curStableNum._default
|
||||
curDevel = Encyclopedia.curDevel._default
|
||||
curDevelLong = Encyclopedia.curDevelLong._default
|
||||
curDevelNum = Encyclopedia.curDevelNum._default
|
||||
curLTS = Encyclopedia.curLTS._default
|
||||
curLTSLong = Encyclopedia.curLTSLong._default
|
||||
curLTSNum = Encyclopedia.curLTSNum._default
|
||||
|
||||
relaychannel = anything("What channel/nick should the bot forward alter messages to?", default=Encyclopedia.replaychannel._default)
|
||||
output("What message should the bot reply with when a factoid can not be found?")
|
||||
notfoundmsg = something("If you include a '%s' in the message, it will be replaced with the requested factoid", default=Encyclopedia.notfoundmsg._default)
|
||||
output("When certain factoids are called an alert can be forwarded to a channel/nick")
|
||||
output("Which factoids should the bot forward alert calls for?")
|
||||
alert = set([])
|
||||
alert_i = anything("Separate types by spaces or commas:", default=', '.join(Encyclopedia.alert._default))
|
||||
for name in re.split(r',?\s+', alert_i):
|
||||
alert.add(name.lower())
|
||||
remotedb = anything("Location of a remote database to sync with (used with @sync)", default=Encyclopedia.remotedb._default)
|
||||
privateNotFound = yn("Should the bot reply in private when a factoid is not found, as opposed to in the channel?", default=Encyclopedia.privateNotFound._default)
|
||||
|
||||
Encyclopedia.enabled.setValue(enabled)
|
||||
Encyclopedia.datadir.setValue(datadir)
|
||||
Encyclopedia.database.setValue(database)
|
||||
Encyclopedia.prefixchar.setValue(prefixchar)
|
||||
Encyclopedia.ignores.setValue(ignores)
|
||||
Encyclopedia.curStable.setValue(curStable)
|
||||
Encyclopedia.curStableLong.setValue(curStableLong)
|
||||
Encyclopedia.curStableNum.setValue(curStableNum)
|
||||
Encyclopedia.curDevel.setValue(curDevel)
|
||||
Encyclopedia.curDevelLong.setValue(curDevelLong)
|
||||
Encyclopedia.curDevelNum.setValue(curDevelNum)
|
||||
Encyclopedia.curLTS.setValue(curLTS)
|
||||
Encyclopedia.curLTSLong.setValue(curLTSLong)
|
||||
Encyclopedia.curLTSNum.setValue(curLTSNum)
|
||||
Encyclopedia.relaychannel.setValue(relaychannel)
|
||||
Encyclopedia.notfoundmsg.setValue(notfoundmsg)
|
||||
Encyclopedia.alert.setValue(alert)
|
||||
Encyclopedia.privateNotFound.setValue(privateNotFound)
|
||||
|
||||
# Create the initial database
|
||||
db_dir = Encyclopedia.datadir()
|
||||
db_file = Encyclopedia.database()
|
||||
|
||||
if not db_dir:
|
||||
db_dir = conf.supybot.directories.data()
|
||||
output("supybot.plugins.Encyclopedia.datadir will be set to %r" % db_dir)
|
||||
Encyclopedia.datadir.setValue(db_dir)
|
||||
|
||||
if not db_file:
|
||||
db_file = 'ubuntu'
|
||||
output("supybot.plugins.Encyclopedia.database will be set to %r" % db_file)
|
||||
Encyclopedia.database.setValue(db_dir)
|
||||
|
||||
if os.path.exists(os.path.join(db_dir, db_file + '.db')):
|
||||
return
|
||||
|
||||
con = sqlite.connect(os.path.join(db_dir, db_file + '.db'))
|
||||
cur = con.cursor()
|
||||
|
||||
try:
|
||||
con.begin()
|
||||
cur.execute("""CREATE TABLE facts (
|
||||
id INTEGER PRIMARY KEY,
|
||||
author VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(20) NOT NULL,
|
||||
added DATETIME,
|
||||
value VARCHAR(200) NOT NULL,
|
||||
popularity INTEGER NOT NULL DEFAULT 0
|
||||
)""")
|
||||
#"""
|
||||
cur.execute("""CREATE TABLE log (
|
||||
id INTEGER PRIMARY KEY,
|
||||
author VARCHAR(100) NOT NULL,
|
||||
name VARCHAR(20) NOT NULL,
|
||||
added DATETIME,
|
||||
oldvalue VARCHAR(200) NOT NULL
|
||||
)""")
|
||||
|
||||
except:
|
||||
con.rollback()
|
||||
raise
|
||||
else:
|
||||
con.commit()
|
||||
finally:
|
||||
con.close()
|
||||
|
||||
Encyclopedia = conf.registerPlugin('Encyclopedia')
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'enabled',
|
||||
registry.Boolean(True, "Enable Encyclopedia"))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'database',
|
||||
registry.String('ubuntu', 'Name of database to use'))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'relaychannel',
|
||||
registry.String('#ubuntu-ops', 'Relay channel for unauthorized edits'))
|
||||
|
||||
conf.registerGlobalValue(Encyclopedia, 'notfoundmsg',
|
||||
registry.String('Factoid %s not found', 'Reply when factoid isn\'t found'))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia,'prefixchar',
|
||||
registry.String('!','Prefix character for factoid display/editing'))
|
||||
|
||||
conf.registerGlobalValue(Encyclopedia, 'datadir',
|
||||
registry.String("", 'Path to dir containing factoid databases', private=True))
|
||||
conf.Directory(conf.supybot.directories.data(), 'Path to dir containing factoid databases', private=True))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'alert',
|
||||
registry.SpaceSeparatedListOfStrings(['ops', 'op', 'kops', 'calltheops'], 'factoid name(s) used for alerts', private=True))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'remotedb',
|
||||
registry.String('http://ubottu.com/ubuntu.db', 'Remote location of the master database', private=True))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'ignores',
|
||||
registry.SpaceSeparatedListOfStrings(['find', 'info'], 'factoid name(s) to ignore', private=True))
|
||||
|
||||
conf.registerChannelValue(Encyclopedia, 'privateNotFound',
|
||||
registry.Boolean(False, "If set to True, send notfoundmsg in private rather than in the channel"))
|
||||
|
||||
|
||||
conf.registerGlobalValue(Encyclopedia, 'curStable',
|
||||
registry.String('Karmic', "Current stable release"))
|
||||
registry.String('Lucid', "Current stable release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curStableLong',
|
||||
registry.String('Karmic Koala', "Current stable release"))
|
||||
registry.String('Lucid Lynx', "Current stable release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curStableNum',
|
||||
registry.String('9.10', "Current stable release"))
|
||||
registry.String('10.04', "Current stable release"))
|
||||
|
||||
conf.registerGlobalValue(Encyclopedia, 'curDevel',
|
||||
registry.String('Lucid', "Current development release"))
|
||||
registry.String('Maveric', "Current development release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curDevelLong',
|
||||
registry.String('Lucid Lynx', "Current development release"))
|
||||
registry.String('Maveric Meercat', "Current development release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curDevelNum',
|
||||
registry.String('10.04', "Current development release"))
|
||||
registry.String('10.10', "Current development release"))
|
||||
|
||||
conf.registerGlobalValue(Encyclopedia, 'curLTS',
|
||||
registry.String('Hardy', "Current LTS release"))
|
||||
registry.String('Lucid', "Current LTS release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curLTSLong',
|
||||
registry.String('Hardy Herron', "Current LTS release"))
|
||||
registry.String('Lucid Lynx', "Current LTS release"))
|
||||
conf.registerGlobalValue(Encyclopedia, 'curLTSNum',
|
||||
registry.String('8.04', "Current LTS release"))
|
||||
registry.String('10.04', "Current LTS release"))
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -92,6 +94,12 @@ def queue(irc, to, msg):
|
||||
irc.queueMsg(ircmsgs.privmsg(to, msg))
|
||||
|
||||
def capab(prefix, capability):
|
||||
# too bad people don't use supybot's own methods,
|
||||
# it would save me the trouble of hacking this up.
|
||||
import supybot.world as world
|
||||
if world.testing:
|
||||
# we're running a testcase, return always True.
|
||||
return True
|
||||
capability = capability.lower()
|
||||
if prefix.find('!') > 0:
|
||||
user = prefix[:prefix.find('!')]
|
||||
@ -128,7 +136,6 @@ def safeQuote(s):
|
||||
|
||||
class Encyclopedia(callbacks.Plugin):
|
||||
"""!factoid: show factoid"""
|
||||
threaded = True
|
||||
|
||||
def __init__(self, irc):
|
||||
callbacks.Plugin.__init__(self, irc)
|
||||
@ -243,7 +250,7 @@ class Encyclopedia(callbacks.Plugin):
|
||||
db = "%s-log" % self.registryValue('database',channel)
|
||||
db_path = os.path.join(self.registryValue('datadir'), "%s.db" % db)
|
||||
if not os.access(db_path, os.R_OK | os.W_OK):
|
||||
self.log.warning("Could not access log database at '%s.db'" % db_path)
|
||||
self.log.warning("Encyclopedia: Could not access log database at '%s.db'" % db_path)
|
||||
return None
|
||||
channel = "%s-log" % channel
|
||||
if channel in self.databases:
|
||||
@ -797,8 +804,8 @@ class Encyclopedia(callbacks.Plugin):
|
||||
# file doesn't exist yet, so nothing to backup
|
||||
pass
|
||||
except Exception, e:
|
||||
self.log.error("Could not rename %s to %s.backup" % (dbpath, dbpath))
|
||||
self.log.error(utils.exnToString(e))
|
||||
self.log.error("Encyclopedia: Could not rename %s to %s.backup" % (dbpath, dbpath))
|
||||
self.log.error('Encyclopedia: ' + utils.exnToString(e))
|
||||
irc.error("Internal error, see log")
|
||||
return
|
||||
|
||||
@ -808,8 +815,8 @@ class Encyclopedia(callbacks.Plugin):
|
||||
download_database(remotedb, dbpath)
|
||||
irc.replySuccess()
|
||||
except Exception, e:
|
||||
self.log.error("Could not download %s to %s" % (remotedb, dbpath))
|
||||
self.log.error(utils.exnToString(e))
|
||||
self.log.error("Encyclopedia: Could not download %s to %s" % (remotedb, dbpath))
|
||||
self.log.error('Encyclopedia: ' + utils.exnToString(e))
|
||||
irc.error("Internal error, see log")
|
||||
os.rename("%s.backup" % dbpath, dbpath)
|
||||
return
|
||||
|
@ -1,14 +1,75 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006, Dennis Kaarsemaker
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2006 Dennis Kaarsemaker
|
||||
# Copyright (c) 2010 Elián Hanisch
|
||||
#
|
||||
# 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 *
|
||||
import supybot.conf as conf
|
||||
|
||||
class Factoid pluginTestCase(PluginTestCase):
|
||||
plugins = ('Factoid plugin',)
|
||||
Econf = conf.supybot.plugins.Encyclopedia
|
||||
Econf.prefixchar.set('@')
|
||||
|
||||
# we use PluginTestCase instead of ChannelPluginTestCase, Encyclopedia does some weird parsing stuff
|
||||
# that upset testcases.
|
||||
class EncyclopediaTestCase(PluginTestCase):
|
||||
plugins = ('Encyclopedia',)
|
||||
|
||||
def setUp(self):
|
||||
super(EncyclopediaTestCase, self).setUp()
|
||||
conf.supybot.reply.whenNotCommand.setValue(False)
|
||||
|
||||
def createDB(self):
|
||||
import sqlite, os
|
||||
dbfile = os.path.join(Econf.datadir(), '%s.db' %Econf.database())
|
||||
try:
|
||||
os.remove(dbfile)
|
||||
except:
|
||||
pass
|
||||
db = sqlite.connect(dbfile)
|
||||
cursor = db.cursor()
|
||||
cursor.execute('CREATE TABLE facts ('\
|
||||
'id INTEGER PRIMARY KEY,'\
|
||||
'author VARCHAR(100) NOT NULL,'\
|
||||
'name VARCHAR(20) NOT NULL,'\
|
||||
'added DATETIME,'\
|
||||
'value VARCHAR(200) NOT NULL,'\
|
||||
'popularity INTEGER NOT NULL DEFAULT 0);')
|
||||
cursor.execute('CREATE TABLE log ('\
|
||||
'id INTEGER PRIMARY KEY,'\
|
||||
'author VARCHAR(100) NOT NULL,'\
|
||||
'name VARCHAR(20) NOT NULL,'\
|
||||
'added DATETIME,'\
|
||||
'oldvalue VARCHAR(200) NOT NULL);')
|
||||
db.commit()
|
||||
cursor.close()
|
||||
db.close()
|
||||
self.getCallback().databases = {}
|
||||
|
||||
def getCallback(self):
|
||||
for cb in self.irc.callbacks:
|
||||
if cb.name() == 'Encyclopedia':
|
||||
break
|
||||
return cb
|
||||
|
||||
def testSimpleTest(self):
|
||||
self.createDB()
|
||||
self.assertNotError('test is test')
|
||||
self.assertResponse('test', 'test is test')
|
||||
self.assertNotError('no, test is test1')
|
||||
self.assertResponse('test', 'test is test1')
|
||||
self.assertNoResponse('hello is <reply> Hi, welcome to $chan!') # no reply? why?
|
||||
self.assertResponse('hello', 'Hi, welcome to test!')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
# vim:set shiftwidth=4 softtabstop=4 tabstop=4 expandtab textwidth=100:
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008, Terence Simpson <tsimpson@ubuntu.com>
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -21,8 +22,9 @@ import supybot.world as world
|
||||
|
||||
__version__ = "0.4"
|
||||
__author__ = supybot.Author("Terence Simpson","tsimpson","tsimpson@ubuntu.com")
|
||||
__contributors__ = {}
|
||||
__url__ = 'http://ubottu.com'
|
||||
__contributors__ = {
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008, Terence Simpson
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008, Terence Simpson
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -100,6 +101,10 @@ launchpad"""
|
||||
|
||||
@wrap
|
||||
def haveidentifymsg(self, irc, msg, args):
|
||||
""""
|
||||
takes no arguments.
|
||||
Displays if identify-msg is enabled or disabled.
|
||||
"""
|
||||
haveCap = getattr(self._irc, "_Freenode_capabed", False)
|
||||
irc.reply("identify-msg is %sabled" % (haveCap and "En" or "Dis"))
|
||||
|
||||
@ -131,7 +136,7 @@ launchpad"""
|
||||
return
|
||||
else:
|
||||
return
|
||||
self.log.info("Calling login for %s" % msg.prefix)
|
||||
self.log.info("IRCLogin: Calling login for %s" % msg.prefix)
|
||||
self._callCommand(["login"], irc, msg, [])
|
||||
|
||||
def do290(self, irc, msg):
|
||||
|
@ -1,5 +1,6 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008, Terence Simpson
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# 2006, Dennis Kaarsemaker
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# (c) 2006, Dennis Kaarsemaker
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005, Daniel DiPaolo
|
||||
# All rights reserved.
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
#
|
||||
@ -19,9 +20,11 @@ import supybot
|
||||
import supybot.world as world
|
||||
|
||||
__version__ = "0.5"
|
||||
__author__ = supybot.Author('Dennis Kaarsemaker','Seveas','dennis@kaarsemaker.net')
|
||||
__contributors__ = {}
|
||||
__url__ = 'http://ubottu.com/'
|
||||
__author__ = supybot.Author('Terence Simpson', 'tsimpson', 'tsimpson@ubuntu.com')
|
||||
__contributors__ = {
|
||||
supybot.Author('Dennis Kaarsemaker','Seveas','dennis@kaarsemaker.net'): ['Original Author']
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
#
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
#
|
||||
@ -139,7 +140,7 @@ class Mess(callbacks.PluginRegexp):
|
||||
try:
|
||||
method(irc, msg, *args, **kwargs)
|
||||
except Exception, e:
|
||||
self.log.exception('Uncaught exception in %s.', command)
|
||||
self.log.exception('Mess: Uncaught exception in %s.', command)
|
||||
if conf.supybot.reply.error.detailed():
|
||||
irc.error(utils.exnToString(e))
|
||||
else:
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
#
|
||||
|
@ -1,31 +1,16 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010, Terence Simpson <tsimpson@ubuntu.com>
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 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.
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
# 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
###
|
||||
|
||||
"""
|
||||
@ -37,8 +22,10 @@ import supybot.world as world
|
||||
|
||||
__version__ = "0.9.1"
|
||||
__author__ = supybot.Author("Terence Simpson", "tsimpson", "tsimpson@ubuntu.com")
|
||||
__contributors__ = {supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ["Origional code"]}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots'
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ["Origional concept"]
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,31 +1,16 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010, Terence Simpson <tsimpson@ubuntu.com>
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 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.
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
# 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
###
|
||||
|
||||
import supybot.conf as conf
|
||||
@ -36,26 +21,82 @@ def configure(advanced):
|
||||
# a bool that specifies whether the user identified himself as an advanced
|
||||
# user or not. You should effect your configuration by manipulating the
|
||||
# registry as appropriate.
|
||||
def makeSource(release):
|
||||
return """deb http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse
|
||||
deb-src http://archive.ubuntu.com/ubuntu/ %s main restricted universe multiverse
|
||||
"""
|
||||
|
||||
from supybot.questions import output, expect, anything, something, yn
|
||||
import os
|
||||
conf.registerPlugin('PackageInfo', True)
|
||||
enabled = yn("Enable the pugin", default=True)
|
||||
if not enabled:
|
||||
PackageInfo.enabled.setValue(enabled)
|
||||
PackageInfo.aptdir.setValue('')
|
||||
PackageInfo.prefixchar.setValue('!')
|
||||
PackageInfo.defaultRelease.setValue("hardy")
|
||||
return
|
||||
aptdir = something("Where should the apt directory be? (<botdir>/data/apt for example)")
|
||||
output("This value should be different from the bots default reply character")
|
||||
prefixchar = something("What character should the bot respond to?", default='!')
|
||||
defaultRelease = expect("Default release to use when none is specified",
|
||||
possibilities=['dapper', 'feisty', 'gutsy', 'hardy', 'intrepid'],
|
||||
default='hardy')
|
||||
|
||||
enabled = yn("Enable this plugin in all channels?", default=True)
|
||||
|
||||
if enabled and advanced:
|
||||
prefixchar = something("Which prefix character should be bot respond to?", default=PackageInfo.prefixchar._default)
|
||||
defaultRelease = something("What should be the default distrobution when not specified?", default=PackageInfo.defaultRelease._default)
|
||||
aptdir = something("Which directory should be used for the apt cache when looking up packages?", default=supybot.directories.data.dirize('aptdir'))
|
||||
|
||||
# People tend to thing this should be /var/cache/apt
|
||||
while aptdir.beginswith('/var'):
|
||||
output("NO! Do not use your systems apt directory")
|
||||
aptdir = something("Which directory should be used for the apt cache when looking up packages?", default=supybot.directories.data.dirize('aptdir'))
|
||||
|
||||
else:
|
||||
prefixchar = PackageInfo.prefixchar._default
|
||||
defaultRelease = PackageInfo.defaultRelease._default
|
||||
aptdir = supybot.directories.data.dirize('aptdir')
|
||||
|
||||
|
||||
PackageInfo.enabled.setValue(enabled)
|
||||
PackageInfo.aptdir.setValue(aptdir)
|
||||
PackageInfo.prefixchar.setValue(prefixchar)
|
||||
PackageInfo.defaultRelease.setValue(defaultRelease)
|
||||
|
||||
default_dists = set(['hardy', 'jaunty', 'karmic', 'lucid', 'maveric'])
|
||||
pluginDir = os.path.abspath(os.path.dirname(__file__))
|
||||
update_apt = os.path.join(pluginDir, 'update_apt')
|
||||
update_apt_file = os.path.join(pluginDir, 'update_apt_file')
|
||||
|
||||
default_dists.add(defaultRelease)
|
||||
|
||||
for release in default_dist:
|
||||
filename = os.path.join(aptdir, "%s.list" % release)
|
||||
try:
|
||||
output("Creating %s" % filename)
|
||||
fd = fileutils.open(filename)
|
||||
fd.write("# Apt sources list for Ubuntu %s\n" % release)
|
||||
fd.write(makeSource(release))
|
||||
fd.write(makeSource(release + '-security'))
|
||||
fd.write(makeSource(release + '-updates'))
|
||||
fd.close()
|
||||
|
||||
for sub in ('backports', 'proposed'):
|
||||
release = "%s-%s" % sub
|
||||
filename = os.path.join(aptdir, "%s.list" % release)
|
||||
output("Creating %s" % filename)
|
||||
fd = fileutils.open(filename)
|
||||
fd.write("# Apt sources list for Ubuntu %s\n" % release)
|
||||
fd.write(makeSource(release))
|
||||
fd.close()
|
||||
except Exception, e:
|
||||
output("Error writing to %r: %r (%s)" % (filename, str(e), type(e)))
|
||||
|
||||
if yn("In order for the plugin to use these sources, you must run the 'update_apt' script, do you want to do this now?", default=True):
|
||||
os.environ['DIR'] = aptdir # the update_apt script checks if DIR is set and uses it if it is
|
||||
(e, o) = commands.getstatusoutput(update_apt)
|
||||
if e != 0:
|
||||
output("There was an error running update_apt, please run '%s -v' to get more information" % update_apt)
|
||||
|
||||
(e, o) = commands.statusoutput('which apt-file')
|
||||
if e != 0:
|
||||
output("You need to install apt-file in order to use the !find command of this plugin")
|
||||
else:
|
||||
if yn("In order for the !find command to work, you must run the 'update_apt_file' script, do you want to do this now?", default=True):
|
||||
os.environ['DIR'] = aptdir # the update_apt_file script checks if DIR is set and uses it if it is
|
||||
(e, o) = commands.getstatusoutput(update_apt_file)
|
||||
if e != 0:
|
||||
output("There was an error running update_apt_file, please run '%s -v' to get more information" % update_apt_file)
|
||||
|
||||
PackageInfo = conf.registerPlugin('PackageInfo')
|
||||
conf.registerChannelValue(PackageInfo, 'enabled',
|
||||
@ -63,8 +104,8 @@ conf.registerChannelValue(PackageInfo, 'enabled',
|
||||
conf.registerChannelValue(PackageInfo, 'prefixchar',
|
||||
conf.ValidPrefixChars('!', "Character the bot will respond to"))
|
||||
conf.registerChannelValue(PackageInfo, 'defaultRelease',
|
||||
registry.String('', "Default release to use when none is specified"))
|
||||
registry.String('lucid', "Default release to use when none is specified"))
|
||||
conf.registerGlobalValue(PackageInfo, 'aptdir',
|
||||
registry.String('', "Path to the apt directory", private=True))
|
||||
conf.Directory(conf.supybot.directories.data.dirize('aptdir'), "Path to the apt directory", private=True))
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||
|
@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson <tsimpson@ubuntu.com>
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -13,6 +14,7 @@
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
###
|
||||
|
||||
import exceptions
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore", "apt API not stable yet", exceptions.FutureWarning)
|
||||
@ -42,11 +44,12 @@ class Apt:
|
||||
%%s %%s""" % tuple([self.aptdir]*4)
|
||||
self.aptfilecommand = """apt-file -s %s/%%s.list -c %s/apt-file/%%s -l search %%s""" % (self.aptdir, self.aptdir)
|
||||
|
||||
def find(self, pkg, checkdists, filelookup=True):
|
||||
def find(self, pkg, chkdistro, filelookup=True):
|
||||
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+'])
|
||||
distro = checkdists
|
||||
if len(pkg.strip().split()) > 1:
|
||||
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '.-_+'])
|
||||
if not distro:
|
||||
distro = chkdistro
|
||||
if distro not in self.distros:
|
||||
return "%s is not a valid distribution: %s" % (distro, ", ".join(self.distros))
|
||||
pkg = _pkg
|
||||
@ -57,10 +60,10 @@ class Apt:
|
||||
data = commands.getoutput(self.aptfilecommand % (distro, distro, pkg)).split()
|
||||
if data:
|
||||
if data[0] == 'sh:': # apt-file isn't installed
|
||||
self.log.error("apt-file is not installed")
|
||||
self.log.error("PackageInfo/packages: apt-file is not installed")
|
||||
return "Please use http://packages.ubuntu.com/ to search for files"
|
||||
if data[0] == 'E:': # No files in the cache dir
|
||||
self.log.error("Please run the 'update_apt_file' script")
|
||||
self.log.error("PackageInfo/packages: Please run the 'update_apt_file' script")
|
||||
return "Cache out of date, please contact the administrator"
|
||||
if data[0] == "Use" and data[1] == "of":
|
||||
url = "http://packages.ubuntu.com/search?searchon=contents&keywords=%s&mode=&suite=%s&arch=any" % (urllib.quote(pkg), distro)
|
||||
@ -76,68 +79,63 @@ class Apt:
|
||||
else:
|
||||
return "Found: %s" % ', '.join(pkgs[:5])
|
||||
|
||||
def info(self, pkg, checkdists):
|
||||
def info(self, pkg, chkdistro):
|
||||
if not pkg.strip():
|
||||
return ''
|
||||
_pkg = ''.join([x for x in pkg.strip().split(None,1)[0] if x.isalnum() or x in '.-_+'])
|
||||
distro = checkdists
|
||||
if len(pkg.strip().split()) > 1:
|
||||
distro = ''.join([x for x in pkg.strip().split(None,2)[1] if x.isalnum() or x in '-._+'])
|
||||
if not distro:
|
||||
distro = checkdists
|
||||
distro = chkdistro
|
||||
if distro not in self.distros:
|
||||
return "%r is not a valid distribution: %s" % (distro, ", ".join(self.distros))
|
||||
|
||||
checkdists = distro
|
||||
|
||||
pkg = _pkg
|
||||
|
||||
for distro in [checkdists]:
|
||||
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', pkg))
|
||||
data2 = commands.getoutput(self.aptcommand % (distro, distro, distro, 'showsrc', pkg))
|
||||
if not data or 'E: No packages found' in data:
|
||||
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', pkg))
|
||||
data2 = commands.getoutput(self.aptcommand % (distro, distro, distro, 'showsrc', pkg))
|
||||
if not data or 'E: No packages found' in data:
|
||||
return 'Package %s does not exist in %s' % (pkg, distro)
|
||||
maxp = {'Version': '0'}
|
||||
packages = [x.strip() for x in data.split('\n\n')]
|
||||
for p in packages:
|
||||
if not p.strip():
|
||||
continue
|
||||
maxp = {'Version': '0'}
|
||||
packages = [x.strip() for x in data.split('\n\n')]
|
||||
for p in packages:
|
||||
if not p.strip():
|
||||
continue
|
||||
parser = FeedParser.FeedParser()
|
||||
parser.feed(p)
|
||||
p = parser.close()
|
||||
if type(p) == type(""):
|
||||
self.log.error("apt returned an error, do you have the deb-src URLs in %s.list?" % distro)
|
||||
return "Package lookup faild"
|
||||
if not p.get("Version", None):
|
||||
continue
|
||||
if apt.VersionCompare(maxp['Version'], p['Version']) < 0:
|
||||
maxp = p
|
||||
del parser
|
||||
maxp2 = {'Version': '0'}
|
||||
packages2 = [x.strip() for x in data2.split('\n\n')]
|
||||
for p in packages2:
|
||||
if not p.strip():
|
||||
continue
|
||||
parser = FeedParser.FeedParser()
|
||||
parser.feed(p)
|
||||
p = parser.close()
|
||||
if type(p) == type(""):
|
||||
self.log.error("apt returned an error, do you have the deb-src URLs in %s.list?" % distro)
|
||||
return "Package lookup faild"
|
||||
if not p['Version']:
|
||||
continue
|
||||
if apt.VersionCompare(maxp2['Version'], p['Version']) < 0:
|
||||
maxp2 = p
|
||||
del parser
|
||||
archs = ''
|
||||
if maxp2.has_key('Architecture'):
|
||||
if maxp2['Architecture'] not in ('all','any'):
|
||||
archs = ' (Only available for %s)' % maxp2['Architecture']
|
||||
maxp["Distrobution"] = distro
|
||||
return("%s (source: %s): %s. In component %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" %
|
||||
(maxp['Package'], maxp['Source'] or maxp['Package'], maxp['Description'].split('\n')[0], component(maxp['Section']),
|
||||
maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'], archs))
|
||||
return 'Package %s does not exist in %s' % (pkg, checkdists)
|
||||
parser = FeedParser.FeedParser()
|
||||
parser.feed(p)
|
||||
p = parser.close()
|
||||
if type(p) == type(""):
|
||||
self.log.error("PackageInfo/packages: apt returned an error, do you have the deb-src URLs in %s.list?" % distro)
|
||||
return "Package lookup faild"
|
||||
if not p.get("Version", None):
|
||||
continue
|
||||
if apt.VersionCompare(maxp['Version'], p['Version']) < 0:
|
||||
maxp = p
|
||||
del parser
|
||||
maxp2 = {'Version': '0'}
|
||||
packages2 = [x.strip() for x in data2.split('\n\n')]
|
||||
for p in packages2:
|
||||
if not p.strip():
|
||||
continue
|
||||
parser = FeedParser.FeedParser()
|
||||
parser.feed(p)
|
||||
p = parser.close()
|
||||
if type(p) == type(""):
|
||||
self.log.error("PackageInfo/packages: apt returned an error, do you have the deb-src URLs in %s.list?" % distro)
|
||||
return "Package lookup faild"
|
||||
if not p['Version']:
|
||||
continue
|
||||
if apt.VersionCompare(maxp2['Version'], p['Version']) < 0:
|
||||
maxp2 = p
|
||||
del parser
|
||||
archs = ''
|
||||
if maxp2.has_key('Architecture'):
|
||||
if maxp2['Architecture'] not in ('all','any'):
|
||||
archs = ' (Only available for %s)' % maxp2['Architecture']
|
||||
maxp["Distrobution"] = distro
|
||||
return("%s (source: %s): %s. In component %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" %
|
||||
(maxp['Package'], maxp['Source'] or maxp['Package'], maxp['Description'].split('\n')[0], component(maxp['Section']),
|
||||
maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'], archs))
|
||||
|
||||
# Simple test
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,31 +1,16 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010, Terence Simpson <tsimpson@ubuntu.com>
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 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.
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
# 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
###
|
||||
|
||||
import supybot.utils as utils
|
||||
@ -136,7 +121,7 @@ class PackageInfo(callbacks.Plugin):
|
||||
queue(irc, reply_target, "%s: %s" % (target, reply))
|
||||
return
|
||||
except Exception, e:
|
||||
self.log.info("Info: Exception in pipe: %r" % e)
|
||||
self.log.info("PackageInfo: (info) Exception in pipe: %r" % e)
|
||||
pass
|
||||
elif rest[0] == '>':
|
||||
try:
|
||||
@ -146,7 +131,7 @@ class PackageInfo(callbacks.Plugin):
|
||||
queue(irc, target, "<%s> wants you to know: %s" % (msg.nick, reply))
|
||||
return
|
||||
except Exception, e:
|
||||
self.log.info("Info: Exception in redirect: %r" % e)
|
||||
self.log.info("PackageInfo: (info) Exception in redirect: %r" % e)
|
||||
pass
|
||||
|
||||
queue(irc, reply_target, reply)
|
||||
@ -174,7 +159,7 @@ class PackageInfo(callbacks.Plugin):
|
||||
queue(irc, reply_target, "%s: %s" % (target, reply))
|
||||
return
|
||||
except Exception, e:
|
||||
self.log.info("Find: Exception in pipe: %r" % e)
|
||||
self.log.info("PackageInfo: (find) Exception in pipe: %r" % e)
|
||||
pass
|
||||
elif rest[0] == '>':
|
||||
try:
|
||||
@ -184,7 +169,7 @@ class PackageInfo(callbacks.Plugin):
|
||||
queue(irc, target, "<%s> wants you to know: %s" % (msg.nick, reply))
|
||||
return
|
||||
except Exception, e:
|
||||
self.log.info("Find: Exception in redirect: %r" % e)
|
||||
self.log.info("PackageInfo: (find) Exception in redirect: %r" % e)
|
||||
pass
|
||||
|
||||
queue(irc, reply_target, reply)
|
||||
|
@ -1,31 +1,16 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010, Terence Simpson <tsimpson@ubuntu.com>
|
||||
# All rights reserved.
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 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.
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
# 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.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DIR=/home/bot/aptdir
|
||||
if [ -z "$DIR" ]; then
|
||||
DIR=/home/bot/aptdir
|
||||
fi
|
||||
|
||||
DEFAULT_OPTS="-qq"
|
||||
|
||||
|
@ -5,8 +5,13 @@ if [ ! -x "$(which apt-file)" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR=/home/bot/aptdir
|
||||
VERBOSE="no"
|
||||
if [ -z "$DIR" ]; then
|
||||
DIR=/home/bot/aptdir
|
||||
fi
|
||||
|
||||
if [ -z "$VERBOSE" ]; then
|
||||
VERBOSE="no"
|
||||
fi
|
||||
|
||||
while [ "x$1" != "x" ]; do
|
||||
case "$1" in
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*+ Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
@ -19,9 +21,11 @@ Update the topic according to an iCal schedule
|
||||
import supybot
|
||||
import supybot.world as world
|
||||
__version__ = "0.3"
|
||||
__author__ = supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net")
|
||||
__contributors__ = {}
|
||||
__url__ = 'http://ubottu.com'
|
||||
__author__ = supybot.Author('Terence Simpson', 'tsimpson', 'tsimpson@ubuntu.com')
|
||||
__contributors__ = {
|
||||
supybot.Author("Dennis Kaarsemaker","Seveas","dennis@kaarsemaker.net"): ['Original Author']
|
||||
}
|
||||
__url__ = 'https://launchpad.net/ubuntu-bots/'
|
||||
|
||||
import config
|
||||
reload(config)
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
#
|
||||
|
@ -1,4 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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 sys, os
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
from icalendar import Calendar, cal, prop
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
# Components
|
||||
from icalendar.cal import Calendar, Event, Todo, Journal
|
||||
from icalendar.cal import FreeBusy, Timezone, Alarm, ComponentFactory
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
try:
|
||||
from zope.interface import Interface, Attribute
|
||||
except ImportError:
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
import unittest, doctest, os
|
||||
from icalendar import cal, caselessdict, parser, prop
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
from string import ascii_letters, digits
|
||||
import random
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
from string import ascii_letters, digits
|
||||
import random
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2005-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
|
@ -1,4 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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 dateutil import rrule
|
||||
import re, datetime
|
||||
|
||||
|
@ -1,3 +1,18 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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 WebcalTestCase(PluginTestCase):
|
||||
plugins = ('Webcal',)
|
||||
|
@ -1,4 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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 datetime, pytz, urllib2, ical
|
||||
def filter(events):
|
||||
ret = [x for x in events if x.seconds_ago() < 1800]
|
||||
|
@ -1,5 +1,7 @@
|
||||
# -*- Encoding: utf-8 -*-
|
||||
###
|
||||
# Copyright (c) 2006-2007 Dennis Kaarsemaker
|
||||
# Copyright (c) 2008-2010 Terence Simpson
|
||||
#
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user