Giter VIP home page Giter VIP logo

botplate's Introduction

BotPlate

A Java IRC bot template-ish thing.

IRCBot.java

This contains the core functionality of the IRC bot. The constructor takes as arguments:

  • IRC Server
  • Channel
  • Bot Nickname
  • Port to connect to the server

It contains functions to write messages to a channel/person, as well as to write generic IRC commands.

Most importantly, it contains a collection of MessageHandler objects. The collection of MessageHandlers are initialized to contain a ping handler. On receiving the PING message from the server, this handler responds with a corresponding PONG message so the server does not drop our connection.

There exists an addHander function which allows a user to extend their bot with any MessageHandler object.

When a bot receives a message, it will iterate over all its MessageHandlers and call the handle function on the message.

MessageHandler.java

This is an abstract class with a concrete constructor, which takes the IRCBot it will be handling messages for as an argument, and stores it as an instance variable called bot.

There is exactly one abstract method:

abstract void handle(Message message);

Where Message is an object corresponding to the parts defined in the IRC client protocol, RFC 2812

Create MessageHandlers and add them to instances of IRCBots to augment their functionality.

App.java

An example IRCBot implementation, which contains a MessageHandler that when it hears "hello exampleBot" in the channel, it responds with "Hey!"

botplate's People

Contributors

mgaut72 avatar

Stargazers

D avatar Lauren Anglin avatar Chris avatar

Watchers

James Cloos avatar  avatar Chris avatar Lauren Anglin avatar

Forkers

seanastephens

botplate's Issues

YouTube handler

Write a message handler that captures !meme <search terms> that does a Google video search to find most relevant video and echoes the link and shorttext back into the channel.

Example usage:

<cwvh> compress twice for half the savings
<jane> !yt hank hill do I look like a jpeg
<botplate> http://youtu.be/QEzhxP-pdos - "For when someone posts a compressed image/uses Windows XP to save a jpeg..."
<cwvh> exactly.

General Bot Ideas

If anyone has bot ideas that they wanted to throw out, toss 'em in here.

Implement validation and error checking in IRCProtocol.Message

There is currently a validate method stubbed out.

Right now, Any IRC server that is speaking the correct protocol will not cause problems.
However, an ill-formatted message will cause us to crash.

Validation and error checking should be implemented according to RFC 2812

Perhaps an exception should be thrown on an invalid message, or maybe just return null. That is still up for discussion.

Regardless, IRCBot should not go down on an invalid message.

Logging

Add application level logging with a logging library like log4j. For bonus, add the ability to write logs to IRC to help with remote debugging.

add help handler

Some handler that responds to !<botname> help or maybe just !help

This might include adding another abstract method to the handler class, which is something like

abstract string getHelpMessage();

This way, the help handler could iterate over all the bots handlers and tell us about the functionality of each handler the bot has

Add Message Parser Class

Currently MessageHandler works with raw IRC messages.

It would be nice for the core bot to parse incoming messages into some object that corresponds to an IRC message according to the IRC client protocol, RFC 2812

MessageHandler would then have to be changed to work with Messages rather than raw strings

Build instructions

Edit the top-level README.md to include how to build BotPlate and have the bot join #ufoa-acm channel on freenode.

Be sure to lookup how to stylize your instructions with Markdown so that they are easy to read!

Fix removal of space characters from trailing in max parameters case of message

According to the IRC Protocol there are 2 cases for message parameters.

The current implementation of Message.java removes the prefix and the command, then splits by a space character to seperate the parameters and trailing part of the message.

In the case where the separation between the parameters is implicit due to there being exactly 14 parameters, all space characters will be removed from the trailing part of the message.

First write a test case which exercises this bug, then fix it.

Use configuration file for bot parameters

Modify BotPlate to read from a configuration file for its username, IRC network, port, etc. This could change the API of IRCBot.java or you might have another class that reads configuration and then constructs an IRCBot. Investigate modern configuration formats such as XML, YAML, JSON.

Dependency injection

BotPlate should be testable on a local developer machine without requiring a network connection or actual IRC server. Investigate the use of a dependency injection framework such as Google Guice.

New to DI? You can start with a video describing what "factories" are, and how DI makes code simpler to read, easier to test, and easier to modify.

Fix code style using Eclipse

Java has a some fairly established guidelines for formatting source code. This task would be to re-format all the source files in BotPlate. Eclipse can do this, but be careful, you might accidentally have hard tabs enabled!

When making stylistic fixes it is important to change only the style. Do not be tempted to fix code or make new features as it makes reading the changes as a reviewer very difficult.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.