cinch 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ require 'cinch'
3
3
  class SomeCommand
4
4
  include Cinch::Plugin
5
5
 
6
- prefix /^~/
6
+ set :prefix, /^~/
7
7
  match "somecommand"
8
8
 
9
9
  def execute(m)
@@ -9,7 +9,7 @@ class DirectAddressing
9
9
  #
10
10
  # The reason we are using a lambda is that the bot's nick can change
11
11
  # and the prefix has to be up to date.
12
- prefix lambda{ |m| Regexp.new("^" + Regexp.escape(m.bot.nick + ": " ))}
12
+ set :prefix, lambda{ |m| Regexp.new("^" + Regexp.escape(m.bot.nick + ": " ))}
13
13
 
14
14
  match "hello", method: :greet
15
15
  def greet(m)
data/lib/cinch/bot.rb CHANGED
@@ -249,6 +249,8 @@ module Cinch
249
249
  channel.unsync_all
250
250
  end # reset state of all channels
251
251
 
252
+ @channels = [] # reset list of channels the bot is in
253
+
252
254
  @join_handler.unregister if @join_handler
253
255
  @join_timer.stop if @join_timer
254
256
 
data/lib/cinch/channel.rb CHANGED
@@ -59,6 +59,14 @@ module Cinch
59
59
 
60
60
  @synced_attributes = Set.new
61
61
  @when_requesting_synced_attribute = lambda {|attr|
62
+ if @in_channel && attr == :topic && !attribute_synced?(:topic)
63
+ # Even if we are in the channel, if there's no topic set,
64
+ # the attribute won't be synchronised yet. Explicitly
65
+ # request the topic.
66
+ @bot.irc.send "TOPIC #@name"
67
+ next
68
+ end
69
+
62
70
  unless @in_channel
63
71
  unsync(attr)
64
72
  case attr
data/lib/cinch/irc.rb CHANGED
@@ -544,15 +544,23 @@ module Cinch
544
544
  end
545
545
 
546
546
 
547
- if msg.message =~ /^\001DCC SEND (?:"([^"]+)"|(\S+)) (\d+) (\d+)(?: (\d+))?\001$/
547
+ if msg.message =~ /^\001DCC SEND (?:"([^"]+)"|(\S+)) (\S+) (\d+)(?: (\d+))?\001$/
548
548
  process_dcc_send($1 || $2, $3, $4, $5, msg, events)
549
549
  end
550
550
  end
551
551
 
552
552
  # @since 2.0.0
553
553
  def process_dcc_send(filename, ip, port, size, m, events)
554
- ip = ip.to_i
555
- ip = [24, 16, 8, 0].collect {|b| (ip >> b) & 255}.join('.')
554
+ if ip =~ /^\d$/
555
+ # If ip is a single integer, assume it's a specification
556
+ # compliant IPv4 address in network byte order. If it's any
557
+ # other string, assume that it's a valid IPv4 or IPv6 address.
558
+ # If it's not valid, let someone higher up the chain notice
559
+ # that.
560
+ ip = ip.to_i
561
+ ip = [24, 16, 8, 0].collect {|b| (ip >> b) & 255}.join('.')
562
+ end
563
+
556
564
  port = port.to_i
557
565
  size = size.to_i
558
566
 
@@ -632,8 +640,8 @@ module Cinch
632
640
  def on_319(msg, events)
633
641
  # RPL_WHOISCHANNELS
634
642
  user = User(msg.params[1])
635
- channels = msg.params[2].scan(/#{@isupport["CHANTYPES"].join}[^ ]+/o).map {|c| Channel(c) }
636
- user.sync(:channels, channels, true)
643
+ channels = msg.params[2].scan(/[#{@isupport["CHANTYPES"].join}][^ ]+/o).map {|c| Channel(c) }
644
+ @whois_updates[user].merge!({:channels => channels})
637
645
  end
638
646
 
639
647
  def on_324(msg, events)
data/lib/cinch/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Cinch
2
2
  # Version of the library
3
- VERSION = '2.0.5'
3
+ VERSION = '2.0.6'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-21 00:00:00.000000000 Z
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple, friendly DSL for creating IRC bots
15
15
  email: