ircinch 2.4.3 → 2.4.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d603bfc62bdd98e5a52cc6f56fea0a5ac42592df0d58c0ccf40a3197f95167b5
4
- data.tar.gz: 271c967f694780843b98712454662782efcfc9145a0d015a7a3a5570af7303bd
3
+ metadata.gz: 3c4b56b78380a166d6ff1806cd237fdb5d08699c8619fa7ad17a4a80cb414b3e
4
+ data.tar.gz: e7481dbd35a3831e48eb80447ff4a429938dd285677c4e08867c31efb8ad868c
5
5
  SHA512:
6
- metadata.gz: d192049a5f08179804fb74810d828ab4facfcada4ffbecdbc18c0e3d7474c2151298f7da2b287882fe8b3a71f40ba9e3f23d3e798f731008170fac47456b2174
7
- data.tar.gz: 8a7693d15e83fef6b7716e1aca5d0cec0d942aa42ab8a99356a5a98fab1d1a1310f29f9a3d1546981df277f30d0b29fc57ef21b60f64124efaea3d9953f99e5a
6
+ metadata.gz: e9e7e645ddefb79ea5ab0489cfb2785624a6c33ea80a0d3cd51e5438e57ce6af6516adab7843256a51cc7041c9a4a35dfef4438ea4c5dab92ef1a6fd632c0692
7
+ data.tar.gz: 6a0e9526b4273cb3a670fc8a739f594f57888b679575d386d2715a767ead935af4c909e6bbad2eac2f2764e1cca2db09d895b2cb9b664842978ce55f71590931
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ * IRCinch 2.4.4, 14 January 2026
2
+ - Improve performance for high traffic channels
3
+ - Increase test coverage
4
+ - Bug fixes
5
+
1
6
  * IRCinch 2.4.3, 27 December 2025
2
7
  - Fix SASL auth time out by fixing IRC message parsing expression (fix by @janikrabe)
3
8
  - Remove various duplicate methods
data/LICENSE.txt CHANGED
@@ -1,8 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2010 Lee Jarvis, Dominik Honnef
4
- Copyright (c) 2011-2019 Dominik Honnef
5
- Copyright (c) 2022-2025 Matt Sias
4
+ Copyright (c) 2011 Dominik Honnef
6
5
 
7
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
8
7
  of this software and associated documentation files (the "Software"), to deal
data/lib/cinch/ban.rb CHANGED
@@ -40,7 +40,7 @@ module Cinch
40
40
  # @raise [Exceptions::UnsupportedFeature] Cinch does not support
41
41
  # Freenode's extended bans
42
42
  def match(user)
43
- raise UnsupportedFeature, "extended bans are not supported yet" if @extended
43
+ raise Exceptions::UnsupportedFeature, "extended bans are not supported yet" if @extended
44
44
  @mask =~ user
45
45
  end
46
46
  alias_method :=~, :match
data/lib/cinch/bot.rb CHANGED
@@ -352,6 +352,8 @@ module Cinch
352
352
  @join_handler = nil
353
353
  @join_timer = nil
354
354
 
355
+ @irc = IRC.new(self)
356
+
355
357
  super(nil, self)
356
358
  instance_eval(&b) if b
357
359
  end
@@ -31,7 +31,7 @@ module Cinch
31
31
  def []=(key, value)
32
32
  # FIXME also adjust method_missing
33
33
  raise ArgumentError, "Unknown option #{key}" unless self.class::KNOWN_OPTIONS.include?(key)
34
- modifiable[new_ostruct_member(key)] = value
34
+ super
35
35
  end
36
36
 
37
37
  # Loads a configuration from a hash by merging the hash with
data/lib/cinch/handler.rb CHANGED
@@ -75,7 +75,7 @@ module Cinch
75
75
  @thread_group.list.each do |thread|
76
76
  Thread.new do
77
77
  @bot.loggers.debug "[Ending thread] Waiting 10 seconds for #{thread} to finish..."
78
- thread.join(10)
78
+ thread.join(stop_timeout)
79
79
  @bot.loggers.debug "[Killing thread] Killing #{thread}"
80
80
  thread.kill
81
81
  end
@@ -116,5 +116,11 @@ module Cinch
116
116
  # TODO maybe add the number of running threads to the output?
117
117
  "#<Cinch::Handler @event=#{@event.inspect} pattern=#{@pattern.inspect}>"
118
118
  end
119
+
120
+ private
121
+
122
+ def stop_timeout
123
+ 10
124
+ end
119
125
  end
120
126
  end
@@ -38,11 +38,23 @@ module Cinch
38
38
  return handlers
39
39
  end
40
40
 
41
- handlers = handlers.select { |handler|
42
- msg.match(handler.pattern.to_r(msg), type, handler.strip_colors)
43
- }.group_by { |handler| handler.group }
44
-
45
- handlers.values_at(*(handlers.keys - [nil])).map(&:first) + (handlers[nil] || [])
41
+ groups = Set.new
42
+ handlers.select { |handler|
43
+ if msg.match(handler.pattern.to_r(msg), type, handler.strip_colors)
44
+ if handler.group
45
+ if groups.include?(handler.group)
46
+ false
47
+ else
48
+ groups << handler.group
49
+ true
50
+ end
51
+ else
52
+ true
53
+ end
54
+ else
55
+ false
56
+ end
57
+ }
46
58
  end
47
59
  end
48
60
 
data/lib/cinch/irc.rb CHANGED
@@ -12,6 +12,11 @@ module Cinch
12
12
  class IRC
13
13
  include Helpers
14
14
 
15
+ # @api private
16
+ REGISTRATION_COMMANDS = %w[001 002 003 004 422].freeze
17
+ # @api private
18
+ PRIVMSG_NOTICE_COMMANDS = %w[PRIVMSG NOTICE].freeze
19
+
15
20
  # @return [ISupport]
16
21
  attr_reader :isupport
17
22
 
@@ -236,7 +241,7 @@ module Cinch
236
241
  msg = Message.new(input, @bot)
237
242
  events = [[:catchall]]
238
243
 
239
- if ["001", "002", "003", "004", "422"].include?(msg.command)
244
+ if REGISTRATION_COMMANDS.include?(msg.command)
240
245
  @registration << msg.command
241
246
  if registered?
242
247
  events << [:connect]
@@ -245,7 +250,7 @@ module Cinch
245
250
  end
246
251
  end
247
252
 
248
- if ["PRIVMSG", "NOTICE"].include?(msg.command)
253
+ if PRIVMSG_NOTICE_COMMANDS.include?(msg.command)
249
254
  events << [:ctcp] if msg.ctcp?
250
255
  events << if msg.channel?
251
256
  [:channel]
@@ -759,8 +764,9 @@ module Cinch
759
764
  end
760
765
  @in_lists << :names
761
766
 
