Module: Ponder::IRC

Included in:
Thaum
Defined in:
lib/ponder/irc.rb

Instance Method Summary collapse

Instance Method Details

#action(recipient, message) ⇒ Object

perform an action



42
43
44
# File 'lib/ponder/irc.rb', line 42

def action(recipient, message)
  raw "PRIVMSG #{recipient} :\001ACTION #{message}\001"
end

#away(message = nil) ⇒ Object

set an away status



86
87
88
89
90
91
92
# File 'lib/ponder/irc.rb', line 86

def away(message = nil)
  if message
    raw "AWAY :#{message}"
  else
    raw "AWAY"
  end
end

#backObject

cancel an away status



95
96
97
# File 'lib/ponder/irc.rb', line 95

def back
  away
end

#ban(channel, address) ⇒ Object

ban an user



105
106
107
# File 'lib/ponder/irc.rb', line 105

def ban(channel, address)
  mode channel, "+b #{address}"
end

#invite(nick, channel) ⇒ Object

invite an user to a channel



100
101
102
# File 'lib/ponder/irc.rb', line 100

def invite(nick, channel)
  raw "INVITE #{nick} #{channel}"
end

#join(channel, password = nil) ⇒ Object

joining a channel



52
53
54
55
56
57
58
# File 'lib/ponder/irc.rb', line 52

def join(channel, password = nil)
  if password
    raw "JOIN #{channel} #{password}"
  else
    raw "JOIN #{channel}"
  end
end

#kick(channel, user, reason = nil) ⇒ Object

kick a user



33
34
35
36
37
38
39
# File 'lib/ponder/irc.rb', line 33

def kick(channel, user, reason = nil)
  if reason
    raw "KICK #{channel} #{user} :#{reason}"
  else
    raw "KICK #{channel} #{user}"
  end
end

#message(recipient, message) ⇒ Object

send a message



11
12
13
# File 'lib/ponder/irc.rb', line 11

def message(recipient, message)
  raw "PRIVMSG #{recipient} :#{message}"
end

#mode(recipient, option) ⇒ Object

set a mode



28
29
30
# File 'lib/ponder/irc.rb', line 28

def mode(recipient, option)
  raw "MODE #{recipient} #{option}"
end

#notice(recipient, message) ⇒ Object

send a notice



23
24
25
# File 'lib/ponder/irc.rb', line 23

def notice(recipient, message)
  raw "NOTICE #{recipient} :#{message}"
end

#part(channel, message = nil) ⇒ Object

parting a channel



61
62
63
64
65
66
67
# File 'lib/ponder/irc.rb', line 61

def part(channel, message = nil)
  if message
    raw "PART #{channel} :#{message}"
  else
    raw "PART #{channel}"
  end
end

#quit(message = nil) ⇒ Object

quitting



70
71
72
73
74
75
76
77
78
# File 'lib/ponder/irc.rb', line 70

def quit(message = nil)
  if message
    raw "QUIT :#{message}"
  else
    raw 'QUIT'
  end
  
  @config.reconnect = false # so Ponder does not reconnect after the socket has been closed
end

#raw(message) ⇒ Object

raw IRC messages



4
5
6
7
8
# File 'lib/ponder/irc.rb', line 4

def raw(message)
  @connection.send_data "#{message}\r\n"
  @logger.info ">> #{message}"
  @console_logger.info ">> #{message}"
end

#registerObject

register when connected



16
17
18
19
20
# File 'lib/ponder/irc.rb', line 16

def register
  raw "NICK #{@config.nick}"
  raw "USER #{@config.username} * * :#{@config.real_name}"
  raw "PASS #{@config.password}" if @config.password
end

#rename(nick) ⇒ Object

rename



81
82
83
# File 'lib/ponder/irc.rb', line 81

def rename(nick)
  raw "NICK :#{nick}"
end

#topic(channel, topic) ⇒ Object

set a topic



47
48
49
# File 'lib/ponder/irc.rb', line 47

def topic(channel, topic)
  raw "TOPIC #{channel} :#{topic}"
end