Hi, I've encountered what seems to be a bug when using the commands plugin.
Here's the fairly simple plugin.
import irc3
from irc3.plugins.command import command
import pipeau
@irc3.plugin
class Plugin:
def __init__(self, bot):
self.bot = bot
@command(permission='view')
def eddy_malou(self, mask, target, args):
"""Quotes from http://eddy-malou.com.
%%eddy_malou
"""
msg = yield from pipeau.eddy_malou()
yield msg
@asyncio.coroutine
def load_page_source_async(url):
loop = asyncio.get_event_loop()
page_source = yield from loop.run_in_executor(None, load_page_source, url) # error seems to come from here
return page_source
@asyncio.coroutine
def eddy_malou():
"""Coroutine loading a quote from http://www.pipotronic.com."""
page_source = yield from load_page_source_async('http://eddy-malou.com')
soup = BeautifulSoup(page_source)
base_element = soup.find('p', { 'id': 'maloutot' })
return element_contents(base_element)
ERROR asyncio Exception in callback <bound method event.async_callback of <bound event :(?P<mask>\S+) PRIVMSG (?P<target>\S+) :{re_cmd}(?P<cmd>\w+)(\s(?P<data>\S.*)|$) to <bound method Commands.on_command of <Commands ['!eddy_malou', '!help', '!ping', '!pipotronic']>>>>({'mask': '[email protected]', 'target': '#pipotronic', 'data': None, 'cmd': 'eddy_malou'},)
handle: Handle(<bound method event.async_callback of <bound event :(?P<mask>\S+) PRIVMSG (?P<target>\S+) :{re_cmd}(?P<cmd>\w+)(\s(?P<data>\S.*)|$) to <bound method Commands.on_command of <Commands ['!eddy_malou', '!help', '!ping', '!pipotronic']>>>>, ({'mask': '[email protected]', 'target': '#pipotronic', 'data': None, 'cmd': 'eddy_malou'},))
Traceback (most recent call last):
File "/usr/local/lib/python3.4/asyncio/events.py", line 39, in _run
self._callback(*self._args)
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/dec.py", line 55, in async_callback
return self.callback(**kwargs)
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/plugins/command.py", line 253, in on_command
return self.do_command(predicates, meth, mask, target, **kw)
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/plugins/command.py", line 309, in do_command
callback(res)
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/plugins/command.py", line 320, in command_callback
handle = self.context.call_many('privmsg', iterator(msgs))
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/base.py", line 275, in call_many
for i, arg in enumerate(args):
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/plugins/command.py", line 316, in iterator
for msg in msgs:
File "/home/jmcomets/Bundle/irc_bots/plugin.py", line 28, in eddy_malou
msg = yield from pipeau.eddy_malou()
File "/home/jmcomets/Bundle/irc_bots/pipeau.py", line 38, in eddy_malou
page_source = yield from load_page_source_async('http://eddy-malou.com')
File "/home/jmcomets/Bundle/irc_bots/pipeau.py", line 24, in load_page_source_async
page_source = yield from loop.run_in_executor(None, load_page_source, url)
File "/usr/local/lib/python3.4/asyncio/futures.py", line 349, in __iter__
assert self.done(), "yield from wasn't used with future"
AssertionError: yield from wasn't used with future
ERROR asyncio Exception in callback <bound method IrcBot.privmsg of <irc3.IrcBot object at 0x7ff8a280eb38>>('#pipotronic', Future<PENDING, [<function wrap_future.<locals>._check_cancel_other at 0x7ff8a23da488>]>)
handle: TimerHandle(97160.945039665, <bound method IrcBot.privmsg of <irc3.IrcBot object at 0x7ff8a280eb38>>, ('#pipotronic', Future<PENDING, [<function wrap_future.<locals>._check_cancel_other at 0x7ff8a23da488>]>))
Traceback (most recent call last):
File "/usr/local/lib/python3.4/asyncio/events.py", line 39, in _run
self._callback(*self._args)
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/__init__.py", line 180, in privmsg
for message in messages:
File "/home/jmcomets/.local/lib/python3.4/site-packages/irc3/utils.py", line 114, in split_message
if len(message) >= max_length:
TypeError: object of type 'Future' has no len()