Linkbot

From Zach

Jump to: navigation, search
Linkbot
Author: Zachary Hauri
Programming language(s): Perl
License: GPL

Linkbot is a bot for Internet Relay Chat.

Contents

[edit] Installation

To install linkbot from SVN, run the following command:

svn checkout http://code.zachhauri.com/svn/linkbot linkbot

Copy the directory tree to your $HOME directory.

[edit] Perl modules

Linkbot requires the following perl modules:

Debian users can use the following command:

# apt-get install libnet-irc-perl libwww-perl libtime-piece-perl liburi-perl libwww-shorten-perl libwww-google-calculator-perl

(Debian doesn't have packages for Config-INI-Simple, so you'll need to install that with CPAN)

Otherwise, use CPAN:

cpan> install Config::INI::Simple Net::IRC LWP Time::Piece URI WWW::Shorten WWW::Google::Calculator

[edit] MySQL

Logs of !seen are stored in a MySQL database. You can create the tables using the .sql file included in the ~/bin/upgrading/ directory, and, if you already have logs stored in ~/logs/linkbotseen.log, you can use the enclosed perl script in that directory to convert them to MySQL.

[edit] Configuration

To configure linkbot to your needs, copy the enclosed ~/etc/linkbot.ini-dist to ~/etc/linkbot.ini, and edit it to your needs.

[edit] Channel options

  • addr: Enables the !addr command
  • autojoin: Auto-join the channel on startup
  • bit: Enables the !bit and !q commands
  • calc: Enables the !calc and !convert commands
  • date: Enables the !date command
  • help: Enables the !help command
  • inviteonly: Access to channel requires a self-invitation
  • linkhost: Full URL before the page title to use for linkification
  • linkify: Enables linkification
  • respondpm: Responds in a msg
  • seen: Enables the !seen command
  • source: Enables the !source command
  • stats: Enables the !stats command
  • time: Enables the !time command
  • tinyurl: Enables the !tinyurl command
  • tinyurl_links: Linkificated urls are printed as a tinyurl
  • weather: Enables the !weather command
  • xm: Enables the !xm command

[edit] Commands

[edit]  !addr

Syntax: !addr hex IP

This command converts a CGI:IRC hexadecimal IP address to a decimal IP, and provides a link to the contributions page of that IP.

The hex IP should be eight hexadecimal characters (0-9, a-f), and will appear in the hostname of the nick. In the following example:

  • i=4ba83221@gateway/web/cgi-irc/wikizine.org/x-610ffb0824c95f81

The hex IP would be 4ba83221, and would be converted to the decimal IP of 75.168.50.33.

[edit]  !bit

Syntax: !bit question

This command randomly returns a bit (0 or 1). It is a simplified version of the !q command below.

[edit]  !calc

Syntax: !calc equation

This command returns the answer of an equation. It uses Google Calculator to calculate and return the answer.

[edit]  !convert

Syntax: !convert equation

This command is the same as !calc.

[edit]  !date

Syntax: !date

This command prints the current GMT date. This is the same date as the servers for Wikinews.

[edit]  !help

Syntax: !help

This command prints a link to this page.

[edit]  !q

Syntax: !q question

This command randomly returns a yes or no. In essence, you can "ask" it a yes or no question, and it will answer it. The !bit command is a simpler version, which returns just a 0 (no) or 1 (yes).

[edit]  !seen

Syntax: !seen nick

This command tells you the last time it has seen a particular nick on IRC. It will return the date/time in GMT, the channel, and the last thing that person said.

[edit]  !source

Syntax: !source

This command returns a link to this page.

[edit]  !stats

Syntax: !stats

This command prints statistics for the random answer functions. It provides the number of times each answer has been used, and the percentage of that answer compared to the total number of answers.

[edit]  !sys

Syntax: !sys command parameters

This command allows the linkbot to perform system functions, such as channel joins, quits, access list editing, and more. It is only accessible through PM.

A list of sys commands is available here.

[edit]  !time

Syntax: !time locale

This command displays the current time in select locations around the world. If you pass a locale, it'll return just the time in that particular place. Not many locales are supported yet, unfortunately. For a list of the times on the Freenode Wikilinker, see this page.

[edit]  !tinyurl

Syntax: !tinyurl url

This command prints a short URL which redirects to a long URL using TinyURL.

[edit]  !weather

Syntax: !weather ICAO airport code

This command prints the most currently recorded weather conditions at a particular airport.

A list of the ICAO airport codes is available here.

[edit]  !xm

Syntax: !xm station#

This command prints the song currently playing on a particular XM Satellite Radio station.

Personal tools
projects