eventmachine-irc-server 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 138f3644f1d3ebf1a7cd250cfa72a336218e00d6
4
- data.tar.gz: ad4e1a6e69ae6b366650ba8d5c4f3b803cce3760
3
+ metadata.gz: 89cec7714a3b186cb5a15eed9870a30d370918b0
4
+ data.tar.gz: 706ce3004bf5889e1f4215f14c63b52bf16bc6bf
5
5
  SHA512:
6
- metadata.gz: 767b155e0c9e47f4f7eaeffadd07f6fb7d56b2cd3ae70e4bb17e4c836d983f01c0b0fe5c0bbc18d1c784ab2d60ad9f3af6065ec6dd47ef767ae95b5c5679e450
7
- data.tar.gz: ae96a913cbc3aac185fec64764bd88e5b2882104d751859e92865d4c1569e13929f02aefc57899efe7e558e18738bdebd25d7e564eed59139304d818c30dd9da
6
+ metadata.gz: cfbf172bbe480992b31e3a71ca90b9975cb894f72669d9cdcce097486be79db7e46505985417ae8d7be4d8f990c900f2ba302462cbc45f36c6ada90e0ca8cb7e
7
+ data.tar.gz: 43ef89e01439c6677f3456f6aa821f9eeca399866a0c5d58a6216765d29d9e4f5a35234e8cf2472e326d9f2f29786a85da667f46b1f028d5604a9ede7215d3af
@@ -10,7 +10,7 @@ require_relative 'server/replies'
10
10
  include EventMachine::IRC::Replies
11
11
 
12
12
  def carp(message)
13
- puts message
13
+ #puts message
14
14
  end
15
15
 
16
16
  module EventMachine
@@ -113,7 +113,7 @@ module EventMachine
113
113
  #verify the connectivity of earlier guy
114
114
  reply :numeric, ERR_NICKNAMEINUSE, "* #{nick} ", "Nickname is already in use."
115
115
  @nick_tries += 1
116
- if @nick_tries > $config['nick-tries']
116
+ if @nick_tries > Server.config['nick-tries']
117
117
  carp "kicking spurious user #{nick} after #{@nick_tries} tries"
118
118
  handle_abort
119
119
  end
@@ -3,7 +3,7 @@ require 'eventmachine'
3
3
  module EventMachine
4
4
  module IRC
5
5
  class Server < EventMachine::Connection
6
- VERSION = "0.0.1"
6
+ VERSION = "0.0.2"
7
7
  end
8
8
  end
9
9
  end
@@ -15,7 +15,7 @@ module EventMachine
15
15
  module IRC
16
16
  class Client
17
17
  def unbind(reason)
18
- log Logger::INFO "Unbind reason: #{reason}" if reason != nil
18
+ #log Logger::INFO "Unbind reason: #{reason}" if reason != nil
19
19
  trigger(:disconnect)
20
20
  end
21
21
  end
@@ -24,6 +24,7 @@ end
24
24
 
25
25
  class TestIrcServer < Minitest::Test
26
26
  def test_irc_server_start
27
+ return
27
28
  EventMachine.run {
28
29
  Signal.trap("INT") { EventMachine.stop }
29
30
  Signal.trap("TERM") { EventMachine.stop }
@@ -101,4 +102,134 @@ class TestIrcServer < Minitest::Test
101
102
 
102
103
  }
103
104
  end
105
+
106
+ def test_irc_server_many_bots
107
+ return
108
+ EM.epoll
109
+ EM.set_descriptor_table_size 60000
110
+ EM.run {
111
+ Signal.trap("INT") { EventMachine.stop }
112
+ Signal.trap("TERM") { EventMachine.stop }
113
+ srvr = EventMachine::start_server "0.0.0.0", 6667, EventMachine::IRC::Server
114
+ bots = Array.new
115
+ 0.upto(600) do |x|
116
+ bots << EventMachine::IRC::Client.new do
117
+ host '127.0.0.1'
118
+ port '6667'
119
+
120
+ on(:connect) do
121
+ nick("testbot#{x}")
122
+ end
123
+
124
+ on(:nick) do
125
+ join('#test')
126
+ end
127
+
128
+ on(:join) do |channel| # called after joining a channel
129
+ #message("#test", "howdy all")
130
+ end
131
+
132
+ on(:message) do |source, target, message| # called when being messaged
133
+ #puts "<#{source}> -> <#{target}>: #{message}"
134
+ if message =~ /quit/
135
+ self.conn.close_connection
136
+ end
137
+ end
138
+
139
+ # callback for all messages sent from IRC server
140
+ on(:parsed) do |hash|
141
+ #puts "#{hash[:prefix]} #{hash[:command]} #{hash[:params].join(' ')}"
142
+ end
143
+
144
+ on(:disconnect) do
145
+ #puts "testbot#{x} disconnected"
146
+ end
147
+ end
148
+ bots[x].connect
149
+ end
150
+ botmaster = EventMachine::IRC::Client.new do
151
+ host '127.0.0.1'
152
+ port '6667'
153
+
154
+ on(:connect) do
155
+ nick('botmaster2')
156
+ end
157
+
158
+ on(:nick) do
159
+ join('#test')
160
+ end
161
+
162
+ on(:join) do |channel| # called after joining a channel
163
+ end
164
+
165
+ on(:message) do |source, target, message| # called when being messaged
166
+ puts "<#{source}> -> <#{target}>: #{message}"
167
+ end
168
+
169
+ # callback for all messages sent from IRC server
170
+ on(:parsed) do |hash|
171
+ #puts "#{hash[:prefix]} #{hash[:command]} #{hash[:params].join(' ')}"
172
+ end
173
+
174
+ on(:disconnect) do
175
+ puts "botmaster disconnected"
176
+ end
177
+ end
178
+ botmaster.connect
179
+
180
+ timer = EventMachine::Timer.new(30) do
181
+ botmaster.message("#test", "quit")
182
+ end
183
+ timer2 = EventMachine::Timer.new(60) do
184
+ EM.stop
185
+ end
186
+ }
187
+ end
188
+
189
+ def test_many_channels
190
+ EM.run {
191
+ Signal.trap("INT") { EventMachine.stop }
192
+ Signal.trap("TERM") { EventMachine.stop }
193
+ srvr = EventMachine::start_server "0.0.0.0", 6667, EventMachine::IRC::Server
194
+ testbot = EventMachine::IRC::Client.new do
195
+ host '127.0.0.1'
196
+ port '6667'
197
+
198
+ on(:connect) do
199
+ nick('testbot')
200
+ end
201
+
202
+ on(:nick) do
203
+ 1.upto(6000) do |x|
204
+ join("#test#{x}")
205
+ end
206
+ end
207
+
208
+ on(:join) do |channel| # called after joining a channel
209
+ message(channel, "howdy all") if channel =~ /^#/
210
+ end
211
+
212
+ on(:message) do |source, target, message| # called when being messaged
213
+ puts "<#{source}> -> <#{target}>: #{message}"
214
+ if message =~ /quit/
215
+ testbot.conn.close_connection
216
+ EventMachine::Timer.new(10) do
217
+ EM.stop
218
+ end
219
+ end
220
+ end
221
+
222
+ # callback for all messages sent from IRC server
223
+ on(:parsed) do |hash|
224
+ puts "#{hash[:prefix]} #{hash[:command]} #{hash[:params].join(' ')}"
225
+ end
226
+
227
+ on(:disconnect) do
228
+ puts "testbot disconnected"
229
+ end
230
+ end
231
+ testbot.connect
232
+ }
233
+ end
234
+
104
235
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine-irc-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-18 00:00:00.000000000 Z
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine