diff --git a/Darkfallonline/__init__.py b/Darkfallonline/__init__.py deleted file mode 100644 index c0312c8..0000000 --- a/Darkfallonline/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -### -# Copyright (c) 2012, Valentin Lorentz -# 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/Darkfallonline/download' - -from . import config -from . import plugin -from imp import reload -reload(plugin) # In case we're being reloaded. -# 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/Darkfallonline/config.py b/Darkfallonline/config.py deleted file mode 100644 index c0eec06..0000000 --- a/Darkfallonline/config.py +++ /dev/null @@ -1,52 +0,0 @@ -### -# Copyright (c) 2012, Valentin Lorentz -# 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 -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('Darkfallonline') - -def configure(advanced): - # This will be called by supybot to configure this module. advanced is - # 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. - from supybot.questions import expect, anything, something, yn - conf.registerPlugin('Darkfallonline', True) - - -Darkfallonline = conf.registerPlugin('Darkfallonline') -# This is where your configuration variables (if any) should go. For example: -# conf.registerGlobalValue(Darkfallonline, 'someConfigVariableName', -# registry.Boolean(False, _("""Help for someConfigVariableName."""))) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: diff --git a/Darkfallonline/plugin.py b/Darkfallonline/plugin.py deleted file mode 100644 index f44542f..0000000 --- a/Darkfallonline/plugin.py +++ /dev/null @@ -1,138 +0,0 @@ -### -# Copyright (c) 2012, Valentin Lorentz -# 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 requests -from BeautifulSoup import BeautifulSoup - -import supybot.utils as utils -import supybot.world as world -from supybot.commands import * -import supybot.plugins as plugins -import supybot.ircmsgs as ircmsgs -import supybot.schedule as schedule -import supybot.ircutils as ircutils -import supybot.callbacks as callbacks -from supybot.i18n import PluginInternationalization, internationalizeDocstring - -_ = PluginInternationalization('Darkfallonline') - -servers = (('US1', 'http://www.us1.darkfallonline.com/news'), - ('EU1', 'http://www.eu1.darkfallonline.com/news'), - ) -login = 'https://ams.darkfallonline.com/AMS/' - -CHANNEL = '#progval' - -def check_status(url): - up = False - soup = BeautifulSoup(requests.get(url).text) - status = "players" - server = "US1" - status = {'players': False, 'gms': False, 'mastergms': False, - 'admins': False} - - for img in soup.findAll('img'): - for type_ in status: - if img["src"].startswith("images/%s_online" % type_): - status[type_] = True - return status - -def check_login_status(url): - return requests.head(url).status_code == 200 - -def write_errors(f): - def newf(*args, **kwargs): - try: - f(*args, **kwargs) - except Exception as e: - import traceback - traceback.print_exc(e) - return - return newf - -@internationalizeDocstring -class Darkfallonline(callbacks.Plugin): - """Add the help for "@plugin help Darkfallonline" here - This should describe *how* to use this plugin.""" - threaded = True - - def __init__(self, irc): - super(Darkfallonline, self).__init__(irc) - self._state = {} - for server, url in servers: - self._state[server] = check_status(url) - self._login = check_login_status(login) - schedule.addPeriodicEvent(self._announcer, 10, - 'Darkfallonline_checkstatus') - def die(self): - schedule.removeEvent('Darkfallonline_checkstatus') - - @write_errors - def _announcer(self): - for server, url in servers: - status = self._state[server] - new_status = check_status(url) - for irc in world.ircs: - if CHANNEL in irc.state.channels: - for type_ in new_status: - if new_status[type_] == status[type_]: - continue - elif new_status[type_]: - msg = '[%s] %s is going up' % (server, - type_.capitalize()) - else: - msg = '[%s] %s is going down' % (server, - type_.capitalize()) - irc.queueMsg(ircmsgs.privmsg(CHANNEL, msg)) - self._state[server] = new_status - - new_login_status = check_login_status(login) - if new_login_status == self._login: - pass - elif new_login_status: - irc.queueMsg(ircmsgs.privmsg(CHANNEL, '[login] Going up')) - else: - irc.queueMsg(ircmsgs.privmsg(CHANNEL, '[login] Going down')) - self._login = new_login_status - - def status(self, irc, msg, args): - """takes no arguments - - Return the status of all servers.""" - for server, status in self._state.items(): - irc.reply('Up on %s: %s' % (server, - format('%L', [x.capitalize() for x,y in status.items() if y]) or 'none'), - private=True) - irc.reply('Login: %s' % ('on' if self._login else 'off'), private=True) - -Class = Darkfallonline - - -# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: diff --git a/Darkfallonline/test.py b/Darkfallonline/test.py deleted file mode 100644 index 775c99f..0000000 --- a/Darkfallonline/test.py +++ /dev/null @@ -1,37 +0,0 @@ -### -# Copyright (c) 2012, Valentin Lorentz -# 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 DarkfallonlineTestCase(PluginTestCase): - plugins = ('Darkfallonline',) - - -# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: