carrier-pigeon 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.org +3 -0
- data/carrier-pigeon.gemspec +1 -1
- data/lib/carrier-pigeon.rb +22 -12
- metadata +18 -4
data/README.org
CHANGED
@@ -16,3 +16,6 @@
|
|
16
16
|
:
|
17
17
|
: # SSL
|
18
18
|
: CarrierPigeon.send(:uri => "irc://nick:password@irc.domain.com:6667/#channel", :message => "coo, secret plan", :ssl => true)
|
19
|
+
:
|
20
|
+
: # Join the channel (required for most Freenode channels)
|
21
|
+
: CarrierPigeon.send(:uri => "irc://nick:password@irc.domain.com:6667/#channel", :message => "cooooo, coo coo", :join => true)
|
data/carrier-pigeon.gemspec
CHANGED
data/lib/carrier-pigeon.rb
CHANGED
@@ -4,9 +4,12 @@ require "openssl"
|
|
4
4
|
|
5
5
|
class CarrierPigeon
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
|
9
|
-
|
7
|
+
def initialize(options={})
|
8
|
+
[:host, :port, :nick, :channel].each do |option|
|
9
|
+
raise "You must provide an IRC #{option}" unless options.has_key?(option)
|
10
|
+
end
|
11
|
+
tcp_socket = TCPSocket.new(options[:host], options[:port])
|
12
|
+
if options[:ssl]
|
10
13
|
ssl_context = OpenSSL::SSL::SSLContext.new
|
11
14
|
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
12
15
|
@socket = OpenSSL::SSL::SSLSocket.new(tcp_socket, ssl_context)
|
@@ -16,9 +19,10 @@ class CarrierPigeon
|
|
16
19
|
else
|
17
20
|
@socket = tcp_socket
|
18
21
|
end
|
19
|
-
sendln "PASS #{password}" if password
|
20
|
-
sendln "NICK #{nick}"
|
21
|
-
sendln "USER #{nick} 0 * :#{nick}"
|
22
|
+
sendln "PASS #{options[:password]}" if options[:password]
|
23
|
+
sendln "NICK #{options[:nick]}"
|
24
|
+
sendln "USER #{options[:nick]} 0 * :#{options[:nick]}"
|
25
|
+
sendln "JOIN #{options[:channel]}" if options[:join]
|
22
26
|
end
|
23
27
|
|
24
28
|
def message(channel, message)
|
@@ -26,23 +30,29 @@ class CarrierPigeon
|
|
26
30
|
end
|
27
31
|
|
28
32
|
def die
|
33
|
+
sendln "QUIT :quit"
|
34
|
+
@socket.gets until @socket.eof?
|
29
35
|
@socket.close
|
30
36
|
end
|
31
37
|
|
32
38
|
def self.send(options={})
|
33
|
-
raise
|
39
|
+
raise "You must supply a valid IRC URI" unless options[:uri]
|
40
|
+
raise "You must supply a message" unless options[:message]
|
34
41
|
uri = Addressable::URI.parse(options[:uri])
|
35
|
-
|
36
|
-
|
37
|
-
|
42
|
+
options[:host] = uri.host
|
43
|
+
options[:port] = uri.port || 6667
|
44
|
+
options[:nick] = uri.user
|
45
|
+
options[:password] = uri.password
|
46
|
+
options[:channel] = "#" + uri.fragment
|
47
|
+
pigeon = new(options)
|
48
|
+
pigeon.message(options[:channel], options[:message])
|
38
49
|
pigeon.die
|
39
50
|
end
|
40
51
|
|
41
52
|
private
|
42
53
|
|
43
54
|
def sendln(cmd)
|
44
|
-
@socket.
|
45
|
-
@socket.flush
|
55
|
+
@socket.puts(cmd)
|
46
56
|
end
|
47
57
|
|
48
58
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrier-pigeon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Sean Porter
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-11-04 00:00:00 -07:00
|
14
19
|
default_executable:
|
15
20
|
dependencies:
|
16
21
|
- !ruby/object:Gem::Dependency
|
@@ -21,6 +26,9 @@ dependencies:
|
|
21
26
|
requirements:
|
22
27
|
- - ">="
|
23
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
24
32
|
version: "0"
|
25
33
|
type: :runtime
|
26
34
|
version_requirements: *id001
|
@@ -55,17 +63,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
63
|
requirements:
|
56
64
|
- - ">="
|
57
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
58
69
|
version: "0"
|
59
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
71
|
none: false
|
61
72
|
requirements:
|
62
73
|
- - ">="
|
63
74
|
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
64
78
|
version: "0"
|
65
79
|
requirements: []
|
66
80
|
|
67
81
|
rubyforge_project: carrier-pigeon
|
68
|
-
rubygems_version: 1.
|
82
|
+
rubygems_version: 1.3.7
|
69
83
|
signing_key:
|
70
84
|
specification_version: 3
|
71
85
|
summary: The simplest library to say something on IRC
|