rhuidean 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ module IRC
14
14
  class Client
15
15
  ##
16
16
  # constants
17
- VERSION = '0.2.2'
17
+ VERSION = '0.2.3'
18
18
 
19
19
  ##
20
20
  # instance attributes
@@ -98,20 +98,32 @@ class Client
98
98
  on(:recvq_ready) { parse }
99
99
  on(:dead) { self.dead = true }
100
100
 
101
+ # Consider ourselves connected on 001
101
102
  on(Numeric::RPL_WELCOME) { log("connected to #@server:#@port") }
102
103
 
104
+ # Keep alive...
103
105
  on(:PING) { |m| raw("PONG :#{m.target}") }
104
106
 
107
+ # Track our nickname...
108
+ on(:NICK) do |m|
109
+ if m.origin =~ /^(#{@nickname})\!(.+)\@(.+)$/
110
+ @nickname = m.params[0]
111
+ end
112
+ end
113
+
114
+ # Track channels
105
115
  on(:JOIN) do |m|
106
116
  @channels << m.target if m.origin =~ /^(#{@nickname})\!(.+)\@(.+)$/
107
117
  end
108
118
 
119
+ # Track channels
109
120
  on(:PART) do |m|
110
121
  if m.origin =~ /^(#{@nickname})\!(.+)\@(.+)$/
111
122
  @channels.delete(m.target)
112
123
  end
113
124
  end
114
125
 
126
+ # Track channels
115
127
  on(:KICK) do |m|
116
128
  @channels.delete(m.target) if m.params[0] == @nickname
117
129
  end
@@ -44,18 +44,18 @@ class EventQueue
44
44
 
45
45
  #
46
46
  # Post a new event to the queue to be handled.
47
+ # Events can be posted more than once per loop,
48
+ # so the callers need to make sure calling the
49
+ # same handlers twice for the same run isn't going
50
+ # to bork something serious like make an otherwise
51
+ # good call become blocking (like read).
47
52
  # ---
48
53
  # event:: event name as a Symbol
49
54
  # args:: list of arguments to pass to handler
50
55
  # returns:: +self+
51
56
  #
52
57
  def post(event, *args)
53
- # Only one post per event per loop, otherwise we end up trying
54
- # to read from a socket that has no data, or stuff like that.
55
- return if m = @queue.find { |q| q.event == event }
56
-
57
58
  @queue << Event.new(event, *args)
58
-
59
59
  self
60
60
  end
61
61
 
@@ -52,6 +52,16 @@ class Client
52
52
  @sendq << "PART #{channel} :#{message}"
53
53
  end
54
54
 
55
+ # Sends an IRC KICK command.
56
+ def kick(channel, target, reason = '')
57
+ @sendq << "KICK #{channel} #{target} :#{reason}"
58
+ end
59
+
60
+ # Sends an IRC TOPIC command.
61
+ def topic(target, new = '')
62
+ @sendq << "TOPIC #{target} :#{new}"
63
+ end
64
+
55
65
  # Sends an IRC MODE command.
56
66
  def umode(mode)
57
67
  @sendq << "MODE #@nickname #{mode}"
@@ -62,6 +72,11 @@ class Client
62
72
  @sendq << "MODE #{target} #{mode}"
63
73
  end
64
74
 
75
+ # Sends an IRC INVITE command.
76
+ def invite(target, channel)
77
+ @senq << "INVITE #{target} #{channel}"
78
+ end
79
+
65
80
  # Send an IRC QUIT command.
66
81
  def quit(message = '')
67
82
  @sendq << "QUIT :#{message}"
data/rakefile CHANGED
@@ -44,7 +44,7 @@ PKG_FILES = FileList['README', 'rakefile',
44
44
 
45
45
  Rake::PackageTask.new('package') do |p|
46
46
  p.name = 'rhuidean'
47
- p.version = '0.2.2'
47
+ p.version = '0.2.3'
48
48
  p.need_tar = false
49
49
  p.need_zip = false
50
50
  p.package_files = PKG_FILES
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  spec = Gem::Specification.new do |s|
54
54
  s.name = 'rhuidean'
55
- s.version = '0.2.2'
55
+ s.version = '0.2.3'
56
56
  s.author = 'Eric Will'
57
57
  s.email = 'rakaur@malkier.net'
58
58
  s.homepage = 'http://github.com/rakaur/rhuidean/'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhuidean
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Will
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-16 00:00:00 -04:00
18
+ date: 2010-09-20 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -31,8 +31,8 @@ files:
31
31
  - README
32
32
  - rakefile
33
33
  - lib/rhuidean.rb
34
- - lib/rhuidean/client.rb
35
34
  - lib/rhuidean/event.rb
35
+ - lib/rhuidean/client.rb
36
36
  - lib/rhuidean/methods.rb
37
37
  - lib/rhuidean/numeric.rb
38
38
  - lib/rhuidean/timer.rb