blur 1.4.1 → 1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ require 'ostruct'
7
7
  Dir.glob("#{File.dirname __FILE__}/blur/**/*.rb").each &method(:require)
8
8
 
9
9
  module Blur
10
- class << Version = [1,4,1]
10
+ class << Version = [1,5]
11
11
  def to_s; join '.' end
12
12
  end
13
13
 
@@ -6,7 +6,7 @@ module Blur
6
6
  class Client
7
7
  include Handling
8
8
 
9
- attr_accessor :options, :networks
9
+ attr_accessor :options, :scripts, :networks
10
10
 
11
11
  def initialize options
12
12
  @options = options
@@ -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
@@ -3,7 +3,7 @@
3
3
  module Blur
4
4
  class Network
5
5
  class Channel
6
- attr_accessor :name, :users, :network
6
+ attr_accessor :name, :users, :topic, :network
7
7
 
8
8
  def initialize name, network = nil, users = []
9
9
  @name = name
@@ -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
- - 4
8
- - 1
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