blur 1.4.1 → 1.5
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/library/blur.rb +1 -1
- data/library/blur/client.rb +1 -1
- data/library/blur/handling.rb +41 -0
- data/library/blur/network/channel.rb +1 -1
- data/library/blur/script/messageparsing.rb +26 -0
- metadata +3 -3
data/library/blur.rb
CHANGED
data/library/blur/client.rb
CHANGED
data/library/blur/handling.rb
CHANGED
@@ -30,6 +30,20 @@ module Blur
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
# A channels topic
|
34
|
+
def got_332 network, command
|
35
|
+
me, name, topic = command.params
|
36
|
+
|
37
|
+
if channel = network.channel_by_name(name)
|
38
|
+
channel.topic = topic
|
39
|
+
else
|
40
|
+
channel = Network::Channel.new name, network, []
|
41
|
+
channel.topic = topic
|
42
|
+
|
43
|
+
network.channels << channel
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
33
47
|
# Are we still breathing?
|
34
48
|
def got_ping network, command
|
35
49
|
network.transmit :PONG, command[0]
|
@@ -108,6 +122,33 @@ module Blur
|
|
108
122
|
end
|
109
123
|
end
|
110
124
|
end
|
125
|
+
|
126
|
+
# Someone got kicked
|
127
|
+
def got_kick network, command
|
128
|
+
name, target, reason = command.params
|
129
|
+
|
130
|
+
if channel = network.channel_by_name(name)
|
131
|
+
if kicker = channel.user_by_nick(command.sender.nickname)
|
132
|
+
if kickee = channel.user_by_nick(target)
|
133
|
+
channel.users.delete kickee
|
134
|
+
|
135
|
+
emit :user_kicked, kicker, channel, kickee, reason
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def got_topic network, command
|
142
|
+
name, topic = command.params
|
143
|
+
|
144
|
+
if channel = network.channel_by_name(name)
|
145
|
+
if user = channel.user_by_nick(command.sender.nickname)
|
146
|
+
emit :topic, user, channel, topic
|
147
|
+
end
|
148
|
+
|
149
|
+
channel.topic = topic
|
150
|
+
end
|
151
|
+
end
|
111
152
|
|
112
153
|
alias_method :got_422, :got_end_of_motd
|
113
154
|
alias_method :got_376, :got_end_of_motd
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Blur
|
4
|
+
class Script < Module
|
5
|
+
module MessageParsing
|
6
|
+
MessageTrigger = "."
|
7
|
+
|
8
|
+
def message user, channel, line
|
9
|
+
return unless line.start_with? MessageTrigger
|
10
|
+
|
11
|
+
command, args = line.split $;, 2
|
12
|
+
name = :"command_#{serialize command}"
|
13
|
+
|
14
|
+
if respond_to? name
|
15
|
+
__send__ name, user, channel, args
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def serialize name
|
22
|
+
name.gsub /\W/, '' if name
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
|
9
|
-
version: 1.4.1
|
7
|
+
- 5
|
8
|
+
version: "1.5"
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- Mikkel Kroman
|
@@ -36,6 +35,7 @@ files:
|
|
36
35
|
- library/blur/network/user.rb
|
37
36
|
- library/blur/network.rb
|
38
37
|
- library/blur/script/cache.rb
|
38
|
+
- library/blur/script/messageparsing.rb
|
39
39
|
- library/blur/script.rb
|
40
40
|
- library/blur.rb
|
41
41
|
has_rdoc: true
|