dragoon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/README.md +12 -6
- data/dragoon.gemspec +1 -1
- data/lib/dragoon.rb +37 -8
- data/lib/dragoon/commands.rb +1 -0
- data/lib/dragoon/version.rb +1 -1
- metadata +5 -7
- data/config/config.yml +0 -4
- data/config/config.yml.example +0 -4
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Dragoon
|
2
2
|
============
|
3
3
|
|
4
|
-
An IRC bot that
|
4
|
+
An IRC bot that alerts you whenever certain keywords pop up in your favorite channels. You can listen to multiple channels but right now, you can only connect to one network at a time. And I've only tested it on freenode.net. Support for multiple networks will be done soon.
|
5
5
|
|
6
6
|
|
7
7
|
Dependencies
|
@@ -15,13 +15,19 @@ P.S. You can still run the program even without growl, you'll only see the keywo
|
|
15
15
|
Usage
|
16
16
|
-----
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
gem install dragoon
|
19
|
+
|
20
|
+
dragoon
|
21
|
+
|
22
|
+
Once you run dragoon, A default config file would be created under your home directory called .dragoon if it doesnt exist. You will have to edit it accordingly. Once the file exists, the program will automatically load the config file on startup.
|
23
|
+
|
24
|
+
If you have growl support, make sure it's turned on
|
22
25
|
|
23
|
-
P.S. will gemify this soon so you only have to do 'gem install dragoon', then 'dragoon'
|
24
26
|
|
25
27
|
Screenshot
|
26
28
|
---------
|
27
29
|
http://farm8.staticflickr.com/7027/6733543233_6f354d61d0_b.jpg
|
30
|
+
|
31
|
+
Questions and Feedback
|
32
|
+
---------
|
33
|
+
I would love to hear any suggestions for improvement. You can email me at redge.tan@gmail.com. I'm also looking for mentors that can help me improve as a software developer. if you're interested in helping me, I'd love to hear from you.
|
data/dragoon.gemspec
CHANGED
data/lib/dragoon.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
require 'ostruct'
|
3
3
|
require 'forwardable'
|
4
|
-
require '
|
4
|
+
require 'json'
|
5
5
|
|
6
6
|
require 'term/ansicolor'
|
7
7
|
|
@@ -19,11 +19,12 @@ module Dragoon
|
|
19
19
|
include Commands
|
20
20
|
include Color
|
21
21
|
|
22
|
-
attr_accessor :nickname, :
|
22
|
+
attr_accessor :nickname, :network, :channels, :keywords
|
23
23
|
|
24
24
|
def_delegators :@event_manager, :on, :dispatch
|
25
25
|
|
26
26
|
DEFAULT_PORT = 6667
|
27
|
+
CONFIG_FILE = File.expand_path("~/.dragoon")
|
27
28
|
|
28
29
|
def initialize(&blk)
|
29
30
|
@event_manager = EventManager.new
|
@@ -33,13 +34,27 @@ module Dragoon
|
|
33
34
|
|
34
35
|
def load_config
|
35
36
|
begin
|
36
|
-
|
37
|
+
if File.exist?(CONFIG_FILE)
|
38
|
+
puts("*** Loading config file ~/.dragoon")
|
39
|
+
config = JSON.parse(File.read(CONFIG_FILE))
|
40
|
+
else
|
41
|
+
config = {
|
42
|
+
"nickname" => "your_nick",
|
43
|
+
"network" => "irc.freenode.net",
|
44
|
+
"channels" => %w[ #ubuntu #ruby #rubyonrails #linux #programming #javascript ],
|
45
|
+
"keywords" => %w[ and how who ]
|
46
|
+
}
|
47
|
+
File.open(CONFIG_FILE,'w+') {|f| f.write(JSON.pretty_generate(config)) }
|
48
|
+
puts("Config file does not exist...created one at #{CONFIG_FILE}".red)
|
49
|
+
puts("Please modify it according to your preference".red)
|
50
|
+
exit 1
|
51
|
+
end
|
37
52
|
rescue => e
|
38
53
|
$stderr.puts e.message
|
39
54
|
exit 1
|
40
55
|
end
|
41
56
|
@nickname = config["nickname"]
|
42
|
-
@
|
57
|
+
@network = config["network"]
|
43
58
|
@channels = config["channels"]
|
44
59
|
@keywords = config["keywords"]
|
45
60
|
end
|
@@ -59,7 +74,7 @@ module Dragoon
|
|
59
74
|
end
|
60
75
|
|
61
76
|
on :mode do |msg|
|
62
|
-
puts "*** Logged in as #{
|
77
|
+
puts "*** Logged in as #{self.nickname}"
|
63
78
|
join_channels
|
64
79
|
end
|
65
80
|
|
@@ -68,7 +83,13 @@ module Dragoon
|
|
68
83
|
end
|
69
84
|
|
70
85
|
on :err do |msg|
|
71
|
-
puts
|
86
|
+
$stderr.puts msg.text.red unless msg.error_code == '470' # channel forwarding
|
87
|
+
if msg.error_code == '433' # nick already in use
|
88
|
+
print("Enter another nickname: ")
|
89
|
+
self.nickname = gets.chomp
|
90
|
+
user(self.nickname)
|
91
|
+
nick(self.nickname)
|
92
|
+
end
|
72
93
|
end
|
73
94
|
|
74
95
|
on :privmsg do |msg|
|
@@ -86,20 +107,28 @@ module Dragoon
|
|
86
107
|
def run
|
87
108
|
@socket = connect
|
88
109
|
while line = @socket.gets
|
110
|
+
trap('INT') { stop }
|
89
111
|
@event = Event.parse(line)
|
90
112
|
dispatch(@event)
|
91
113
|
end
|
92
114
|
end
|
93
115
|
|
94
116
|
def connect
|
95
|
-
puts "*** Connecting to #{@
|
96
|
-
TCPSocket.new(@
|
117
|
+
puts "*** Connecting to #{@network} on port #{DEFAULT_PORT}"
|
118
|
+
TCPSocket.new(@network, DEFAULT_PORT)
|
97
119
|
end
|
98
120
|
|
99
121
|
def escape_double_quotes(text)
|
100
122
|
text.gsub("\"", "\\\"")
|
101
123
|
end
|
102
124
|
|
125
|
+
def stop
|
126
|
+
@socket.close
|
127
|
+
puts
|
128
|
+
puts "*** Program stopped"
|
129
|
+
exit
|
130
|
+
end
|
131
|
+
|
103
132
|
end
|
104
133
|
end
|
105
134
|
|
data/lib/dragoon/commands.rb
CHANGED
data/lib/dragoon/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragoon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Reginald Tan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-23 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
type: :development
|
33
33
|
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name: term
|
35
|
+
name: term-ansicolor
|
36
36
|
prerelease: false
|
37
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
38
38
|
none: false
|
@@ -62,8 +62,6 @@ files:
|
|
62
62
|
- Rakefile
|
63
63
|
- TODO
|
64
64
|
- bin/dragoon
|
65
|
-
- config/config.yml
|
66
|
-
- config/config.yml.example
|
67
65
|
- dragoon.gemspec
|
68
66
|
- lib/dragoon.rb
|
69
67
|
- lib/dragoon/color.rb
|
data/config/config.yml
DELETED
data/config/config.yml.example
DELETED