diff --git a/sgx-bwmsgsv2.rb b/sgx-bwmsgsv2.rb index 416629788b98b746fcb1e8f42647017c13b8b33f..2b6dc35adc2d8f95a057ef89e46d333e91d82d75 100755 --- a/sgx-bwmsgsv2.rb +++ b/sgx-bwmsgsv2.rb @@ -1111,8 +1111,16 @@ class WebhookHandler < Goliath::API puts text end - if not msg - msg = Blather::Stanza::Message.new(bare_jid, text) + # If text is not empty, but there isn't a msg, + # we need to construct a msg to convey that text + unless msg || text&.empty? + msg = Blather::Stanza::Message.new( + bare_jid, + # TODO: The numbers, what do they mean? + text.gsub(/[\u0000-\u0008\u000b-\u001f]/, "") + ) + msg.document.encoding = "utf-8" + msg.chat_state = nil end else # per prior switch, this is: jparams['direction'] == 'out' tag_parts = jparams['tag'].split(/ /, 2)