Add files via upload

This commit is contained in:
Gordon Shumway 2019-05-29 20:47:15 -04:00 committed by GitHub
parent 430a4e6fea
commit 960beba552
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 284 additions and 0 deletions

8
UndernetX/README.md Normal file
View File

@ -0,0 +1,8 @@
Logs into Undernet's X Service
## Setup
* configure the plugin by setting `plugins.UndernetX.auth.password` and `plugins.UndernetX.auth.username`
* If you want your bot to /mode +x on login, make sure to set
`plugins.UndernetX.modeXonID` to `True` if it isn't already.

67
UndernetX/__init__.py Normal file
View File

@ -0,0 +1,67 @@
###
# Copyright (c) 2013, Ken Spencer
# 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
import importlib
# 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"
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.Author("Ken Spencer", "kspencer", "ken@electrocode.net")
# 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/UndernetX/download'
from . import config
from . import plugin
importlib.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:

65
UndernetX/config.py Normal file
View File

@ -0,0 +1,65 @@
###
# Copyright (c) 2013, Ken Spencer
# 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
import supybot.ircutils as ircutils
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('UndernetX')
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('UndernetX', True)
UndernetX = conf.registerPlugin('UndernetX')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(UndernetX, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerGlobalValue(UndernetX, 'modeXonID',
registry.Boolean(True, _("""Whether or not to mode +x on ID""")))
conf.registerGroup(UndernetX, 'auth')
# /msg X@channels.undernet.org login username password
conf.registerGlobalValue(UndernetX.auth, 'username',
registry.String("", _("""Username for X""")))
conf.registerGlobalValue(UndernetX.auth, 'password',
registry.String("", _("""Password for X""")))
conf.registerGlobalValue(UndernetX.auth, 'xservice',
registry.String("X@channels.undernet.org", _("""XService hostmask""")))
conf.registerGlobalValue(UndernetX.auth, 'noJoinsUntilAuthed',
registry.Boolean(True, _("""Don't join until we're authed.""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

107
UndernetX/plugin.py Normal file
View File

@ -0,0 +1,107 @@
###
# Copyright (c) 2017, Ken Spencer
# 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.log as log
import supybot.ircmsgs as ircmsgs
import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('UndernetX')
@internationalizeDocstring
class UndernetX(callbacks.Plugin):
"""Logins to Undernet's X Service"""
threaded = True
def __init__(self, irc):
global instance
instance = self
self.__parent = super(UndernetX, self)
callbacks.Plugin.__init__(self, irc)
instance.irc = irc
def _login(self, irc):
username = self.registryValue('auth.username')
password = self.registryValue('auth.password')
xserv = self.registryValue('auth.xservice')
irc.sendMsg(ircmsgs.privmsg(xserv, "login {} {}".format(username, password)))
def doNotice(self, irc, msg):
if irc.state.supported.get('NETWORK', '') == 'UnderNet':
if 'X!cservice@undernet.org' in msg.prefix:
if 'AUTHENTICATION SUCCESSFUL as' in msg.args[1]:
log.info("Successfully authed to X.")
modex = self.registryValue('modeXonID')
if modex:
log.info("Setting +x")
irc.sendMsg(ircmsgs.IrcMsg("MODE {} +x".format(irc.nick)))
else:
log.info("Received a NOTICE from X. msg: {}".format(msg.args[1]))
return
else:
if 'AUTHENTICATION SUCCESSFUL as' in msg.args[1]:
log.warning("Someone is impersonating X!")
else:
log.debug("Notice isn't from UnderNet.. Ignoring")
def do376(self, irc, msg):
"""Watch for the MOTD and login if we can"""
if irc.state.supported.get('NETWORK', '') == 'UnderNet':
if self.registryValue('auth.username') and self.registryValue('auth.password'):
log.info("Attempting login to XService")
else:
log.warning("username and password not set, this plugin will not work")
return
self._login(irc)
# Similar to Services->Identify
def login(self, irc, msg, args):
"""takes no arguments
Logins to Undernet's X Service"""
if irc.state.supported.get('NETWORK', '') == 'UnderNet':
if self.registryValue('auth.username') and self.registryValue('auth.password'):
log.info("Attempting login to XService")
else:
log.warning("username and password not set, this plugin will not work")
return
self._login(irc)
else:
log.error("We're not on UnderNet, we can't use this.")
irc.error("We're not on UnderNet, this is useless.")
login = wrap(login, ['admin'])
Class = UndernetX
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

37
UndernetX/test.py Normal file
View File

@ -0,0 +1,37 @@
###
# Copyright (c) 2013, Ken Spencer
# 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 DDateTestCase(PluginTestCase):
plugins = ('UndernetX',)
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: