ircinch 2.4.2 → 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: de7e4e085fee1303e2bcca842721d58d57748d597b392c2f914a25bd2e6a30ef
4
- data.tar.gz: 8aae2cfb9b253be5bb25aed45f05f1bb26de5b0acad85f732dbde1d9b7a54268
3
+ metadata.gz: 3c4b56b78380a166d6ff1806cd237fdb5d08699c8619fa7ad17a4a80cb414b3e
4
+ data.tar.gz: e7481dbd35a3831e48eb80447ff4a429938dd285677c4e08867c31efb8ad868c
5
5
  SHA512:
6
- metadata.gz: 3a6fa7c8ab22c8afaf2426e2ac39321587b490a7a9cd186f7b025a10758286879d77e945dbc45089ffc23564725f74bad9c77b2bdd9f4223b8ee5a7373197627
7
- data.tar.gz: 7ee970b4665d0e682d8e1382330d6b36809d967f485997717f2d37a96d2c9f14a244d96de00d4fd45bd0f8c57682160439b980f697b18c6044ffc44fcadacd3c
6
+ metadata.gz: e9e7e645ddefb79ea5ab0489cfb2785624a6c33ea80a0d3cd51e5438e57ce6af6516adab7843256a51cc7041c9a4a35dfef4438ea4c5dab92ef1a6fd632c0692
7
+ data.tar.gz: 6a0e9526b4273cb3a670fc8a739f594f57888b679575d386d2715a767ead935af4c909e6bbad2eac2f2764e1cca2db09d895b2cb9b664842978ce55f71590931
data/.standard.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  # For available configuration options, see:
2
2
  # https://github.com/testdouble/standard
3
- ruby_version: 3.4
3
+ parallel: true
4
+ ruby_version: 3.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ * IRCinch 2.4.4, 14 January 2026
2
+ - Improve performance for high traffic channels
3
+ - Increase test coverage
4
+ - Bug fixes
5
+
6
+ * IRCinch 2.4.3, 27 December 2025
7
+ - Fix SASL auth time out by fixing IRC message parsing expression (fix by @janikrabe)
8
+ - Remove various duplicate methods
9
+ - Update standardrb configuration and lint files
10
+ - Improve CI build and steps
11
+
1
12
  * IRCinch 2.4.2, 3 April 2025
2
13
  - Improve Gemspec metadata
3
14
  - Performance and linting improvements
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
@@ -8,6 +8,7 @@ require "ircinch"
8
8
 
9
9
  class Autovoice
10
10
  include Cinch::Plugin
11
+
11
12
  listen_to :join
12
13
  match(/autovoice (on|off)$/)
13
14
 
@@ -5,6 +5,7 @@ require "open-uri"
5
5
 
6
6
  class Google
7
7
  include Cinch::Plugin
8
+
8
9
  match(/google (.+)/)
9
10
 
10
11
  def search(query)
@@ -2,6 +2,7 @@ require "ircinch"
2
2
 
3
3
  class Nickchange
4
4
  include Cinch::Plugin
5
+
5
6
  listen_to :nick
6
7
 
7
8
  def listen(m)
@@ -2,6 +2,7 @@ require "ircinch"
2
2
 
3
3
  class MultiCommands
4
4
  include Cinch::Plugin
5
+
5
6
  match(/command1 (.+)/, method: :command1)
6
7
  match(/command2 (.+)/, method: :command2)
7
8
  match(/^command3 (.+)/, use_prefix: false)
@@ -8,6 +8,7 @@ class Seen
8
8
  end
9
9
 
10
10
  include Cinch::Plugin
11
+
11
12
  listen_to :channel
12
13
  match(/seen (.+)/)
13
14
 
data/ircinch.gemspec CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency "base64"
42
42
  spec.add_development_dependency "bundler-audit"
43
43
  spec.add_development_dependency "bundler-integrity"
44
+ spec.add_development_dependency "irb"
44
45
  spec.add_development_dependency "minitest"
45
46
  spec.add_development_dependency "rake"
46
47
  spec.add_development_dependency "simplecov"
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
data/lib/cinch/channel.rb CHANGED
@@ -23,7 +23,7 @@ module Cinch
23
23
  synced_attr_reader :users
24
24
 
25
25
  # @return [String] the channel's topic
26
- attr_accessor :topic
26
+ attr_reader :topic
27
27
  synced_attr_reader :topic
28
28
 
29
29
  # @return [Array<Ban>] all active bans
@@ -307,7 +307,6 @@ module Cinch
307
307
  @bot.irc.send("INVITE #{user} #{@name}")
308
308
  end
309
309
 
310
- undef_method(:topic=)
311
310
  # Sets the topic.
312
311
  #
313
312
  # @param [String] new_topic the new topic
@@ -418,10 +417,6 @@ module Cinch
418
417
  end
419
418
  super
420
419
  end
421
- alias_method :msg, :send # deprecated
422
- alias_method :privmsg, :send # deprecated
423
- undef_method(:msg) # yardoc hack
424
- undef_method(:privmsg) # yardoc hack
425
420
 
426
421
  # @deprecated
427
422
  def msg(*args)
@@ -447,8 +442,6 @@ module Cinch
447
442
  def to_s
448
443
  @name
449
444
  end
450
- alias_method :to_str, :to_s # deprecated
451
- undef_method(:to_str) # yardoc hack
452
445
 
453
446
  def to_str
454
447
  Cinch::Utilities::Deprecation.print_deprecation("2.2.0", "Channel#to_str", "Channel#to_s")
@@ -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/helpers.rb CHANGED
@@ -182,8 +182,6 @@ module Cinch
182
182
  def Format(*settings, string)
183
183
  Formatting.format(*settings, string)
184
184
  end
185
- alias_method :Color, :Format # deprecated
186
- undef_method(:Color) # yardoc hack
187
185
 
188
186
  def Color(*args)
189
187
  Cinch::Utilities::Deprecation.print_deprecation("2.2.0", "Helpers.Color", "Helpers.Format")
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(/(?:^@([^:]+))?(?::?(\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/target.rb CHANGED
@@ -48,10 +48,6 @@ module Cinch
48
48
  end
49
49
  end
50
50
  end
51
- alias_method :msg, :send # deprecated
52
- alias_method :privmsg, :send # deprecated
53
- undef_method(:msg) # yardoc hack
54
- undef_method(:privmsg) # yardoc hack
55
51
 
56
52
  # @deprecated
57
53
  def msg(*args)
@@ -80,21 +76,17 @@ module Cinch
80
76
  def safe_send(text, notice = false)
81
77
  send(Cinch::Helpers.sanitize(text), notice)
82
78
  end
83
- alias_method :safe_msg, :safe_send # deprecated
84
- alias_method :safe_privmsg, :safe_msg # deprecated
85
- undef_method(:safe_msg) # yardoc hack
86
- undef_method(:safe_privmsg) # yardoc hack
87
79
 
88
80
  # @deprecated
89
81
  def safe_msg(*args)
90
82
  Cinch::Utilities::Deprecation.print_deprecation("2.2.0", "Target#safe_msg", "Target#safe_send")
91
- send(*args)
83
+ safe_send(*args)
92
84
  end
93
85
 
94
86
  # @deprecated
95
87
  def safe_privmsg(*args)
96
88
  Cinch::Utilities::Deprecation.print_deprecation("2.2.0", "Target#safe_privmsg", "Target#safe_send")
97
- send(*args)
89
+ safe_send(*args)
98
90
  end
99
91
 
100
92
  # Like {#safe_msg} but for notices.
data/lib/cinch/user.rb CHANGED
@@ -261,13 +261,11 @@ module Cinch
261
261
  @bot.irc.send "WHOIS #{@name} #{@name}"
262
262
  end
263
263
  end
264
- alias_method :whois, :refresh # deprecated
265
- undef_method(:whois) # yardoc hack
266
264
 
267
265
  # @deprecated
268
- def whois
266
+ def whois(*args)
269
267
  Cinch::Utilities::Deprecation.print_deprecation("2.2.0", "User#whois", "User#refresh")
270
- refresh
268
+ refresh(*args)
271
269
  end
272
270
 
273
271
  # @param [Hash, nil] values A hash of values gathered from WHOIS,
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.2"
5
+ VERSION = "2.4.4"
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ircinch
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.2
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Sias
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-04 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ostruct
@@ -65,6 +65,20 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: irb
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
68
82
  - !ruby/object:Gem::Dependency
69
83
  name: minitest
70
84
  requirement: !ruby/object:Gem::Requirement
@@ -255,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
255
269
  - !ruby/object:Gem::Version
256
270
  version: '0'
257
271
  requirements: []
258
- rubygems_version: 3.6.6
272
+ rubygems_version: 4.0.3
259
273
  specification_version: 4
260
274
  summary: An IRC Bot Building Ruby Framework
261
275
  test_files: []