diff options
author | icebaker <icebaker@proton.me> | 2023-12-07 21:13:32 -0300 |
---|---|---|
committer | icebaker <icebaker@proton.me> | 2023-12-07 21:13:32 -0300 |
commit | df565c04fda0a8c60437559266e2958f58fc8310 (patch) | |
tree | b8adb2c1fbde782ac7ee32e187fc09aa55aa9299 | |
parent | fb7df6529de160340480272f92554862ce8d4569 (diff) |
ensuring backward compatibility for callbacks
-rw-r--r-- | components/stream.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/components/stream.rb b/components/stream.rb index 73da8b0..0a16dde 100644 --- a/components/stream.rb +++ b/components/stream.rb @@ -13,7 +13,11 @@ module NanoBot @accumulated = "#{@accumulated.force_encoding('UTF-8')}#{args.first.force_encoding('UTF-8')}" end - @callback.call(@accumulated, args.first, false, args[1]) + if @callback.arity == 3 + @callback.call(@accumulated, args.first, false) + else + @callback.call(@accumulated, args.first, false, args[1]) + end end super(args.first) end @@ -30,7 +34,11 @@ module NanoBot rewind if @callback - @callback.call(@accumulated, nil, true) + if @callback.arity == 3 + @callback.call(@accumulated, nil, true) + else + @callback.call(@accumulated, nil, true, nil) + end @callback = nil @accumulated = nil end |