GorillaBot

GorillaBot is an IRC bot written in Python.

View project on GitHub

GorillaBot

GorillaBot is an IRC bot framework written in Python. The bot is initiated from the command line. Once it is connected, it receives its commands through IRC. Because I'm writing the framework mainly for use in a channel frequented by Wikipedia editors, there are a number of Wikipedia-specific commands.

Author: Molly White
License: MIT
Status: Unstable
Version: 2.0

Installation

Download code from the master branch. Code in the rewrite branch is often incomplete and non-functional.

  1. Run python3 bot.py from the source directory. This will step you through configuring the bot. If you already have already configured the bot, you can use that configuration or create a new one.
  2. Enter any information when prompted.
  3. Once the bot has successfully connected, command the bot from IRC. There are also a number of admin commands available to bot operators.

Commanding the bot

The bot receives commands in one of three ways:

  1. Detecting a word preceded by an exclamation point: !command
  2. Receiving a message addressed to it directly: GorillaBot: command or GorillaBot: !command
  3. Receiving a command in a private message: /msg GorillaBot command

In the examples below, I use the !command syntax, but the other two would work equally well.

All-user commands

admincommands

Aliases: admincommandlist

!admincommands
< GorillaWarfare> !admincommands
< GorillaBot> My available admin commands are join, part, quit, setcommand,
              and unset. See http://molly.github.io/GorillaBot for documentation.

Say the available admin-only commands. This does not display command aliases.

adminlist

Aliases: admins, botops, oplist

!adminlist
< GorillaWarfare> !adminlist
< GorillaBot> My bot admin is GorillaWarfare.

Say the current bot operators.

attention

Aliases: pingall, highlightall

!attention
< GorillaWarfare> !attention
< GorillaBot> user1, user2, user3: GorillaWarfare wants your attention

Ping all of the users in the channel.

Settings

on - Anyone can use this command. Be sure you trust everyone in the channel not to abuse it. admin - Only bot admins can use this command.

bash

Aliases: b, qdb

!bash [number]
< GorillaWarfare> !bash
< GorillaBot> --- #64 (859) http://bash.org?64 ----------------------------------------------
< GorillaBot> <Ash> Win2k! ^_^
< GorillaBot> *** Ash Quit (Read error: 73 (Connection reset by peer))
< GorillaBot> -------------------------------------------------------------------------------
< GorillaWarfare> !bash 400459
< GorillaBot> --- #400459 (13378) http://bash.org?400459 ------------------------------------
< GorillaBot> <Sonium> someone speak python here?
< GorillaBot> <lucky> HHHHHSSSSSHSSS
< GorillaBot> <lucky> SSSSS
< GorillaBot> <Sonium> the programming language
< GorillaBot> -------------------------------------------------------------------------------

Post a quote from bash.org. If given a quote number, it will try to post it. Otherwise it will post a random quote. If the quote is too long, it will direct the user to the URL. Please note that there is no filtering here, so some of the quotes may be inappropriate.

commands

Aliases: commandlist, help

!commands
< GorillaWarfare> !commands
< GorillaBot> My available commands are admincommands, adminlist, commands, hug,
              link, spotify, and xkcd. See http://molly.github.io/GorillaBot
              for documentation.

Say the available all-user commands. This does not display command aliases.

eightball

Aliases: 8ball, 8-ball

!8ball [question]
< GorillaWarfare> !8ball
< GorillaBot> Most likely.

Returns a magic 8 ball response.

flirt

Aliases: pickupline, flirts

!flirt [user ...]
< GorillaWarfare> !flirt
< GorillaBot> I'm a fermata... hold me.
< GorillaWarfare> !flirt user
< GorillaBot> user: If you were a booger I'd rearrange the alphabet so you fell from heaven!

Flirts at the user or the channel.

hug

Aliases: hugs, glomp

!hug [user ...]
< GorillaWarfare> !hug
* GorillaBot distributes tackle-glomps evenly among the channel
< GorillaWarfare> !hug user
* GorillaBot tackles user

Hugs the user or the channel.

