progval / Supybot-plugins

Collection of plugins for Supybot/Limnoria I wrote or forked.
https://github.com/ProgVal/Limnoria/
107 stars 63 forks source link

TWSS - error on "load twss" #307

Closed 7MinSec closed 6 years ago

7MinSec commented 8 years ago

Hey there,

The TWSS plugin looks like a riot. When I tell the bot to "load twss" I get "The operation succeeded" however the "twss" doesn't fire when a match from twss.txt is said. In the logs I see:

Exception in thread Thread-254: Traceback (most recent call last): File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/usr/lib/python3.4/threading.py", line 868, in run self._target(_self._args, *_self._kwargs) File "/home/brian/bot/plugins/TWSS/plugin.py", line 58, in _import_twss import twss ImportError: No module named 'twss'

Is this a python3 compatibility thing?

Brian

progval commented 8 years ago

Is this a python3 compatibility thing?

Indeed. Fixed.

7MinSec commented 8 years ago

Hey thanks again for quick fix. I pulled the plugin down and ran it today and the console says:

Exception in thread Thread-103: Traceback (most recent call last): File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/usr/lib/python3.4/threading.py", line 868, in run self._target(_self._args, *_self._kwargs) File "/home/brian/bot/plugins/TWSS/plugin.py", line 58, in _import_twss from . import twss File "/home/brian/bot/plugins/TWSS/twss.py", line 51 print last ^

SyntaxError: Missing parentheses in call to 'print'

progval commented 8 years ago

Fixed.

7MinSec commented 8 years ago

Hi there! I grabbed the new version and activated it, and now when I say a TWSS trigger in the channel, I no longer get errors. But the bot also doesn't chime in with "that's what she said." Best I can tell the plugin is either "enabled" or not. Am I missing the obvious?

progval commented 8 years ago

Any error in the console? Is supybot.plugins.TWSS.enable set to true on the channel?

7MinSec commented 8 years ago

Well I did this in my channel: !config supybot.plugins.twss.enable true. Is there anymore to it? And nope, the console looks clean this time.

progval commented 8 years ago

what is the reply to !config channel #channelname supybot.plugins.twss.enable?

7MinSec commented 8 years ago

The bot says "True" on both channels I've tried to enable it for.

progval commented 8 years ago

In TWSS/plugin.py, replace:

    def doPrivmsg(self, irc, msg):
        if self.registryValue('enable', msg.args[0]) and self._twss:
            jenni = Jenny()
            self._twss.say_it(jenni, msg.args[1])
            if jenni._msg:
                irc.reply(jenni._msg)

with:

    def doPrivmsg(self, irc, msg):
        print('--- a')
        print(self.registryValue('enable', msg.args[0]))
        print(bool(self._twss))
        if self.registryValue('enable', msg.args[0]) and self._twss:
            print('---- b')
            jenni = Jenny()
            self._twss.say_it(jenni, msg.args[1])
            print('---- c')
            if jenni._msg:
                print('---- d')
                irc.reply(jenni._msg)
                print('---- e')

Then reload the plugin. What does it show in the console this time?

7MinSec commented 8 years ago

Code changed and code reloaded - I don't seem to see any change in console output.

progval commented 8 years ago

That means the code is not actually run. Make sure you don't have an other instance of TWSS instealled somewhere else (check the directories listed in supybot.directories.plugins), that you remove .pyc files, etc.

7MinSec commented 8 years ago

Sorry I should've been more clear - in the console I see "unload called in private by..." and "load called in private by ..." in the console when I unload/reload TWSS, but should I be seeing something else?

progval commented 8 years ago

I understood that, but could you check the things I mentioned in my previous post?

7MinSec commented 8 years ago

Sure. My .conf file says my supybot.directories.plugins is /home/brian/bot/plugins. Inside that directory I have Trivia and TWSS

That's the only place I have tried to put TWSS in the past, but I did a locate for twss.py just in case and it wasn't anywhere else on the machine.

When you say "remove .pyc" files could you provide more specifics? I'm not sure which ones to look for and delete.

progval commented 8 years ago

Nevermind. could you load the Debug plugin, and tell me the output of @eval __import__(irc.getCallback('GitHub').__module__)?

7MinSec commented 8 years ago

Is this what you're looking for? The command didn't run with @ in front of it but when running without:

screen shot 2016-09-27 at 3 00 01 pm
progval commented 8 years ago

Oops, sorry, wrong command. @eval __import__(irc.getCallback('TWSS').__module__)

7MinSec commented 8 years ago

If I chat that to the bot with @ I get @eval is not a valid command. If I run without @ I get:

