From 6c8e41e1898cb02df6a83f05d9f574e311e67e7a Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 16 Oct 2014 18:38:07 -0700 Subject: [PATCH] add Namegen plugin / update README and PkgInfo tests - PkgInfo: add basic tests for pkgsearch / mintpkg - Deprecate OperUp (and RelayLink to a lesser extent) - add new Namegen plugin --- Namegen/README.md | 22 +++++ Namegen/__init__.py | 69 +++++++++++++++ Namegen/config.py | 56 ++++++++++++ Namegen/ends.txt | 176 ++++++++++++++++++++++++++++++++++++++ Namegen/local/__init__.py | 1 + Namegen/middles.txt | 176 ++++++++++++++++++++++++++++++++++++++ Namegen/plugin.py | 83 ++++++++++++++++++ Namegen/starts.txt | 171 ++++++++++++++++++++++++++++++++++++ Namegen/test.py | 41 +++++++++ OperUp/README.md | 2 +- PkgInfo/test.py | 6 ++ README.md | 8 +- RelayLink/README.md | 2 +- 13 files changed, 809 insertions(+), 4 deletions(-) create mode 100644 Namegen/README.md create mode 100644 Namegen/__init__.py create mode 100644 Namegen/config.py create mode 100644 Namegen/ends.txt create mode 100644 Namegen/local/__init__.py create mode 100644 Namegen/middles.txt create mode 100644 Namegen/plugin.py create mode 100644 Namegen/starts.txt create mode 100644 Namegen/test.py diff --git a/Namegen/README.md b/Namegen/README.md new file mode 100644 index 0000000..709ee8e --- /dev/null +++ b/Namegen/README.md @@ -0,0 +1,22 @@ +This plugin provides a simple random name generator. + +Portions of this code was taken from Atheme services' [gameserv/namegen](https://github.com/atheme/atheme/blob/875d8b7/modules/gameserv/names/default) module. The license is as follows: + +``` +Copyright (c) 2005-2014 Atheme Project (http://www.atheme.org) + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +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. +``` diff --git a/Namegen/__init__.py b/Namegen/__init__.py new file mode 100644 index 0000000..d3f362d --- /dev/null +++ b/Namegen/__init__.py @@ -0,0 +1,69 @@ +### +# Copyright (c) 2014, James Lu +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * 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 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. + +### + +""" +Add a description of the plugin (to be presented to the user inside the wizard) +here. This should describe *what* the plugin does. +""" + +import supybot +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__ = "" + +# XXX Replace this with an appropriate author or supybot.Author instance. +__author__ = supybot.authors.unknown + +# This is a dictionary mapping supybot.Author instances to lists of +# contributions. +__contributors__ = {} + +# This is a url where the most recent plugin package can be downloaded. +__url__ = '' # 'http://supybot.com/Members/yourname/Namegen/download' + +from . import config +from . import plugin +from imp import reload +# In case we're being reloaded. +reload(config) +reload(plugin) +# Add more reloads here if you add third-party modules and want them to be +# reloaded when this plugin is reloaded. Don't forget to import them as well! + +if world.testing: + from . import test + +Class = plugin.Class +configure = config.configure + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/Namegen/config.py b/Namegen/config.py new file mode 100644 index 0000000..219d90f --- /dev/null +++ b/Namegen/config.py @@ -0,0 +1,56 @@ +### +# Copyright (c) 2014, James Lu +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * 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 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 +import supybot.registry as registry +try: + from supybot.i18n import PluginInternationalization + _ = PluginInternationalization('Namegen') +except: + # Placeholder that allows to run the plugin on a bot + # without the i18n module + _ = lambda x:x + +def configure(advanced): + # This will be called by supybot to configure this module. advanced is + # a bool that specifies whether the user identified themself as an advanced + # user or not. You should effect your configuration by manipulating the + # registry as appropriate. + from supybot.questions import expect, anything, something, yn + conf.registerPlugin('Namegen', True) + + +Namegen = conf.registerPlugin('Namegen') +# This is where your configuration variables (if any) should go. For example: +# conf.registerGlobalValue(Namegen, 'someConfigVariableName', +# registry.Boolean(False, _("""Help for someConfigVariableName."""))) + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/Namegen/ends.txt b/Namegen/ends.txt new file mode 100644 index 0000000..043e2a9 --- /dev/null +++ b/Namegen/ends.txt @@ -0,0 +1,176 @@ +ty +carn +ar +acy +er +al +gary +y +ar +arny +alen +carth +gant +y +ber +art +dal +arth +arth +an +ere +geth +aldy +yn +valer +arne +aller +varn +ayne +an +nal +tyne +ayne +art +ont +ney +aver +lyn +iel +gar +y +arry +or +quine +astar +er +aryn +art +war +asty +zane +arik +ayne +an +oller +warty +aryne +chean +ta +un +tha +reth +ant +el +yne +el +tuny +wat +juin +dor +gayn +tyn +dar +car +gine +codd +quent +eas +ew +azer +ont +ly +stead +orn +en +cath +iera +que +air +la +art +erry +sa +ar +er +ern +arty +doth +y +ert +dy +orn +ont +ern +ayn +art +warne +arn +in +ian +el +ak +il +ydd +ime +yn +en +in +im +el +ar +ro +is +is +ro +era +ene +in +ane +iam +ain +ir +un +il +bin +lin +is +sene +bin +lir +ame +a +fyn +se +in +yd +ien +ain +yn +ar +er +in +sume +ras +on +mel +luth +ance +er +yn +an +ar +ayne +eth +nyd +ter +rik +nik +ro +a +mel +yn +ris +lene +ane +yr \ No newline at end of file diff --git a/Namegen/local/__init__.py b/Namegen/local/__init__.py new file mode 100644 index 0000000..e86e97b --- /dev/null +++ b/Namegen/local/__init__.py @@ -0,0 +1 @@ +# Stub so local is a module, used for third-party modules diff --git a/Namegen/middles.txt b/Namegen/middles.txt new file mode 100644 index 0000000..6d2680a --- /dev/null +++ b/Namegen/middles.txt @@ -0,0 +1,176 @@ +gur +carn +az +acy +ayn +asc +gary +hen +tan +arny +alen +carth +gant +rath +cam +art +ron +arth +arth +carad +ere +geth +aldy +yn +valer +arne +aller +varn +ar +an +nal +tyne +ar +art +ont +aur +aver +lyn +as +gar +cuth +arry +or +quine +astar +mel +aryn +art +war +asty +zane +arik +ayne +loc +oller +warty +aryne +chean +quin +tar +dar +reth +ant +an +yne +ax +tuny +wat +juin +a +gayn +on +an +car +gine +codd +quent +eas +ew +azer +am +ly +stead +orn +ar +cath +iera +que +air +la +art +erry +end +om +ast +et +arty +doth +cath +ert +dy +orn +ont +tak +ar +art +warne +arn +in +ian +el +ak +il +ydd +ime +yn +en +in +im +el +ar +ro +is +is +ro +era +ene +in +ane +iam +ain +ir +un +il +bin +lin +is +sene +bin +lir +ame +a +fyn +y +in +yd +ien +ain +yn +ar +er +in +sume +ras +id +mel +luth +ance +er +yn +an +ar +ayne +eth +len +ter +rik +er +ro +tin +mel +yn +ris +lene +ane +as \ No newline at end of file diff --git a/Namegen/plugin.py b/Namegen/plugin.py new file mode 100644 index 0000000..94d28c8 --- /dev/null +++ b/Namegen/plugin.py @@ -0,0 +1,83 @@ +### +# Copyright (c) 2014, James Lu +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * 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 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 random +import os.path +from sys import version_info + +import supybot.utils as utils +from supybot.commands import * +import supybot.plugins as plugins +import supybot.ircutils as ircutils +import supybot.callbacks as callbacks + +try: + from supybot.i18n import PluginInternationalization + _ = PluginInternationalization('Namegen') +except ImportError: + # Placeholder that allows to run the plugin on a bot + # without the i18n module + _ = lambda x:x + +class Namegen(callbacks.Plugin): + """Simple random name generator.""" + threaded = True + def __init__(self, irc): + self.__parent = super(Namegen, self) + self.__parent.__init__(irc) + self.names = {} + for fn in ('starts', 'middles', 'ends'): + with open(os.path.join(os.path.dirname(__file__), '%s.txt') % fn) as f: + self.names[fn] = f.read().splitlines() + + def _namegen(self): + """Generates a random name.""" + numSyl = random.randint(0, 3) + name = "{}{}{}".format(random.choice(self.names['starts']), \ + ''.join(random.sample(self.names['middles'], numSyl)), \ + random.choice(self.names['ends'])) + return name + + def namegen(self, irc, msg, args, count): + """[] + + Generates random names. If not specified, [] defaults to 10.""" + if not count: + count = 10 + if version_info[0] >= 3: + xrange = range + s = ', '.join([self._namegen() for _ in xrange(count)]) + irc.reply(s) + namegen = wrap(namegen, [optional('int')]) + + +Class = Namegen + + +# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/Namegen/starts.txt b/Namegen/starts.txt new file mode 100644 index 0000000..6f03d7b --- /dev/null +++ b/Namegen/starts.txt @@ -0,0 +1,171 @@ +Mar +Quarne +Ba +Er +Odas +Ka +Mold +Syn +Ro +Jast +Yal +Nap +Vard +As +Binthe +Zald +Dez +Las +Uld +Nev +Haur +Bar +Das +Ty +Dar +Ost +Tral +Grave +Eth +Flar +Yal +Klab +Harab +Jar +Nor +Dain +Toc +Bay +Haith +Cal +Lar +Naut +Druc +Bar +Art +For +Mart +Yar +Ha +Ny +Yar +Verd +Wy +Plag +Ter +Haur +Var +Ar +Dar +Val +Mar +Car +Loc +Wearn +Dras +Bel +Har +Jar +For +Kil +Oc +Al +Skal +Nun +Az +Kop +Houl +Lab +Jar +Vast +Claune +Tes +Ob +Nist +El +Est +Zol +Brow +Pulg +Star +Kren +Crac +Scaun +Wal +Quer +Ry +Cyn +Rusk +Del +Lab +Mel +Sep +Lor +Ros +Jar +Daf +Hal +Kol +In +Ael +Sald +Kuv +Ym +Ca +Keld +Bar +Tarl +Shot +Pes +Quer +Lor +Geld +Ar +Har +Bae +Vad +Pas +Ur +Nor +Kir +Var +Mel +Ar +Shy +I +Rald +Cor +Sar +Kor +Rol +Har +Ash +Dir +Las +Vab +Ald +Par +Ob +Hor +Chy +Jar +Ryle +Char +Hab +Sar +Vart +Nist +Obr +Jar +Ge +Yas +Pav +Jes +Shot +Mar +Hor +Er +Ki +Har +Cal +And \ No newline at end of file diff --git a/Namegen/test.py b/Namegen/test.py new file mode 100644 index 0000000..cd69504 --- /dev/null +++ b/Namegen/test.py @@ -0,0 +1,41 @@ +### +# Copyright (c) 2014, James Lu +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * 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 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 * + +class NamegenTestCase(PluginTestCase): + plugins = ('Namegen',) + + def testNamegen(self): + self.assertNotError('namegen') + self.assertNotError('namegen 2') + + +# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/OperUp/README.md b/OperUp/README.md index fca2900..bcc2acd 100644 --- a/OperUp/README.md +++ b/OperUp/README.md @@ -1 +1 @@ -Simple plugin that allows Supybot to oper up on configured networks, on connect and manually. +Simple plugin that allows Supybot to oper up on configured networks, on connect and manually. **This plugin is deprecated and will likely be removed in a future release.** diff --git a/PkgInfo/test.py b/PkgInfo/test.py index 3e5a549..9426554 100644 --- a/PkgInfo/test.py +++ b/PkgInfo/test.py @@ -54,4 +54,10 @@ class PkgInfoTestCase(PluginTestCase): self.assertError('archaur wjoitgjwotgjv') self.assertNotError('archaur yaourt') + def testMintPkg(self): + self.assertNotError('mintpkg qiana cinnamon') + + def testPkgsearch(self): + self.assertNotError('pkgsearch debian python') + # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/README.md b/README.md index a02b192..c0ce81e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes forks/mods of existing Supybot plugins and some that I've written myself. All of the code in this repository is considered **experimental** and **not** ready for production use. It may glitch, break, or spontaneously combust at any time. You have been warned! -*Note:* This repository is currently being written for Python 2.7/Python 3.4, and has not been tested for compatibility with other Python versions. Older Python versions are unsupported, use at your own risk! +*Note:* This repository is currently being written for Python 2.7/Python 3.4, and has not been tested for compatibility with other Python versions. Older Python versions are unsupported; use them at your own risk! ## Support If you have any questions, concerns, or feature requests, please feel free to submit an issue. Pull requests are welcome. @@ -24,8 +24,11 @@ Any specific plugin dependencies *should* also be listed. ##### NoTrigger - Anti-abuse script; prevents the bot from triggering other bots by modifying its output slightly. +##### Namegen +- A simple random name generator. + ##### OperUp -- Simple plugin that allows Supybot to oper up on configured networks, automatically (on connect) and manually. +- Simple plugin that allows Supybot to oper up on configured networks, automatically (on connect) and manually. **This plugin is deprecated and will likely be removed in a future release.** ##### PassGen - Generates random passwords on the fly! @@ -39,6 +42,7 @@ Any specific plugin dependencies *should* also be listed. ##### RelayLink - [LinkRelay](https://github.com/ProgVal/Supybot-plugins/tree/master/LinkRelay) forked into a different name. See [RelayLink/README.md] for more details. +- **Mainstream development has ceased. Any new changes will only be for maintainence purposes/bugfixes.** ##### SupyMisc - Some assorted commands that don't seem to fit anywhere else. diff --git a/RelayLink/README.md b/RelayLink/README.md index c87a8e1..93fb255 100644 --- a/RelayLink/README.md +++ b/RelayLink/README.md @@ -1,4 +1,4 @@ -A fork of the LinkRelay plugin, tailored to my needs. +A fork of the LinkRelay plugin, tailored to my needs. **Mainstream development has ceased. Any new changes will only be for maintainence purposes/bugfixes.** #### Differences from [stock LinkRelay](https://github.com/ProgVal/Supybot-plugins/tree/master/LinkRelay):