net-yail 1.1.1 → 1.2.0
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/CHANGELOG +15 -1
- data/examples/logger/default.yml +2 -0
- data/examples/logger/logger_bot.rb +37 -4
- data/examples/logger/run.rb +4 -1
- data/lib/net/yail.rb +2 -1
- data/lib/net/yail/default_events.rb +8 -2
- data/lib/net/yail/output_api.rb +6 -3
- metadata +7 -7
data/CHANGELOG
CHANGED
@@ -19,4 +19,18 @@
|
|
19
19
|
system.
|
20
20
|
* Net::YAIL now has handling for INVITE messages
|
21
21
|
* Added fully working logger bot for a solid example
|
22
|
-
* Since changes are more extensive
|
22
|
+
* Since changes are more extensive than a minor release, bumping to 1.1.1
|
23
|
+
|
24
|
+
2008-07-07:
|
25
|
+
* The included logger example bot no longer crashes on incoming "private"
|
26
|
+
message
|
27
|
+
* Logger example also has an example of using an outgoing handler to
|
28
|
+
centralize a list of channel passwords - all join messages get a password
|
29
|
+
tacked on if the central password list has one for the given channel
|
30
|
+
* Obviously the above addition required support for joining password-protected
|
31
|
+
channels, so YAY!
|
32
|
+
|
33
|
+
2008-07-17:
|
34
|
+
* Fixed logger's handler to not call the channel logging code on private message
|
35
|
+
* Figured it's about time for a new gem, 1.2.0. Change to join handler breaks
|
36
|
+
existing code in a minor way - don't forget to fix your handlers!
|
data/examples/logger/default.yml
CHANGED
@@ -18,6 +18,7 @@ class LoggerBot < IRCBot
|
|
18
18
|
# * <tt>:silent</tt>: Very little logging
|
19
19
|
# * <tt>:master</tt>: User who can order quits
|
20
20
|
# * <tt>:output_dir</tt>: Where to store log files
|
21
|
+
# * <tt>:passwords</tt>: Hash of channel=>pass for joining channels
|
21
22
|
def initialize(options = {})
|
22
23
|
@master = options.delete(:master)
|
23
24
|
@output_dir = options.delete(:output_dir) || File.dirname(__FILE__)
|
@@ -26,6 +27,7 @@ class LoggerBot < IRCBot
|
|
26
27
|
# filenames on a per-channel basis
|
27
28
|
@current_log = {}
|
28
29
|
@log_date = {}
|
30
|
+
@passwords = options[:passwords] || {}
|
29
31
|
|
30
32
|
options[:username] = BOTNAME
|
31
33
|
options[:realname] = BOTNAME
|
@@ -44,14 +46,19 @@ class LoggerBot < IRCBot
|
|
44
46
|
@irc.prepend_handler(:incoming_act, self.method(:_in_act))
|
45
47
|
@irc.prepend_handler(:incoming_invite, self.method(:_in_invited))
|
46
48
|
@irc.prepend_handler(:incoming_kick, self.method(:_in_kick))
|
49
|
+
|
50
|
+
@irc.prepend_handler(:outgoing_join, self.method(:_out_join))
|
47
51
|
end
|
48
52
|
|
49
53
|
private
|
50
54
|
# Incoming message handler
|
51
55
|
def _in_msg(fullactor, user, channel, text)
|
52
56
|
# check if this is a /msg command, or normal channel talk
|
53
|
-
|
54
|
-
|
57
|
+
if channel =~ /#{bot_name}/
|
58
|
+
incoming_private_message(user, text)
|
59
|
+
else
|
60
|
+
incoming_channel_message(user, channel, text)
|
61
|
+
end
|
55
62
|
end
|
56
63
|
|
57
64
|
def _in_act(fullactor, user, channel, text)
|
@@ -61,12 +68,32 @@ class LoggerBot < IRCBot
|
|
61
68
|
end
|
62
69
|
|
63
70
|
# TODO: recalls the most recent logs for a given channel by reading from
|
64
|
-
# the file system or using a hash of log data.
|
65
|
-
# general sanity
|
71
|
+
# the file system or using a hash of log data. Or both.
|
66
72
|
def recent_logs(channel, num = 10)
|
67
73
|
raise "Not implemented"
|
68
74
|
end
|
69
75
|
|
76
|
+
# TODO: Searches logs for a given pattern. Relies on the file system data
|
77
|
+
# to do a comprehensive search, and 'grep', so SANITIZE INPUT!
|
78
|
+
def search_logs(pattern)
|
79
|
+
raise "Not implemented"
|
80
|
+
end
|
81
|
+
|
82
|
+
# Gives the user very simplistic information. TODO: Add a command for
|
83
|
+
# accessing and searching logs.
|
84
|
+
def incoming_private_message(user, text)
|
85
|
+
case text
|
86
|
+
when /\bhelp\b/i
|
87
|
+
msg(user, 'LoggerBot at your service - I log all messages and actions in any channel')
|
88
|
+
msg(user, 'I\'m in. In the future I\'ll offer searchable logs. If you /INVITE me to')
|
89
|
+
msg(user, 'a channel, I\'ll pop in and start logging.')
|
90
|
+
return
|
91
|
+
end
|
92
|
+
|
93
|
+
msg(user, "I don't log private messages. If you'd like to know what I do, ")
|
94
|
+
msg(user, "enter \"HELP\"")
|
95
|
+
end
|
96
|
+
|
70
97
|
def incoming_channel_message(user, channel, text)
|
71
98
|
# check for special stuff before keywords
|
72
99
|
# Nerdmaster is allowed to do special ordering
|
@@ -122,4 +149,10 @@ class LoggerBot < IRCBot
|
|
122
149
|
|
123
150
|
return true
|
124
151
|
end
|
152
|
+
|
153
|
+
# We're trying to join a channel - use key if we have one
|
154
|
+
def _out_join(target, pass)
|
155
|
+
key = @passwords[target]
|
156
|
+
pass.replace(key) unless key.to_s.empty?
|
157
|
+
end
|
125
158
|
end
|
data/examples/logger/run.rb
CHANGED
@@ -9,6 +9,8 @@ require 'getopt/long'
|
|
9
9
|
# If options are specified, they override the default yaml file. If a
|
10
10
|
# different yaml file is specified, its settings are read, then overridden
|
11
11
|
# by options.
|
12
|
+
#
|
13
|
+
# Passwords hash cannot be specified on the command-line - yaml or nothing.
|
12
14
|
|
13
15
|
opt = Getopt::Long.getopts(
|
14
16
|
['--silent', '-s', Getopt::BOOLEAN],
|
@@ -35,6 +37,7 @@ end
|
|
35
37
|
:loud => options['loud'],
|
36
38
|
:irc_network => options['network'],
|
37
39
|
:output_dir => options['output-dir'],
|
38
|
-
:master => options['master']
|
40
|
+
:master => options['master'],
|
41
|
+
:passwords => options['passwords']
|
39
42
|
)
|
40
43
|
@bot.irc_loop
|
data/lib/net/yail.rb
CHANGED
@@ -102,7 +102,8 @@ module Net
|
|
102
102
|
# * :outgoing_ctcpreply(target, text) - CTCP NOTICE messages
|
103
103
|
# * :outgoing_mode(target, modes, objects) - Sets or queries mode. If modes is
|
104
104
|
# present, sends mode list to target. Objects would be users.
|
105
|
-
# * :outgoing_join(target) -
|
105
|
+
# * :outgoing_join(target, pass) - About to attempt to join target channel with
|
106
|
+
# given password (pass is '' if not specified in the join() command)
|
106
107
|
# * :outgoing_part(target, text) - The given target channel is about to be
|
107
108
|
# left, with optional text reason.
|
108
109
|
# * :outgoing_quit(text) - The client is about to quit, with optional text
|
@@ -28,6 +28,7 @@ module Defaults
|
|
28
28
|
# Incoming numeric events here
|
29
29
|
prepend_handler :incoming_welcome, self.method(:r_welcome)
|
30
30
|
prepend_handler :incoming_bannedfromchan, self.method(:r_bannedfromchan)
|
31
|
+
prepend_handler :incoming_badchannelkey, self.method(:r_badchannelkey)
|
31
32
|
prepend_handler :incoming_nicknameinuse, self.method(:_nicknameinuse)
|
32
33
|
prepend_handler :incoming_channelurl, self.method(:r_channelurl)
|
33
34
|
prepend_handler :incoming_topic, self.method(:r_topic)
|
@@ -90,8 +91,13 @@ module Defaults
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def r_bannedfromchan(text, args)
|
93
|
-
text =~ /^(\S*) :Cannot join channel
|
94
|
-
report "
|
94
|
+
text =~ /^(\S*) :Cannot join channel/
|
95
|
+
report "Banned from channel #{$1}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def r_badchannelkey(text, args)
|
99
|
+
text =~ /^(\S*) :Cannot join channel/
|
100
|
+
report "Bad channel key (password) for #{$1}"
|
95
101
|
end
|
96
102
|
|
97
103
|
def r_welcome(*args)
|
data/lib/net/yail/output_api.rb
CHANGED
@@ -133,13 +133,16 @@ module IRCOutputAPI
|
|
133
133
|
end
|
134
134
|
|
135
135
|
# Calls :outgoing_join handler and then raw JOIN message for a given channel
|
136
|
-
def join(target)
|
136
|
+
def join(target, pass = '')
|
137
137
|
# Dup strings so handler can filter safely
|
138
138
|
target = target.dup
|
139
|
+
pass = pass.dup
|
139
140
|
|
140
|
-
handle(:outgoing_join, target)
|
141
|
+
handle(:outgoing_join, target, pass)
|
141
142
|
|
142
|
-
|
143
|
+
text = "JOIN #{target}"
|
144
|
+
text += " #{pass}" unless pass.empty?
|
145
|
+
raw text
|
143
146
|
end
|
144
147
|
|
145
148
|
# Calls :outgoing_part handler and then raw PART for leaving a given channel
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-yail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Echols
|
@@ -9,7 +9,7 @@ autorequire: net/yail
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-07-
|
12
|
+
date: 2008-07-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -23,16 +23,16 @@ extra_rdoc_files:
|
|
23
23
|
- README
|
24
24
|
- CHANGELOG
|
25
25
|
files:
|
26
|
+
- examples/logger/default.yml
|
26
27
|
- examples/logger/logger_bot.rb
|
27
28
|
- examples/logger/run.rb
|
28
|
-
- examples/logger/default.yml
|
29
29
|
- lib/net/yail.rb
|
30
30
|
- CHANGELOG
|
31
|
+
- lib/net/yail/output_api.rb
|
32
|
+
- lib/net/yail/default_events.rb
|
33
|
+
- lib/net/yail/magic_events.rb
|
31
34
|
- lib/net/yail/eventmap.yml
|
32
35
|
- lib/net/yail/IRCBot.rb
|
33
|
-
- lib/net/yail/magic_events.rb
|
34
|
-
- lib/net/yail/default_events.rb
|
35
|
-
- lib/net/yail/output_api.rb
|
36
36
|
- README
|
37
37
|
has_rdoc: true
|
38
38
|
homepage: http://ruby-irc-yail.nerdbucket.com/
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements: []
|
58
58
|
|
59
59
|
rubyforge_project: net-yail
|
60
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.2.0
|
61
61
|
signing_key:
|
62
62
|
specification_version: 2
|
63
63
|
summary: "Yet Another IRC Library: wrapper for IRC communications in Ruby."
|