<module 'TWSS' from '/home/brian/bot/plugins/TWSS/__init__.py'>
progval commented 8 years ago

What is the output of grep print /home/brian/bot/plugins/TWSS/plugin.py? (run it in a shell)

7MinSec commented 8 years ago

Sure:

print('--- a') print(self.registryValue('enable', msg.args[0])) print(bool(self._twss)) print('---- b') print('---- c') print('---- d') print('---- e')

progval commented 8 years ago

What if you restart the bot?

7MinSec commented 8 years ago

This weekend I shut it down, did a git pull and fired it back up again. I also just shut 'er down and restarted a few moments ago, but still no "TWSS" getting triggered when we say things inside of twss.txt.

progval commented 8 years ago

Try rm -f /home/brian/bot/plugins/TWSS/*.pyc and rf -rf /home/brian/bot/plugins/TWSS/__pycache__/ and restart the bot

7MinSec commented 8 years ago

Did all those things and bot still remains silent. Question though - does it treat the bot OWNER any differently or should it respond to me too? So far I've just made the bot join an alt channel from my primary and tried to say things in the channel to generate a TWSS response. One thing I can try this weekend is just joining as a regular user from a Web client and see if I can get a TWSS response.

progval commented 8 years ago

does it treat the bot OWNER any differently

Not in that case.

Does the bot answer to you when you use other commands?

7MinSec commented 8 years ago

Yep, it'll respond fine to !learn !factoid etc. no problem.

progval commented 8 years ago

Could you give me the output of @eval __import__(irc.getCallback('TWSS').plugin.__module__) (on IRC) and the content of /home/brian/bot/plugins/TWSS/plugin.py?

7MinSec commented 8 years ago

Pardon the delay, I must've missed this email!

Output of @eval __import__(irc.getCallback('TWSS').plugin.__module__) on IRC is:

braimee: An error has occurred and has been logged. Check the logs for more information.

And the output of plugin.py is:

###
# 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 threading

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('TWSS')

class Jenny:
    _msg = None
    def say(self, msg):
        self._msg = msg

@internationalizeDocstring
class TWSS(callbacks.Plugin):
    """Add the help for "@plugin help TWSS" here
    This should describe *how* to use this plugin."""

    def __init__(self, irc):
        super(TWSS, self).__init__(irc)
        self._twss = None
        threading.Thread(target=self._import_twss).start()

    def _import_twss(self):
        from . import twss
        self._twss = twss

def doPrivmsg(self, irc, msg):
        print('--- a')
        print(self.registryValue('enable', msg.args[0]))
        print(bool(self._twss))
        if self.registryValue('enable', msg.args[0]) and self._twss:
            print('---- b')
            jenni = Jenny()
            self._twss.say_it(jenni, msg.args[1])
            print('---- c')
            if jenni._msg:
                print('---- d')
                irc.reply(jenni._msg)
                print('---- e')

Class = TWSS

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
progval commented 8 years ago

Ok, I found the problem. This line:

def doPrivmsg(self, irc, msg):

should have one indentation level, to be in the class. Like this:

    def doPrivmsg(self, irc, msg):
7MinSec commented 8 years ago

I moved to a brand new VPS, installed Limnoria and TWSS from scratch, verified the def doPrivmsg(self, irc, msg): was indented right, and I'm still not getting the bot to say "TWSS" when triggers are said. Sorry for the trouble but dang, I really want this to work. Can I re-run some debugging/troubleshooting commands to show you what's up?

progval commented 8 years ago

Could you show me the full content of plugin.py and the reply to !config channel #channelname supybot.plugins.twss.enable?

7MinSec commented 8 years ago

Pardon the delay. Here's plugin.py:

###
# 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 threading

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('TWSS')

class Jenny:
    _msg = None
    def say(self, msg):
        self._msg = msg

@internationalizeDocstring
class TWSS(callbacks.Plugin):
    """Add the help for "@plugin help TWSS" here
    This should describe *how* to use this plugin."""

    def __init__(self, irc):
        super(TWSS, self).__init__(irc)
        self._twss = None
        threading.Thread(target=self._import_twss).start()

    def _import_twss(self):
        from . import twss
        self._twss = twss

    def doPrivmsg(self, irc, msg):
        if self.registryValue('enable', msg.args[0]) and self._twss:
            jenni = Jenny()
            self._twss.say_it(jenni, msg.args[1])
            if jenni._msg:
                irc.reply(jenni._msg)

Class = TWSS

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

And here's the output for !config channel #mychannel supybot.plugins.twss.enable

[Bot] True