mttlbot2

mttlbot2 is the name of a project to create a useful bot for the #swig IRC channel. The basis for the project is Bot-BasicBot-Pluggable which has been extended with additional modules. The primary developer is Toby Inkster.

The primary installation of mttlbot2 is a bot that usually hangs out in #swig and #mttlbot on Freenode IRC, amongst other channels. It generally goes by the nickname of mttlbot.

If there are any other channels you'd like mttlbot to frequent, find tobyink on Freenode and ask him.

This page: Source Code | Commands | Modules | Web Query | To Do .

Source Code

The source code is available via subversion at svn://ophelia.g5n.co.uk/perlmods/mttlbot2/. You can also browse the subversion respository using a web browser.

Commands

Some commands need to be "addressed" to mttlbot2. There are two ways of addressing data to mttlbot2 - either send a private message, or prefix a public (channel) message with "mttlbot:" or "mttlbot," (assuming that mttlbot2's nick is "mttlbot"). Some other commands are understood without being explicitly addressed.

Each command supported by mttlbot2 is provided by a module. The modules currently provided by mttlbot2 are described below.

Modules

The following modules are installed on Toby Inkster's instance of mttlbot2:

AccountPasswords

Some other modules (just Relay at the moment) require users to have passwords. This module allows them to set passwords. It's recommended you use private messaging when setting a password. Setting your password in a public channel is a little silly. Passwords are stored in the quad store, so available to anyone. They are SHA1 hashed, but still, I'd recommend not using an especially sensitive password, as it will be vulnerable to dictionary attacks.

joe:      mttlbot: SET PASSWORD newpass oldpass
mttlbot:  joe: Password set for joe.

You can also use SET PASSWORD HASH sha1hash oldpass to set a password by directly supplying a SHA1 hash rather than the plain text password. Use lower-case hex, or else it will not be matched.

There's not currently a password recovery tool.

MicroTurtle

mttlbot2 parses RDF data posted to any channel it's in or received as a private message. It accepts a variant of Turtle called MicroTurtle. Any message that matches the regular expression /#mttl\b/ (i.e. the string #mttl followed by a non-word character such as a space) is treated as MicroTurtle - the part before #mttl is treated as a comment; the part after, as data.

Data is entered as a named graph in mttlbot2's quad store, and a URI for the graph is returned to the user as a reply.

MicroTurtle data does not need to be addressed to mttlbot2.

NickServ

This module doesn't provide any commands. It authenticates mttlbot2 with NickServ.

RDFGraphs

Provides a subset of SPARQL 1.1 Update for graph management.

joe:      mttlbot: LOAD <http://example.com/data.ttl>
mttlbot:  joe: Loaded 9 triples from <http://example.com/data.ttl>.
joe:      mttlbot: CLEAR GRAPH <http://example.com/data.ttl>
mttlbot:  joe: Dropped <http://example.com/data.ttl>.

As well as CLEAR GRAPH and LOAD a shortcut RELOAD is provided to do both in succession. Angled brackets surrounding URIs are optional.

To show the contents of an existing graph, DUMP is also provided:

joe:      mttlbot: DUMP <http://example.com/data.ttl>
mttlbot:  joe: Graph dumped to: <http://esw.pastebin.com/dsgfwsrf>.
joe:      mttlbot: DUMP AS json <http://example.com/data.ttl>
mttlbot:  joe: Graph dumped to: <http://esw.pastebin.com/asdiuerq>.

DUMP AS supports the same output formats as DESCRIBE AS which is provided by RDFQuery.

When loading data, most common RDF formats are supported, including RDF/XML, Turtle, N-Triples, RDF/JSON, RDFa (in XHTML, HTML, SVG, Atom, etc). Also supported are Notation 3 and XRD.

Graph management commands should be explicitly addressed to mttlbot2 or the first word of the command must be capitalised. Otherwise the command is ignored.

There are a handful of graphs internal to mttlbot2 that only administrators are allowed to manage.

RDFQuery

Provides SPARQL 1.1 Query support.

joe:      mttlbot: SELECT DISTINCT ?knower ?knowee WHERE { GRAPH ?g { ?knower foaf:knows ?knowee . } }
mttlbot:  joe: {"knowee":"http://example.com/joe#me","knower":"http://example.com/alice#me"}
mttlbot:  joe: {"knowee":"http://example.com/bob#me","knower":"http://example.com/alice#me"}
mttlbot:  joe: {"knowee":"http://example.com/joe#me","knower":"http://example.com/bob#me"}
joe:      mttlbot: DEFINE who_knows AS SELECT DISTINCT ?knower WHERE { GRAPH ?g { ?knower foaf:knows ?1 . } }
mttlbot:  joe: Defined function 'who_knows' with 1 arguments.
joe:      mttlbot: CALL who_knows <http://example.com/bob#me>
mttlbot:  joe: {"knower":"http://example.com/alice#me"}
joe:      mttlbot: UNDEFINE who_knows/1
mttlbot:  joe: Dropped function who_knows/1

Note function definition is an extension to SPARQL, allowing frequently used SPARQL queries to be saved. Placeholders ?1, ?2, etc are used for function arguments. It's possible to define different functions with the same name provided they take different numbers of arguments. Note that the UNDEFINE command above only deletes the variant of who_knows that takes one argument.

mttlbot2 also provides an extension to SPARQL CONSTRUCT and DESCRIBE queries allowing you to choose the output format.

joe:      mttlbot: DESCRIBE AS Turtle <http://example.com/bob#me>

Formats supported include 'XML', 'N3', 'Turtle', 'N-Triples', 'JSON', 'RDFa' and 'Canonical' (canonicalised N-Triples). The Turtle output is probably the most legible.

SPARQL Query commands should be explicitly addressed to mttlbot2 or the first word of the command must be capitalised (but the latter only works if the first word is 'SELECT', 'ASK', 'CONSTRUCT' or 'DESCRIBE' - not 'BASE' and 'PREFIX'). Otherwise the command is ignored.

RDFStore

This module doesn't provide any commands. It just provides a hook for other modules.

Relay

This module provides message relaying. You give mttlbot the nick that the message is being relayed from (i.e. your nick... somewhat redundant I suppose), your password (from AccountPasswords) the channel to relay the message to, and then the message.

joe:      mttlbot: RELAY joe joespassword #somechannel Hello, this is Joe!
mttlbot:  joe: Will relay that message.

Then in #somechannel:

* mttlbot is relaying message for joe (2010-10-09T22:03:40)
mttlbot:  Hello, this is Joe!

The relay command must either be capitalised, or mttlbot must be addressed directly.

This seems pretty useless, and it is. The idea is to reuse the relay facility in a web-to-IRC gateway.

SemantiKarma

This is a subclass of the standard BasicBot Karma module adapted to store its data in the quad store, using the Karma Ontology.

Note that things that karma is assigned to are implied to be skos:Concepts but you can use RDF to describe how these concepts relate to real world objects.

Whois

This module keeps track of who people are.

joe:      mttlbot: I am <http://example.com/joe#me>
mttlbot:  joe: Got it: <http://example.com/joe#me> foaf:account <irc://chat.example.net/joe,isnick>.
mttlbot:  joe: Loaded 38 triples from <http://example.com/joe#me>.
joe:      mttlbot: Who is alice?
mttlbot:  joe: alice is Alice Smith <http://example.com/alice#me>
          (Last of the freelance hackers and Greatest swordfighter in the world.)
          WWW: <http://users.example.com/~alice/>.
joe:      mttlbot: Who is <http://example.com/alice#me>
mttlbot:  joe: alice is Alice Smith <http://example.com/alice#me>
          (Last of the freelance hackers and Greatest swordfighter in the world.)
          WWW: <http://users.example.com/~alice/>.

The properties understood by the "who is" command are foaf:name, bio:olb and foaf:homepage.

The question mark after "who is" is optional. Angled brackets are optional around URIs. Commands to the Whois module need to be addressed.

Web Query

mttlbot's quad store can be viewed over the Web too!

Describe URI :
Show Graph :

To Do