Microsoft Teams escaping underscores in text

浪尽此生 提交于 2021-02-08 11:38:50

问题


I have following function in ruby to send aws logs to microsoft team channel through webhook. Some text contains underscore signs like connection_web but appears like connectionweb in MS teams. How to get the exact output ?

require 'json'
require 'net/https'
require 'uri'
require 'base64'
require 'zlib'
require 'stringio'
def lambda_handler(event:, context:)
  log_event = JSON.parse(decode_and_decompress(event["awslogs"]["data"]))
  response = speak(messages_from_blob(log_event))
  puts response.body
end
def speak(message)
  http = Net::HTTP.new("MS-Teamwebhook.com", 443)
  http.use_ssl = true
  request = Net::HTTP::Post.new(ENV["HOOK_URL"])
  request.body = JSON.generate({
    text: message
  })
  http.request(request)
end
def decode_and_decompress(input)
  binary_compressed = Base64.decode64(input)
  gz = Zlib::GzipReader.new(StringIO.new(binary_compressed))    
  gz.read
end
def messages_from_blob(event_data)
  event_data["logEvents"]
    .map{ |e| e["message"] }
    .join("\n")
end

来源:https://stackoverflow.com/questions/65923762/microsoft-teams-escaping-underscores-in-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!