mirror of
https://github.com/jlu5/SupyPlugins.git
synced 2025-05-04 17:31:00 -05:00
Remove obsolete Voteserv plugin
This commit is contained in:
parent
3ea070a803
commit
b04f315bde
@ -81,9 +81,6 @@ Most of these plugins also have their own READMEs in their folders; you can usua
|
|||||||
##### [TranslateParty](TranslateParty/README.md)
|
##### [TranslateParty](TranslateParty/README.md)
|
||||||
- Translates text through Google Translate multiple times in order to get amusing results.
|
- Translates text through Google Translate multiple times in order to get amusing results.
|
||||||
|
|
||||||
##### Voteserv
|
|
||||||
- A plugin for storing and manipulating votes/polls.
|
|
||||||
|
|
||||||
##### Wikifetch
|
##### Wikifetch
|
||||||
- Fork of [ProgVal's Wikipedia plugin](https://github.com/ProgVal/Supybot-plugins), with support for other wikis (via a `--site` option) and other improvements.
|
- Fork of [ProgVal's Wikipedia plugin](https://github.com/ProgVal/Supybot-plugins), with support for other wikis (via a `--site` option) and other improvements.
|
||||||
- **Requires:** [lxml](https://lxml.de/installation.html)
|
- **Requires:** [lxml](https://lxml.de/installation.html)
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
A plugin for storing and manipulating votes/polls.
|
|
||||||
|
|
||||||
```
|
|
||||||
<+GLolol> `vote lose the game
|
|
||||||
<@supybot> GLolol voted to lose the game. (Votes: 1)
|
|
||||||
<+GLolol> `votes lose the game
|
|
||||||
<@supybot> 1 person has voted to lose the game. (Votes: 1)
|
|
||||||
<+GLolol> `vote lose the game
|
|
||||||
<@supybot> Error: You have already voted to lose the game.
|
|
||||||
```
|
|
@ -1,68 +0,0 @@
|
|||||||
###
|
|
||||||
# Copyright (c) 2014-2015, 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.
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
"""
|
|
||||||
A simple plugin to track polls.
|
|
||||||
"""
|
|
||||||
|
|
||||||
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__ = "2020.01.05+git"
|
|
||||||
|
|
||||||
__author__ = getattr(supybot.authors, 'jlu',
|
|
||||||
supybot.Author('James Lu', 'GLolol', 'james@overdrivenetworks.com'))
|
|
||||||
|
|
||||||
# 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__ = 'https://github.com/jlu5/SupyPlugins/'
|
|
||||||
|
|
||||||
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:
|
|
@ -1,58 +0,0 @@
|
|||||||
###
|
|
||||||
# Copyright (c) 2014-2015, 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('Voteserv')
|
|
||||||
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('Voteserv', True)
|
|
||||||
|
|
||||||
|
|
||||||
Voteserv = conf.registerPlugin('Voteserv')
|
|
||||||
conf.registerGlobalValue(Voteserv, 'allowAdminOverride',
|
|
||||||
registry.Boolean(False, _("""Determines whether bot admins will be
|
|
||||||
allowed to override duplicate vote checks.""")))
|
|
||||||
conf.registerGlobalValue(Voteserv, 'allowCheat',
|
|
||||||
registry.Boolean(False, _("""Determines whether the 'cheat' command
|
|
||||||
is enabled.""")))
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
|
@ -1 +0,0 @@
|
|||||||
# Stub so local is a module, used for third-party modules
|
|
@ -1,193 +0,0 @@
|
|||||||
###
|
|
||||||
# Copyright (c) 2014-2015, 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 json
|
|
||||||
import supybot.conf as conf
|
|
||||||
import supybot.utils as utils
|
|
||||||
from supybot.commands import *
|
|
||||||
import supybot.plugins as plugins
|
|
||||||
import supybot.ircutils as ircutils
|
|
||||||
import supybot.ircdb as ircdb
|
|
||||||
import supybot.callbacks as callbacks
|
|
||||||
import supybot.world as world
|
|
||||||
try:
|
|
||||||
from supybot.i18n import PluginInternationalization
|
|
||||||
_ = PluginInternationalization('Voteserv')
|
|
||||||
except ImportError:
|
|
||||||
# Placeholder that allows to run the plugin on a bot
|
|
||||||
# without the i18n module
|
|
||||||
_ = lambda x:x
|
|
||||||
|
|
||||||
class Voteserv(callbacks.Plugin):
|
|
||||||
"""Small plugin for storing and manipulating votes/polls."""
|
|
||||||
threaded = True
|
|
||||||
|
|
||||||
def _pluralize(self, n):
|
|
||||||
"""Returns 's' if <n> is not 1."""
|
|
||||||
return 's' if n != 1 else ''
|
|
||||||
|
|
||||||
def __init__(self, irc):
|
|
||||||
self.__parent = super(Voteserv, self)
|
|
||||||
self.__parent.__init__(irc)
|
|
||||||
self.vfilename = conf.supybot.directories.data.dirize("votes.db")
|
|
||||||
self.loadVoteDB()
|
|
||||||
world.flushers.append(self.exportVoteDB)
|
|
||||||
|
|
||||||
def loadVoteDB(self):
|
|
||||||
self.log.debug("Voteserv: loading votes database from "+self.vfilename)
|
|
||||||
try:
|
|
||||||
with open(self.vfilename, "r") as f:
|
|
||||||
self.votedb = json.load(f)
|
|
||||||
except IOError:
|
|
||||||
self.log.error("Voteserv: failed to load votes database %s"
|
|
||||||
", creating a new one in memory...", self.vfilename)
|
|
||||||
self.votedb = {}
|
|
||||||
except ValueError:
|
|
||||||
self.log.error("Voteserv: Invalid JSON found in votes database "
|
|
||||||
"%s, creating a new one in memory...", self.vfilename)
|
|
||||||
self.votedb = {}
|
|
||||||
|
|
||||||
def exportVoteDB(self):
|
|
||||||
self.log.debug("Voteserv: exporting votes database to "+self.vfilename)
|
|
||||||
with open(self.vfilename, 'w') as f:
|
|
||||||
json.dump(self.votedb, f, indent=4, separators=(',', ': '))
|
|
||||||
f.write("\n")
|
|
||||||
|
|
||||||
def die(self):
|
|
||||||
try:
|
|
||||||
self.exportVoteDB()
|
|
||||||
except IOError as e:
|
|
||||||
self.log.error("Failed to export votes database: " + str(e))
|
|
||||||
world.flushers.remove(self.exportVoteDB)
|
|
||||||
self.__parent.die()
|
|
||||||
|
|
||||||
def _lazyhostmask(self, host):
|
|
||||||
return "*!"+host.split("!",1)[1]
|
|
||||||
|
|
||||||
def _formatAction(self, action):
|
|
||||||
a = action.split()
|
|
||||||
try: n = self.votedb[action][0]
|
|
||||||
except KeyError: n = 0
|
|
||||||
if len(a) >= 2:
|
|
||||||
return "\x02%s\x02 %s. (Votes: \x02%s\x02)" % \
|
|
||||||
(a[0], ' '.join(a[1:]), n)
|
|
||||||
return "\x02%s\x02. (Votes: \x02%s\x02)" % \
|
|
||||||
(action, n)
|
|
||||||
|
|
||||||
def vote(self, irc, msg, args, action):
|
|
||||||
"""<something>
|
|
||||||
|
|
||||||
Votes for something. It doesn't actually perform any actions directly,
|
|
||||||
but could be an interesting way to get user feedback."""
|
|
||||||
action = ircutils.stripFormatting(action.lower()).strip()
|
|
||||||
override = self.registryValue("allowAdminOverride") and \
|
|
||||||
ircdb.checkCapability(msg.prefix, 'admin')
|
|
||||||
if not action: # It must be just whitespace or formatting codes
|
|
||||||
irc.error("You must specify a proper action!", Raise=True)
|
|
||||||
try:
|
|
||||||
votedhosts = map(self._lazyhostmask, self.votedb[action][1:])
|
|
||||||
if self._lazyhostmask(msg.prefix) in votedhosts and not override:
|
|
||||||
irc.error("You have already voted to %r." % action, Raise=True)
|
|
||||||
except KeyError:
|
|
||||||
self.votedb[action] = [0]
|
|
||||||
self.votedb[action][0] += 1
|
|
||||||
irc.reply("%s voted to %s" % (msg.nick,self._formatAction(action)))
|
|
||||||
self.votedb[action].append(msg.prefix)
|
|
||||||
vote = wrap(vote, ['text'])
|
|
||||||
|
|
||||||
def voteclear(self, irc, msg, args):
|
|
||||||
"""takes no arguments.
|
|
||||||
|
|
||||||
Clears all votes stored in memory. Use with caution!"""
|
|
||||||
self.votedb = {}
|
|
||||||
irc.replySuccess()
|
|
||||||
voteclear = wrap(voteclear, ['admin'])
|
|
||||||
|
|
||||||
def votes(self, irc, msg, args, opts, action):
|
|
||||||
"""[--hosts] [--number] <action>
|
|
||||||
|
|
||||||
Returns the amount of people that have voted for <action>. If
|
|
||||||
--hosts is given, also show the hosts that have voted for <action>.
|
|
||||||
If --number is given, only returns the number of people who has
|
|
||||||
voted for <action> (useful for nested commands)."""
|
|
||||||
action = ircutils.stripFormatting(action.lower()).strip()
|
|
||||||
if not action:
|
|
||||||
irc.error("You must specify a proper action!", Raise=True)
|
|
||||||
try:
|
|
||||||
n, hosts = self.votedb[action][0], self.votedb[action][1:]
|
|
||||||
except KeyError:
|
|
||||||
n, hosts = 0, None
|
|
||||||
opts = dict(opts)
|
|
||||||
if 'number' in opts:
|
|
||||||
irc.reply(n)
|
|
||||||
else:
|
|
||||||
s = '\x02%s\x02 %s voted to %s' % \
|
|
||||||
(n, 'person has' if n == 1 else 'people have', \
|
|
||||||
self._formatAction(action))
|
|
||||||
if 'hosts' in opts and n:
|
|
||||||
s += format(" [%L]", list(set(hosts)))
|
|
||||||
irc.reply(s)
|
|
||||||
votes = wrap(votes, [getopts({'hosts':'', 'number':''}), 'text'])
|
|
||||||
|
|
||||||
def cheat(self, irc, msg, args, num, action):
|
|
||||||
"""<number of votes> <action>
|
|
||||||
|
|
||||||
Sets the number of votes for <action> to a certain amount,
|
|
||||||
perfect for rigged elections!
|
|
||||||
This will also reset the list of hosts that have voted for
|
|
||||||
<action>, allowing everyone to vote again."""
|
|
||||||
if not self.registryValue("allowCheat"):
|
|
||||||
irc.error("This command is disabled; please set config plugins."
|
|
||||||
"voteserv.allowCheat accordingly.", Raise=True)
|
|
||||||
action = ircutils.stripFormatting(action.lower()).strip()
|
|
||||||
if not action:
|
|
||||||
irc.error("You must specify a proper action!", Raise=True)
|
|
||||||
self.votedb[action] = [num]
|
|
||||||
irc.replySuccess()
|
|
||||||
cheat = wrap(cheat, ['admin', 'int', 'text'])
|
|
||||||
|
|
||||||
def listallvotes(self, irc, msg, args):
|
|
||||||
"""<takes no arguments>.
|
|
||||||
|
|
||||||
Returns the list of things that have been voted for, along
|
|
||||||
with the number of votes for each."""
|
|
||||||
items = self.votedb.items()
|
|
||||||
if items:
|
|
||||||
s = "; ".join(['"%s": \x02%s\x02 vote%s' % (k, v[0], self._pluralize(v[0]))
|
|
||||||
for k, v in items])
|
|
||||||
irc.reply(s)
|
|
||||||
else:
|
|
||||||
irc.error("The vote database is empty!")
|
|
||||||
listallvotes = wrap(listallvotes)
|
|
||||||
|
|
||||||
Class = Voteserv
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
|
@ -1,84 +0,0 @@
|
|||||||
###
|
|
||||||
# Copyright (c) 2014-2015, 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 VoteservTestCase(PluginTestCase):
|
|
||||||
plugins = ('Voteserv','Admin')
|
|
||||||
config = {'supybot.plugins.voteserv.allowCheat': True}
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
PluginTestCase.setUp(self)
|
|
||||||
# Create a valid user to use
|
|
||||||
self.prefix = 'foo!bar@baz'
|
|
||||||
|
|
||||||
def testVoteservBasic(self):
|
|
||||||
self.assertRegexp('vote test something', 'foo voted to.*?test.*?something.*')
|
|
||||||
self.assertRegexp('votes test something', '.*?1.*?voted to.*?test.*?something.*')
|
|
||||||
|
|
||||||
def testNoDuplicateVotes(self):
|
|
||||||
# The plugin should block duplicate votes from the same user by hostmask.
|
|
||||||
self.assertNotError('vote test something')
|
|
||||||
self.assertError('vote test something')
|
|
||||||
|
|
||||||
def testCheat(self):
|
|
||||||
self.assertNotError('cheat 300 abcdefg')
|
|
||||||
self.assertRegexp('votes abcdefg', '.*?300.*? voted to \x02abcdefg.*')
|
|
||||||
|
|
||||||
def testCheatResetsVotes(self):
|
|
||||||
self.assertNotError('vote Abcd')
|
|
||||||
self.assertNotError('cheat 200 Abcd')
|
|
||||||
# 'cheat' should set the votes for something to a certain amount AND
|
|
||||||
# reset the list of people who voted, allowing them to all vote again.
|
|
||||||
self.assertNotError('vote Abcd')
|
|
||||||
|
|
||||||
def testVoteStripFormatting(self):
|
|
||||||
self.assertError('vote "\x02\x02\x0f \x03"')
|
|
||||||
self.assertNotError('vote "\x02\x03 helLo"')
|
|
||||||
self.assertRegexp('votes Hello', ".*?1.*?voted to.*?")
|
|
||||||
|
|
||||||
def testCheatStripFormatting(self):
|
|
||||||
self.assertError('cheat 30 " "')
|
|
||||||
self.assertNotError('cheat 30 " lose the game\x02 "')
|
|
||||||
self.assertRegexp('votes lose the game ', ".*?30.*?voted to.*?")
|
|
||||||
|
|
||||||
def testAdminOverride(self):
|
|
||||||
conf.supybot.plugins.voteserv.allowAdminOverride.setValue(True)
|
|
||||||
try:
|
|
||||||
u = ircdb.users.newUser()
|
|
||||||
u.name = 'abcde'
|
|
||||||
ircdb.users.setUser(u)
|
|
||||||
self.assertNotError('capability add abcde admin')
|
|
||||||
self.assertNotError('vote test something')
|
|
||||||
self.assertNotError('vote test something')
|
|
||||||
finally:
|
|
||||||
conf.supybot.plugins.voteserv.allowAdminOverride.setValue(False)
|
|
||||||
ircdb.users.delUser(u.id)
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
|
Loading…
x
Reference in New Issue
Block a user