link

!link URL
< GorillaWarfare> !link http://molly.github.io/GorillaBot/
< GorillaBot> Link: GorillaBot
< GorillaWarfare> !link https://www.youtube.com/watch?v=aSarf4-REgk
< GorillaBot> Link: "Baby Gorilla Reunites With Mother" (01:43). Uploaded Mar 24,
              2014. 164347 views. 513 likes, 32 dislikes.
< GorillaWarfare> !link [[Gorilla]]
< GorillaBot> https://en.wikipedia.org/wiki/Gorilla

Provide information about the given link, or provide a link to the English Wikipedia article if formatted as a wikilink.

In order to provide rich information about YouTube videos, you must provide a YouTube API key when configuring the bot. You can get an API key by registering a project in the Google Developer Console. Without a key, the normal linking will be used.

Settings

  • auto - All links and wikilinks entered in the chat will be parsed, regardless of whether they're prefaced with !link.

spotify

!spotify URI
< GorillaWarfare> !spotify spotify:track:6NmXV4o6bmp704aPGyTVVG
< GorillaBot> "Bøn Fra Helvete (Live)" by Kaizers Orchestra

Provide information about the Spotify URI. Accepts Spotify- and HTTP-style URIs.

Settings

  • auto - All Spotify URIs in the chat will be parsed, regardless of whether they're prefaced with !spotify.

weather

!weather [--now|--week] location
< GorillaWarfare> !weather boston
< GorillaBot> Weather in Boston, MA, USA: Rain until tomorrow evening and breezy until
              tomorrow morning. 51˚F (10˚C). Feels like 51˚F (10˚C). Humidity: 95%. Wind
              speed: 23mph (38kph).
< GorillaWarfare> !weather --now boston
< GorillaBot> Weather in Boston, MA, USA: Light Rain and Breezy. 51˚F (10˚C). Feels like
              51˚F (10˚C). Humidity: 96%. Wind speed: 25mph (40kph).
< GorillaWarfare> !weather --week boston
< GorillaBot> Weather in Boston, MA, USA: Light rain throughout the week, with temperatures
              bottoming out at 53°F on Friday. 51–55˚F (11–13˚C).

Provide weather information for the given location. Defaults to giving weather information about today. Given the --now parameter, this will give the current weather. Given the --weekly parameter, this will give the forecast for the week.

In order to provide weather information, you must provide a Forecast.io API key when configuring the bot. You can get an API key by registering an email address at http://developer.forecast.io/.

xkcd

Aliases: relevantxkcd

!xkcd [number|query]
< GorillaWarfare> !xkcd batman acne
< GorillaBot> xkcd: Complexion: http://xkcd.com/700/
< GorillaWarfare> !xkcd 700
< GorillaBot> xkcd: Complexion: http://xkcd.com/700/
< GorillaWarfare> !xkcd
< GorillaBot> xkcd: Telescope Names: http://xkcd.com/1294/

Without any arguments, this provides a random xkcd comic. When a number is supplied, it tries to return the xkcd comic with that given number. When a query string is supplied, it tries to return the xkcd comic that most closely matches that query.

Admin-only commands

join

!join #channel

Joins the specified channel. Only joins one channel at a time.

part

Aliases: leave

!part [#channel] [message]

Parts from the specified channel, or the current channel if unspecified. Only parts from one channel at a time. If a message is included, this will be used as the part message.

quit

Aliases: shutdown

!quit [message]

Quits the bot from the network and shuts down.

setcommand

Aliases: set

!set setting value [#channel]
< GorillaWarfare> !set link auto
< GorillaBot> "link" set to "auto" in ##GorillaBot.

Change settings for a command. Allowed and default settings for a command are viewable in the command's documentation. Settings can only be edited for channels the bot is joined to, or has been joined to in the past.

unset

!unset setting [#channel]
< GorillaWarfare> !unset link
< GorillaBot> "link" unset for ##GorillaBot.

Removes the setting for a channel. This will revert to the default value. Settings can only be edited for channels the bot is joined to, or has been joined to in the past.