Giter VIP home page Giter VIP logo

cs583-project's Introduction

hasbot (CS583 Project)

Build Status

This is an IRC bot that exposes haskell functions over a chat interface. More details can be found in Proposal.doc

Link to the project: https://github.com/maxking/cs583-project

Project Members:

  • Abhilash Raj
  • Deepthi S Kumar

Dependencies

How to Run

To run this project, you can build this project by:

$ git clone https://github.com/maxking/cs583-project
$ cd cs583-project
$ cabal build

Then you can run the program like:

$ ./dist/build/hasbot/hasbot

This will run the bot and connect it to IRC (Internet Relay Chat) network. To interact with the bot, open an irc client or a web client and join the channel ##maxking and you will find the bot there with nick hasbot.

For now, the bot just responds to simple IRC commands like

>!hi
Hello!

> !add 3 4
7

> !neg -9
9

Anything else that you type is echo'd back from the bot.

Features

  • hasbot connects to Frenode network by default and joins ##maxking channel
  • It logs all the conversation on the channel internally
  • Logs are accesible through web at http://localhost:3000
  • The webserver and irc bot run in two seperate threads that are created using forkIO.
  • hasbot responds to the commands on the channel ##maxking and also over private message.
  • !help command presents a list of all the availabe commands along with usage for each of the commands.
  • !search commands accepts one or more words to search in the history of the channel. The searching algorithm itself is naive and slows down as the length of the channel history increases.

TODO

  • Make it easy to add more commands (right now only !add and !neg commands are available)

Internal Design

All messages are of type IrcMessage and have following important attributes:

  • mNick : Nickname of the sender
  • mUser : Realname of the sender
  • mHost : Hostname of the sender
  • mServer: Server address of the sender
  • mCode : IRC code for the message, almost always defaults to PRIVMSG
  • mChan : Sent to, either a channel or to the channel or nick
  • mOrigin : Sent by, if private message then sender else channel
  • mRaw : Raw message.

When a message is received, it can be of three types:

  1. Sent to the channel
  2. Sent to the channel but starting with hasbot: to highlight
  3. Sent as private message to the bot

In each of the three cases above we perform the following actions:

  • 1: Just log the message to a file
  • 2: Parse the command in the message and respond to the sender with a response on the channel that the command was recieved on
  • 3: Do the same processing as (2) but send the response as private message to sender

The raw message extracted from the IrcMessage is then parsed to get a value of ChatMsg type. The parser is written using the parsec parser combinator library.

A ChatMsg can be a command or some text. A command is prefixed by "!" symbol and followed by arguments New commands can be easily added without any changes required at the command processing level. This is facilitated by the higher order abstract syntax of the Command data type. The user who wants to add new commands can do so by defining two functions, one to convert the arguments from String to the required types (transform) and the other which performs the operation (execute).

The example commands hi, neg and add that takes zero, one and two arguments repectively can be used as reference to add new commands.

The type of transform function is [String] -> a and that of execute function is a -> String. The type parameter a here needs to same only for the command that is being defined and not all the commands. This is achieved by using existential types.

Design Questions

  • Handling messages that are not commands. There is no framework for dealing with such messages. They are simply echo'd back to the channel.

  • How to make the design modular so that commands can be added over the chat interface itself.

cs583-project's People

Contributors

deepthiskumar avatar maxking avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

deepthiskumar

cs583-project's Issues

do not return entire error message.

<hasbot> (line 1, column 11):
<hasbot> unexpected end of input
<hasbot> "hey" not found

Do not show the whole error message, only the last line is relevant to the user.

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.