sopel

From IndieWeb


sopel is a Python based IRC bot.

IRC Bridge Example

The following setup will allow you to engage the #indieweb-dev chat from your own site by both backfeeding others' messages and POSSEing your own messages. See chat#Brainstorming for prior efforts at microformat patterns.

$ pip install sopel
$ sopel
...follow wizard to initialize, accept defaults...

YourIRCName should match your entry on chat-names. YourSiteName can be any valid nick -- it isn't used. Overwrite ~/.sopel/default.cfg with the following.

[core]
nick = YourIRCName
host = irc.freenode.net
use_ssl = true
port = 6697
owner = YourSiteName
channels = #indieweb-dev
enable = indiechatbridge

You implement backfeed() and posse_queue. Install the following at ~/.sopel/modules/indiechatbridge.py.

from sopel.module import rule, interval

@rule(".*")
def message_received(bot, trigger):
    entry = {"author": str(trigger.nick),
             "published": trigger.time,
             "content": str(trigger)}
    backfeed(entry)

@interval(.1)
def posse(bot):
    message = posse_queue.pop()
    if message:
        bot.msg("#indieweb-dev", message)

Start the bot.

$ sopel

See Also