Seeks: move the whole URL to the configuration.

master
Valentin Lorentz 2011-03-02 13:18:39 +01:00
parent 0f8d3e0afa
commit 957a5532b3
3 changed files with 9 additions and 5 deletions

View File

@ -38,7 +38,7 @@ import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword
# in here if you're keeping the plugin in CVS or some similar system.
__version__ = "0.1"
__version__ = "0.1.1"
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.Author('Pablo Joubert', 'piti', 'pablo.piti@gmail.com')
@ -48,7 +48,9 @@ __author__ = supybot.Author('Pablo Joubert', 'piti', 'pablo.piti@gmail.com')
if not hasattr(supybot.authors, 'progval'):
supybot.authors.progval = supybot.Author('Valentin Lorentz', 'ProgVal',
'progval@gmail.com')
__contributors__ = {supybot.authors.progval: ['code enhancements']}
__contributors__ = {supybot.authors.progval: ['code enhancements',
'unit test',
'configurability']}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/Seeks/download'

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2010, Pablo Joubert
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -46,7 +47,8 @@ Seeks = conf.registerPlugin('Seeks')
# registry.Boolean(False, """Help for someConfigVariableName."""))
conf.registerChannelValue(Seeks, 'url',
registry.String('http://www.seeks.fr/search', """The Seeks server
registry.String('http://www.seeks.fr/search?expansion=1&'
'action=expand&output=json&q=', """The Seeks server
that this plugin will use."""))
conf.registerChannelValue(Seeks, 'separator',
registry.String('/', """The character(s) to use between search

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2010, Pablo Joubert
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -45,13 +46,12 @@ class Seeks(callbacks.Plugin):
self.__parent = super(Seeks, self)
self.__parent.__init__(irc)
# should be changed for your node
self.query_str = '%s?expansion=1&action=expand&output=json&q='
def search(self, irc, msg, args, query):
"""<query>
Searches the <query> in a seeks node."""
query_str = self.query_str % self.registryValue('url', msg.args[0])
query_str = self.registryValue('url', msg.args[0])
query = urllib.quote(query).replace('%20', '+')
raw_page = urllib.urlopen(query_str + query)
page = raw_page.read()