bazz1tv / ayumi

My lovely IRC bot :sparkles: :turtle: :mailbox: :sparkles:
0 stars 1 forks source link

@s doesn't work if message-history contains non-ASCII #70

Closed bazz1tv closed 8 years ago

bazz1tv commented 8 years ago
[2016/05/12 22:11:41.256] !! /usr/share/gems/gems/json-1.8.3/lib/json/common.rb:155:in `encode': "\xC2" on US-ASCII (Encoding::InvalidByteSequenceError)
[2016/05/12 22:11:41.256] !!    /usr/share/gems/gems/json-1.8.3/lib/json/common.rb:155:in `initialize'
[2016/05/12 22:11:41.256] !!    /usr/share/gems/gems/json-1.8.3/lib/json/common.rb:155:in `new'
[2016/05/12 22:11:41.257] !!    /usr/share/gems/gems/json-1.8.3/lib/json/common.rb:155:in `parse'
[2016/05/12 22:11:41.257] !!    /home/bazz/Code/ayumi/lib/cinch/plugins/s.rb:44:in `block in execute'
[2016/05/12 22:11:41.257] !!    /home/bazz/Code/ayumi/lib/cinch/plugins/s.rb:44:in `map'
[2016/05/12 22:11:41.257] !!    /home/bazz/Code/ayumi/lib/cinch/plugins/s.rb:44:in `execute'
[2016/05/12 22:11:41.257] !!    /home/bazz/.gem/ruby/gems/cinch-2.3.1/lib/cinch/plugin.rb:418:in `call'
[2016/05/12 22:11:41.257] !!    /home/bazz/.gem/ruby/gems/cinch-2.3.1/lib/cinch/plugin.rb:418:in `block (2 levels) in __register_matchers'
[2016/05/12 22:11:41.257] !!    /home/bazz/.gem/ruby/gems/cinch-2.3.1/lib/cinch/handler.rb:99:in `call'
[2016/05/12 22:11:41.257] !!    /home/bazz/.gem/ruby/gems/cinch-2.3.1/lib/cinch/handler.rb:99:in `block in call'
[2016/05/12 22:11:41.257] !! [Thread done] For #<Cinch::Handler @event=:message pattern=#<Cinch::Pattern:0x00557f9d2961d0 @prefix="@", @pattern=/s\/(.+)\/(.*)\/([ig]+)?/, @suffix=nil>>: #<Thread:0x00557f9d182550> -- 0 remaining.
[2016/05/12 22:11:43.856] >> :Ordinate!~Ordinate@adsl-99-1-119-81.dsl.chcgil.sbcglobal

that is this line: history = @bot.redis.lrange(list, 0, 100).map { |msg| JSON.parse msg }

an example of a problematic msg is likely こんにちは

the JSON string comes in the form: {"nick":"bazz","message":"derp"}

bazz1tv commented 8 years ago

this seems to be solved by stevekinney/pizza#103 Encoding.default_external = 'UTF-8'

bazz1tv commented 8 years ago

8b0e7268fc6cc9f446debb6b1b753c78db742c94