Skip to content

mike-rogers/scalabot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

------------------------------
Introduction
------------------------------

This is a simple irc bot written in scala.

Right now it has fourteen commands:
    1. The "%pom" command will output the phase of the mooon.
    2. The "%crime" command will randomize two superheroes known for crimefighting.
    3. The "%calc" command will try to execute the remainder of the privmsg as an RPN statement.
    4. The "%roll" command will roll a certain number of dice. For example, 2d4 will add 2 four-sided dice.
    5. The "%stock" command will return the current stock value for a given ticker symbol.
    6. The "%tweet" command. See 'Configuring the Tweet Command' for more information.
    7. The "%utime" command will return the current Unix time in seconds since the epoch (1970-01-01)
    8. The "%faq" command returns an answer to a frequently asked question. Example: %faq help
    9. The "%faqadd" command adds an answer to the FAQ. Example: %faqadd help This is the text that will show up
    10. The "%faqdel" command removes an answer from the FAQ. Example: %faqdel help
    11. The "%tell" command will leave a message for someone who's not currently logged in
    12. The "%ack" command will delete all %tell messages left for you in a specific channel
    13. The "%alert" command messages you after X minutes. Example: %alert 60 put laundry in dryer
    14. The "%spell" command uses a Yahoo! web service to get suggestions for your misspellings. See Yahoo! section below.

------------------------------
Configuration
------------------------------

To configure, have a file called 'config.xml' in the root of your classpath. Mine looks like this:

<server name="freenode"
        url="irc.freenode.net"
        nick="your_nick_here"
        identify="your_nickserv_pass_here">
    <channel name="#test_channel"/>
</server>

You can add as many channels as you wish.

------------------------------
Compiling and Running
------------------------------

Prior to your first compilation, you will need to install the PircBot library in Maven. To do this, download the library from http://www.jibble.org/pircbot.php, unzip, and run the following command:

mvn install:install-file -Dfile=pircbot-1.5.0/pircbot.jar -DgroupId=pircbot -DartifactId=pircbot -Dversion=1.5.0 -Dpackaging=jar

I compile with: mvn assembly:assembly

I run with: java -cp target/scalabot-0.1-SNAPSHOT-jar-with-dependencies.jar org.cansado.scalabot.ScalaBot

------------------------------
Configuring the Database
------------------------------

First you'll want to create the database (I use MySQL). Grant all permissions to some username and password pair.

Edit the file src/main/resources/dbconfig.properties. Mine looks like this:

db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost/scalabot
db.username=scalabot
db.password=mySecretPasswordOmg

You'll want to run all the scripts in the db/ directory to create the tables necessary to run the commands.

------------------------------
Configuring the Tweet Command
------------------------------

The %tweet command is intended to be a gateway from an IRC channel to a single Twitter account. Right now you can only post to the Twitter account from IRC.

To configure the %tweet command, you'll need to register an account with Twitter. You'll then need to log in to this new account and visit http://twitter.com/apps/new to register this bot as a new application. This will get you your 'consumerKey' and 'consumerSecret'.

Then you'll need to compile the application per 'Compiling and Running', and run with: java -cp target/scalabot-0.1-SNAPSHOT-jar-with-dependencies.jar org.cansado.scalabot.twitter.Configurator

When prompted, enter your consumerKey and consumerSecret. You will then be asked to visit a URL. Go there and 'approve' the application. You'll be presented with a PIN, which you will then need to enter at the Configurator prompt.

The Configurator will spit out your 'tokenKey' and 'tokenSecret'. You now have everything you need to configure the %tweet command. Here's a sample config.xml:

<server name="server-identifier"
	url="server.url"
	nick="bot-nickname">
  <channel name="#yourchannel">
    <twitter name="twitter-name"
	     consumerKey="consumerKey"
	     consumerSecret="consumerSecret"
	     tokenKey="tokenKey"
	     tokenSecret="tokenSecret"/>
  </channel>
</server>

------------------------------
Configuring Yahoo! Services
------------------------------

The Yahoo! web services require a unique application ID to be registered with Yahoo!. To configure, you'll need to visit https://developer.apps.yahoo.com/projects and register your project to obtain an AppID.

Once you have your AppID, modify your config.xml:

<server name="server-identifier"
	url="server.url"
	nick="bot-nickname">
  <channel name="#yourchannel">
    <yahoo appId="your-yahoo-app-id"/>
  </channel>
</server>

------------------------------

If you have any questions, feel free to add to the wiki or do whatever. I don't know github yet.

About

Rudimentary IRC bot written in Scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages