spunk 0.1.0 → 0.1.1
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.
- data/lib/spunk.rb +2 -1
- data/lib/spunk/bot.rb +8 -4
- data/lib/spunk/origin.rb +1 -3
- data/lib/spunk/spunk_exceptions.rb +9 -0
- metadata +6 -6
data/lib/spunk.rb
CHANGED
data/lib/spunk/bot.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'openssl'
|
3
|
-
require 'mutex_m'
|
4
3
|
require 'logger'
|
5
4
|
|
6
5
|
module Spunk
|
@@ -9,7 +8,6 @@ module Spunk
|
|
9
8
|
attr_reader :processors, :request_processors, :response_processors, :hostname
|
10
9
|
|
11
10
|
def initialize(options = {})
|
12
|
-
#self.extend Mutex_m
|
13
11
|
options.each do |option, value|
|
14
12
|
instance_variable_set("@#{option}", value)
|
15
13
|
end
|
@@ -134,7 +132,11 @@ module Spunk
|
|
134
132
|
|
135
133
|
def connect
|
136
134
|
@logger.info "Starting connection to #{@server[:hostname]}:#{@server[:port]}"
|
137
|
-
|
135
|
+
begin
|
136
|
+
@socket = TCPSocket.new(@server[:hostname], @server[:port])
|
137
|
+
rescue
|
138
|
+
raise SpunkException::BotException.new "Unable to establish connection"
|
139
|
+
end
|
138
140
|
if @ssl == true
|
139
141
|
@logger.debug "Detected SSL connection"
|
140
142
|
@ssl_context = OpenSSL::SSL::SSLContext.new()
|
@@ -170,7 +172,9 @@ module Spunk
|
|
170
172
|
|
171
173
|
def say(to, message)
|
172
174
|
@logger.debug "saying message: PRIVMSG #{to} :#{message}"
|
173
|
-
send_message "PRIVMSG #{to} :#{message}"
|
175
|
+
unless send_message "PRIVMSG #{to} :#{message}"
|
176
|
+
raise SpunkException::BotException.new "Unable to send message"
|
177
|
+
end
|
174
178
|
end
|
175
179
|
|
176
180
|
def send_message(message)
|
data/lib/spunk/origin.rb
CHANGED
@@ -7,7 +7,7 @@ module Spunk
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def nickname
|
10
|
-
@prefix.to_s.split(/!/, 2)
|
10
|
+
@prefix.to_s.split(/!/, 2).first
|
11
11
|
end
|
12
12
|
|
13
13
|
def username
|
@@ -20,8 +20,6 @@ module Spunk
|
|
20
20
|
nickname
|
21
21
|
when @prefix
|
22
22
|
@prefix
|
23
|
-
else
|
24
|
-
"-unknown-"
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: A simple little IRCbot framework
|
15
|
-
for defining parsers.
|
14
|
+
description: A simple little IRCbot framework. Uses IOC pattern for defining parsers.
|
16
15
|
email: parabuzzle@gmail.com
|
17
16
|
executables: []
|
18
17
|
extensions: []
|
@@ -24,7 +23,8 @@ files:
|
|
24
23
|
- lib/spunk/base_parser.rb
|
25
24
|
- lib/spunk/ping_parser.rb
|
26
25
|
- lib/spunk/helpers.rb
|
27
|
-
|
26
|
+
- lib/spunk/spunk_exceptions.rb
|
27
|
+
homepage: http://parabuzzle.github.io/spunk/
|
28
28
|
licenses: []
|
29
29
|
post_install_message:
|
30
30
|
rdoc_options: []
|
@@ -47,5 +47,5 @@ rubyforge_project:
|
|
47
47
|
rubygems_version: 1.8.25
|
48
48
|
signing_key:
|
49
49
|
specification_version: 3
|
50
|
-
summary: A simple little IRCbot framework
|
50
|
+
summary: A simple little IRCbot framework
|
51
51
|
test_files: []
|