Module: LibertyBot

Defined in:
lib/libertybot/prefix.rb,
lib/libertybot.rb,
lib/libertybot/bot.rb,
lib/libertybot/client.rb,
lib/libertybot/message.rb

Overview

Some IRC Bot vim: sw=2 ts=2 ai et

Copyright © 2011 Fritz Grimpen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Classes: Bot, Client, Message, Prefix

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clientObject

Returns the value of attribute client.



27
28
29
# File 'lib/libertybot.rb', line 27

def client
  @client
end

#nickObject

Returns the value of attribute nick.



27
28
29
# File 'lib/libertybot.rb', line 27

def nick
  @nick
end

#prefixObject

Returns the value of attribute prefix.



27
28
29
# File 'lib/libertybot.rb', line 27

def prefix
  @prefix
end

#realnameObject

Returns the value of attribute realname.



27
28
29
# File 'lib/libertybot.rb', line 27

def realname
  @realname
end

#split_patternObject

Returns the value of attribute split_pattern.



27
28
29
# File 'lib/libertybot.rb', line 27

def split_pattern
  @split_pattern
end

#usernameObject

Returns the value of attribute username.



27
28
29
# File 'lib/libertybot.rb', line 27

def username
  @username
end

Instance Method Details

#command(command, &block) ⇒ Object



47
48
49
50
# File 'lib/libertybot.rb', line 47

def command(command, &block)
  @commands = {} unless @commands
  @commands[command] = block
end

#connectObject



41
42
43
44
45
# File 'lib/libertybot.rb', line 41

def connect
  @client.connect
  @client.send("USER #{username} localhost localhost :#{realname}\r\n")
  @client.send("NICK #{nick}\r\n")
end

#initialize(client) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/libertybot.rb', line 29

def initialize(client)
  @client = client
  @nick = nil
  @username = nil
  @realname = nil
  @prefix = "!"
  @split_pattern = /[\s]+/
  @commands = {}

  setup
end