767
+ prefix_regex = /^([#{@isupport["PREFIX"].values.join}]+)/
762
768
  msg.params[3].split(" ").each do |user|
763
- m = user.match(/^([#{@isupport["PREFIX"].values.join}]+)/)
769
+ m = user.match(prefix_regex)
764
770
  if m
765
771
  prefixes = m[1].chars.map { |s| @isupport["PREFIX"].key(s) }
766
772
  nick = user[prefixes.size..]
data/lib/cinch/logger.rb CHANGED
@@ -167,5 +167,13 @@ module Cinch
167
167
  def format_exception(message)
168
168
  message
169
169
  end
170
+
171
+ def format_fatal(message)
172
+ message
173
+ end
174
+
175
+ def format_log(message)
176
+ message
177
+ end
170
178
  end
171
179
  end
data/lib/cinch/message.rb CHANGED
@@ -86,6 +86,8 @@ module Cinch
86
86
  # @since 2.3.0
87
87
  attr_reader :statusmsg_mode
88
88
 
89
+ MSG_REGEX = /\A(?:@([^ ]+) )?(?::(\S+) )?(\S+)(.*)/
90
+
89
91
  def initialize(msg, bot)
90
92
  @raw = msg
91
93
  @bot = bot
@@ -99,7 +101,7 @@ module Cinch
99
101
  # @api private
100
102
  # @return [void]
101
103
  def parse
102
- match = @raw.match(/\A(?:@([^ ]+) )?(?::(\S+) )?(\S+)(.*)/)
104
+ match = @raw.match(MSG_REGEX)
103
105
  tags, @prefix, @command, raw_params = match.captures
104
106
 
105
107
  if @bot.irc.network.ngametv?
@@ -280,7 +282,7 @@ module Cinch
280
282
 
281
283
  class << self
282
284
  def to_symbol(string)
283
- string.tr(/-/, "_").downcase.to_sym
285
+ string.tr("-", "_").downcase.to_sym
284
286
  end
285
287
  end
286
288
 
@@ -343,7 +345,7 @@ module Cinch
343
345
  chantypes = @bot.irc.isupport["CHANTYPES"]
344
346
  statusmsg = @bot.irc.isupport["STATUSMSG"]
345
347
  if statusmsg.include?(s[0]) && chantypes.include?(s[1])
346
- status = @bot.irc.isupport["PREFIX"].invert[s[0]]
348
+ status = @bot.irc.isupport["PREFIX"].key(s[0])
347
349
  [s[1..], status]
348
350
  elsif chantypes.include?(s[0])
349
351
  [s, nil]
@@ -4,23 +4,55 @@
4
4
  # objects.
5
5
  #
6
6
  # @api private
7
- class OpenEndedQueue < Queue
8
- # @param [Object] obj
9
- # @return [void]
7
+ class OpenEndedQueue
8
+ def initialize
9
+ @queue = []
10
+ @mutex = Mutex.new
11
+ @cv = ConditionVariable.new
12
+ end
13
+
14
+ def <<(obj)
15
+ push(obj)
16
+ end
17
+
18
+ def push(obj)
19
+ @mutex.synchronize do
20
+ @queue.push(obj)
21
+ @cv.signal
22
+ end
23
+ end
24
+
10
25
  def unshift(obj)
11
- t = nil
12
- @mutex.synchronize {
13
- @que.unshift obj
14
- begin
15
- t = @waiting.shift
16
- t&.wakeup
17
- rescue ThreadError
18
- retry
26
+ @mutex.synchronize do
27
+ @queue.unshift(obj)
28
+ @cv.signal
29
+ end
30
+ end
31
+
32
+ def pop(non_block = false)
33
+ @mutex.synchronize do
34
+ while @queue.empty?
35
+ raise ThreadError, "queue empty" if non_block
36
+ @cv.wait(@mutex)
19
37
  end
20
- }
21
- begin
22
- t&.run
23
- rescue ThreadError
38
+ @queue.shift
24
39
  end
25
40
  end
41
+ alias_method :shift, :pop
42
+ alias_method :deq, :pop
43
+ alias_method :enq, :push
44
+
45
+ def empty?
46
+ @mutex.synchronize { @queue.empty? }
47
+ end
48
+
49
+ def size
50
+ @mutex.synchronize { @queue.size }
51
+ end
52
+
53
+ alias_method :length, :size
54
+
55
+ def clear
56
+ @mutex.synchronize { @queue.clear }
57
+ end
26
58
  end
data/lib/cinch/pattern.rb CHANGED
@@ -46,9 +46,14 @@ module Cinch
46
46
  attr_reader :pattern
47
47
  def initialize(prefix, pattern, suffix)
48
48
  @prefix, @pattern, @suffix = prefix, pattern, suffix
49
+ if !@prefix.is_a?(Proc) && !@pattern.is_a?(Proc) && !@suffix.is_a?(Proc)
50
+ @cached_regex = to_r
51
+ end
49
52
  end
50
53
 
51
54
  def to_r(msg = nil)
55
+ return @cached_regex if @cached_regex
56
+
52
57
  pattern = Pattern.resolve_proc(@pattern, msg)
53
58
 
54
59
  case pattern
@@ -23,6 +23,6 @@ class Module
23
23
  # @api private
24
24
  def synced_attr_accessor(attr)
25
25
  synced_attr_reader(attr)
26
- attr_accessor(attr)
26
+ attr_writer(attr)
27
27
  end
28
28
  end
data/lib/cinch/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Cinch
4
4
  # Version of the library
5
- VERSION = "2.4.3"
5
+ VERSION = "2.4.4"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ircinch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Sias