<commit_before># Jabbot

## Description

Jabbot is a Ruby micro-framework for creating Jabber/MUC bots,
heavily inspired by Sinatra and Twibot.

I modified the code of Twibot to fit my needs.
The original Twibot code is located at:
http://github.com/cjohansen/twibot/tree/master

A big thank you to <NAME>, who wrote the code for Twibot.
Jabbot is heavily based on his code.

## Usage

### Simple example

    # Receive messages, and post them publicly
    message do |message, params|
      post message.text
    end

    # Respond to query if they come from the right crowd
    # post "message" => "user" is just some syntax sugar
    # post "message", "user" will work to
    query :from => [:cjno, :irbno] do |message, params|
      post "#{message.user} I agree" => message.user
    end

    # Log every single line
    # (you can use "message :all" too ;)
    message do |message, params|
      MyApp.log_message(message)
    end

### Running the bot

To run the bot, simply do:

    ruby bot.rb

Jabbot uses the [at\_exit hook](http://ruby-doc.org/core/classes/Kernel.html#M005932) to start.

### Configuration

Jabbot looks for a configuration file in ./config/bot.yml. It should contain
atleast:

    login: jabber_login
    password: <PASSWORD>
    channel: channel_to_join
    server: server_to_connect_to
    nick: mybot

You can also configure with Ruby:

    configure do |conf|
      conf.login = "my_account"
      conf.nick = "mybot"
    do

If you don't specify login and/or password in any of these ways, Jabbot will fail
Nick is automatically set to "jabbot" unless something different is defined
If you want you can set the Jabber Resource:

    configure do |conf|
      conf.resource ="mybot_resource"

    end

Default is "jabbot".

### "Routes"

Like Sinatra, and other web app frameworks, Jabbot supports "routes":
patterns to match incoming tweets and messages:

    message "time :country :city" do |message, params|<commit_msg>improved readme docu<commit_after># Jabbot

## Description

Jabbot is a Ruby micro-framework for creating Jabber/MUC bots,
heavily inspired by Sinatra and Twibot.

I modified the code of Twibot to fit my needs.
The original Twibot code is located at:
http://github.com/cjohansen/twibot/tree/master

A big thank you to <NAME>, who wrote the code for Twibot.
Jabbot is heavily based on his code.

If your curious if this code is stable enough:
I have a bot instance running on my server for quite some time now
and it works great :)

## Usage

### Simple example

    # Receive messages, and post them publicly
    message do |message, params|
      post message.text
    end

    # Respond to query if they come from the right crowd
    # query "message" => "user" is just some syntax sugar
    # query "message", "user" will work to
    query :from => [:cjno, :irbno] do |message, params|
      post "#{message.user} I agree" => message.user
    end

    # Log every single line
    # (you can use "message :all" too ;)
    message do |message, params|
      MyApp.log_message(message)
    end

### Running the bot

To run the bot, simply do:

    ruby bot.rb

Jabbot uses the [at\_exit hook](http://ruby-doc.org/core/classes/Kernel.html#M005932) to start.

### Configuration

Jabbot looks for a configuration file in ./config/bot.yml. It should contain
atleast:

    login: jabber_login
    password: <PASSWORD>
    channel: channel_to_join
    server: server_to_connect_to
    nick: mybot

You can also configure with Ruby:

    configure do |conf|
      conf.login = "my_account"
      conf.nick = "mybot"
    do

If you don't specify login and/or password in any of these ways, Jabbot will fail
Nick is automatically set to "jabbot" unless something different is defined
If you want you can set the XMPP Resource:

    configure do |conf|
      conf.resource ="mybot_resource"
    end

Default is "jabbot".

### "Routes"

Like Sinatra, and other web app frameworks, Jabbot supports "routes":
patterns to match incoming messages:

    message "time :country :city" do |message, params|
{'fraction_non_alphanumeric': 0.08283877349159248, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 3.298618490967056, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3447634', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1227, 'n_words': 522}