numberoverzero / bottom

asyncio-based rfc2812-compliant IRC Client
http://bottom-docs.readthedocs.io
MIT License
76 stars 23 forks source link

Example on README isn't working #25

Closed Inconditus closed 8 years ago

Inconditus commented 8 years ago

the example posted on the README:

import bottom

NICK = 'bottom-bot'
CHANNEL = '#python'

bot = bottom.Client('localhost', 6697)

@bot.on('CLIENT_CONNECT')
def connect(**kwargs):
    bot.send('NICK', nick=NICK)
    bot.send('USER', user=NICK, realname='Bot using bottom.py')
    bot.send('JOIN', channel=CHANNEL)

@bot.on('PING')
def keepalive(message, **kwargs):
    bot.send('PONG', message=message)

@bot.on('PRIVMSG')
def message(nick, target, message, **kwargs):
    """ Echo all messages """

    # Don't echo ourselves
    if nick == NICK:
        return
    # Respond directly to direct messages
    if target == NICK:
        bot.send("PRIVMSG", target=nick, message=message)
    # Channel message
    else:
        bot.send("PRIVMSG", target=target, message=message)

# This schedules a connection to be created when the bot's event loop
# is run.  Nothing will happen until the loop starts running to clear
# the pending coroutines.
bot.loop.create_task(bot.connect())

# Ctrl + C to quit
bot.loop.run_forever()

is giving me this error:

Traceback (most recent call last):
  File "bottom_test.py3", line 38, in <module>
    bot.loop.create_task(bot.connect())
AttributeError: 'Client' object has no attribute 'loop'

Running python 3.5.1, bottom==0.9.13.

numberoverzero commented 8 years ago

EDIT: github doesn't parse markdown from email replies, or even after editing the reply on their site. That's some hot garbage, but apparently also a known issue.

Thanks for the report!

The sample will work in 1.0.0 which is on github but not pushed to pypi (which is on 0.9.13)

For now, you can install 1.0.0 from github with

pip install git+https://github.com/numberoverzero/bottom

0.9.13 had some significant code issues, and while the public api didn't change much, internally the event system was almost entirely rewritten, along with the irc protocol handling. And the test scaffolding. Everything but pack and unpack, really.

While I expect the 1.0.0 release to happen this weekend, I want to make sure I've done one last design review. The kind of changes between 0.9.13 and 1.0.0 won't be possible after this.

Inconditus commented 8 years ago

Thanks!

numberoverzero commented 8 years ago

I just released the 1.0.0 version on pypi, you should be able to pip install bottom and run the README.