ichverstehe-isaac 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/isaac.gemspec +2 -2
  2. data/lib/isaac.rb +42 -4
  3. metadata +2 -2
data/isaac.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "isaac"
3
- s.version = "0.0.3"
4
- s.date = "2008-12-11"
3
+ s.version = "0.0.4"
4
+ s.date = "2009-01-28"
5
5
  s.summary = "The smallish DSL for writing IRC bots"
6
6
  s.email = "ichverstehe@gmail.com"
7
7
  s.homepage = "http://github.com/ichverstehe/isaac"
data/lib/isaac.rb CHANGED
@@ -13,7 +13,7 @@ module Isaac
13
13
  app.execute(params, &block)
14
14
  end
15
15
 
16
- Config = Struct.new(:nick, :server, :port, :username, :realname, :version, :verbose)
16
+ Config = Struct.new(:nick, :server, :port, :username, :realname, :version, :verbose, :password)
17
17
 
18
18
  # These are top level methods you use to construct your bot.
19
19
  class Application
@@ -91,7 +91,8 @@ module Isaac
91
91
  puts "Connecting to #{@config.server} at port #{@config.port}"
92
92
  @irc = TCPSocket.open(@config.server, @config.port)
93
93
  puts "Connection established."
94
-
94
+
95
+ @irc.puts "PASS #{@config.password}" if @config.password
95
96
  @irc.puts "NICK #{@config.nick}"
96
97
  @irc.puts "USER #{@config.username} foobar foobar :#{@config.realname}"
97
98
 
@@ -138,7 +139,11 @@ module Isaac
138
139
  end
139
140
  when /^PING (\S+)/
140
141
  #TODO not sure this is correct. Damned RFC.
141
- @queue << "PONG #{$1}"
142
+ if registered?
143
+ @queue << "PONG #{$1}"
144
+ else
145
+ @irc.puts "PONG #{$1}"
146
+ end
142
147
  when /^:\S+ PONG \S+ :excess/
143
148
  @queue.lock = false
144
149
  end
@@ -223,7 +228,28 @@ module Isaac
223
228
  def notice(recipient, text)
224
229
  raw("PRIVMSG #{recipient} :#{text}")
225
230
  end
226
-
231
+
232
+ # Set modes(s)
233
+ # mode "#awesome" "+im"
234
+ # mode "arnie" "+o-v"
235
+ # mode "#awesome" "+k" "password"
236
+ def mode(target, mode, option=nil)
237
+ option = " #{option}" if option
238
+ raw "MODE #{target} #{mode}#{option}"
239
+ end
240
+
241
+ # Ban a hostmask
242
+ # ban_mask "#awesome" "*!*@*"
243
+ def ban_mask(channel, mask)
244
+ mode channel, "+b", mask
245
+ end
246
+
247
+ # Unban a hostmask
248
+ # unban_mask "#awesome" "*!*@*"
249
+ def unban_mask(channel, mask)
250
+ mode channel, "-b", mask
251
+ end
252
+
227
253
  # Join channel(s):
228
254
  # join "#awesome_channel"
229
255
  # join "#rollercoaster", "#j-lo"
@@ -248,6 +274,18 @@ module Isaac
248
274
  def topic(channel, topic)
249
275
  raw("TOPIC #{channel} :#{topic}")
250
276
  end
277
+
278
+ # Invite nicks to channel
279
+ # invite "#awesome_channel", "arnie"
280
+ # invite "#awesome_channel", "arnie", "brigitte"
281
+ def invite(channel, *nicks)
282
+ nicks.each {|nick| raw("INVITE #{nick} #{channel}")}
283
+ end
284
+
285
+ # Change nickname
286
+ def set_nick(nickname)
287
+ raw("NICK #{nickname}")
288
+ end
251
289
  end
252
290
  end
253
291
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ichverstehe-isaac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Vangberg
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-11 00:00:00 -08:00
12
+ date: 2009-01-28 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15