Willie

From Omnia
Revision as of 15:00, 23 January 2015 by Kenneth (talk | contribs) (→‎Configure)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Willie

Willie - Willie - The Python IRC Bot - http://willie.dftba.net/

Install

Dependencies: [1]

sudo yum install libxml2-devel libxslt-devel enchant
sudo pip install feedparser pytz lxml praw pyenchant pygeoip
sudo pip install IPython

Install Willie

sudo pip install willie

Python 2.7 has a bug, to fix:

# error: ImportError: No module named backports.ssl_match_hostname
sudo pip install backports.ssl_match_hostname

Execute

To run Willie, run as a non root user:

$ willie

To fork (background):

$ willie -f

Configure

To configure, run as a non root user, and answer the few questions:

$ willie

This will create the config directory:

~/.willie/
~/.willie/default.cfg

Note: when specifying a channel, make sure to prefix with "#"

~/.willie/default.cfg

[core]
nick = billybob
host = myirc.server.com
use_ssl = False
port = 6667
owner = billyowner
channels = #billybob,#somethingelse

admins = user1,user2
enable = echo,help,adminchannel,autoop

Usage

.help
.commands
.c 5 / 2

Modules

Note: multiple modules can be placed into the same file.

# ~/.willie/modules/helloworld.py
import willie

# .hello world
@willie.module.commands('helloworld')
def helloworld(bot, trigger):
    bot.say('Hello, world!')
# ~/.willie/modules/echo.py
import willie

# .echo with arguments
@willie.module.commands('echo')
def echo(bot, trigger):
    bot.reply(trigger.group(2))
# ~/.willie/modules/hi.py
import willie

# regex
@willie.module.rule('hello!?')
def hi(bot, trigger):
    bot.say('Hi, ' + trigger.nick)

Core modules exist here:

/opt/python-2.7.9/lib/python2.7/site-packages/willie/modules/

References:

Core Modules

Core modules exist here:

/opt/python-2.7.9/lib/python2.7/site-packages/willie/modules/
adminchannel.py - op, deop, 
admin.py
announce.py
bugzilla.py
calc.py
chanlogs.py
clock.py
countdown.py
currency.py
dice.py
etymology.py
find.py
find_updates.py
github.py
help.py - help, commands
ip.py
ipython.py
isup.py
lmgtfy.py
meetbot.py
movie.py
ping.py
radio.py
rand.py
reddit.py
reload.py
remind.py
rss.py
safety.py
search.py
seen.py
spellcheck.py
tell.py
tld.py
translate.py
unicode_info.py
units.py
uptime.py
url.py
version.py
weather.py
wikipedia.py
wiktionary.py
xkcd.py
youtube.py

Custom Modules

admins can op themselves

Owner/Admins can op themselves

--- adminchannel.py.old 2015-01-22 15:12:31.893968888 -0700
+++ adminchannel.py     2015-01-22 15:11:25.985975053 -0700
@@ -37,8 +37,12 @@
     Command to op users in a room. If no nick is given,
     willie will op the nick who sent the command
     """
-    if bot.privileges[trigger.sender][trigger.nick] < OP:
-        return
+    #if bot.privileges[trigger.sender][trigger.nick] < OP:
+    #    return
+    if not (trigger.nick == bot.config.owner or
+         trigger.nick in bot.config.admins.split(',') or
+         bot.privileges[trigger.sender][trigger.nick] == OP):
+             return
     if bot.privileges[trigger.sender][bot.nick] < OP:
         return bot.reply("I'm not a channel operator!")
     nick = trigger.group(2)

auto op admins

# ~/.willie/modules/autoop.py
import willie

@willie.module.event('JOIN')
@willie.module.rule('.*')
def autoop(bot, trigger):
    nick = trigger.nick
    channel = trigger.sender
    if bot.privileges[channel][bot.nick] < willie.module.OP:
        return # not a channel operator!
    if (nick == bot.config.owner or
        nick in bot.config.admins.split(',')):
            bot.say('Hi, ' + trigger.nick)
            bot.write(['MODE', channel, "+o", nick])

keywords