Giter VIP home page Giter VIP logo

rubot's Introduction

Rubot is a framework for creating IRC bots.

Installation

gem install rubot
rubot new botname
cd botname
bundle install 
vim config.yml
bundle exec rubot server
nohup bundle exec rubot server & 

Usage

Rubot::Controller adds functionality to the class, namely the message method. message is an instance of the message that matched a listener or triggered a command.

You can get the message sender's nick from message.from

adding a command

class WebLinkController < Rubot::Controller
  command :calc do
    reply Google.calc(:q => message.text)
  end
  
  command :google, :g do
    reply Google.lmgtfy_url_for(message.text)
  end
end

using listeners

class SubstitutionsController < Rubot::Controller
  listener :matches => /hello/ do
    reply "hello, #{message.from}"
  end
end

adding resources

A resource is just a class or module that is a source of data. Resources are looked for in APP_ROOT/resources

module Google
  def self.lmgtfy_url_for(query)
    "http://www.lmgtfy.com/?q=#{CGI.escape(query)}"
  end
end

using Rubot::WebResource

Rubot ships with a Rubot::WebResource class that can be subclassed to add simple web scraping functionality.

class Google < Rubot::WebResource
  get :calc, "http://www.google.com/search" do |doc|
    doc.css(".r")[0].text
  end
end

generate a migration

rake db:migration migration_name

migrate the database

rake db:migrate

NOTE: both the migrations and the sqlite database itself are stored within APP_ROOT/db

use database in a resource

class Fact < Sequel::Model
  def self.random
    # this is a pretty shitty way of getting a random record
    DB["select * from facts order by random() limit 1"].first
  end
end

now Fact.random can be used from a controller

why should I use rubot to build my IRC bot?

  1. provides a very simple DSL for quickly adding commands
  2. can update the application via git and reload

Future

  • incorporate some resources, commands, listeners as core configurable extensions/plugins?

Authors

Chris Thorn (@thorncp)

Matt Culpepper (@mculp)

rubot's People

Contributors

thorncp avatar mculp avatar rsdehart avatar

Stargazers

 avatar  avatar Sliim avatar Kazuya Takeshima avatar Tim Heckman avatar Pavel avatar Richard Wilson avatar caojiafeng avatar Leandro Araújo avatar Becky Boone avatar  avatar tanduy avatar  avatar Jason Jones avatar

Watchers

 avatar Pavel avatar James Cloos avatar  avatar

rubot's Issues

Web Service Manager

Create manager for using web resources. This could possibly be a part of the Resource Manager, or at least in the same module.

Improved Command Aliases

Find some way for commands to take advantage of aliases, either by passing a block when defining them, or just a message.alias that holds the name that was used to invoke the command, or... some other solution.

Logging

Implement an unobtrusive logger

Message Replies

See about having commands set a reply variable on messages instead of calling server.msg themselves. It'd be nice to get server out of the commands all together, but it is used for things other than .msg, like access to the connection time, sending actions, and possibly other things.

Message Splitting Seems Broken

Sending long messages doesn't seem to be splitting them. Instead, it just sends the max characters and the remaining text is lost.

Smarter Message Breaking

See about breaking long winded messages on a punctuation mark, so they are split in a grammatically meaningful manner to improve readability.

Refactor database loading

Hardcoding the database name is not very friendly, and the code that does it is in a terrible location.

NEW RELEASE

Last gem pushed out was version 0.2, and there have been 128 commits since then. Need to push out a new release now.

Message Queue

Need a message queue with a delay so we don't get excess flood kicked for long winded messages

Bug with message parsing

Using the following command

command :raw, :protected => true do
  puts message.text
  server.raw message.text
end

and executing the command

!raw PRIVMSG #channel :derp

message.text is empty. The incoming string is

:thorncp!~thorncp@server PRIVMSG #channel :!raw PRIVMSG #channel :derp

Resource Manager

Let's see about creating a resource manager to handle concurrency with accessing resource files.

Rake Tasks

Rake tasks for generating commands, listeners, and runners.

Help

A command to list available commands, and any options they might have.

Depends on #25

RDoc Source Code

Comment the hell out of everything, you'll thank yourself down the road.

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.