wbh-community / wb-discord-bot

Discord Bot to connect the Discord and Discourse Server
MIT License
0 stars 0 forks source link

webhook for the bot #3

Closed kreativmonkey closed 3 years ago

kreativmonkey commented 3 years ago

https://hackaday.com/2018/02/15/creating-a-discord-webhook-in-python/

kreativmonkey commented 3 years ago

Scheinbar ist flask das mittel der wahl... https://forum.uipath.com/t/creating-a-simple-webhook-listener-using-python/235217 schaut recht simpel aus.

kreativmonkey commented 3 years ago

Beispiel der umsetzung: https://stackoverflow.com/questions/48693069/running-flask-a-discord-bot-in-the-same-application

kreativmonkey commented 3 years ago

Secret Verification example: https://meta.discourse.org/t/discourse-signing-parameters-in-webhooks/134415

Code im Discourse:

  def payload(secret = nil)
    payload = Base64.strict_encode64(unsigned_payload)
    "sso=#{CGI::escape(payload)}&sig=#{sign(payload, secret)}"
  end

https://github.com/discourse/discourse/blob/75e159f0ed6df4db271c528ed49098ea4a0f25c3/lib/single_sign_on.rb#L129

if @web_hook.secret.present?
        headers['X-Discourse-Event-Signature'] = "sha256=#{OpenSSL::HMAC.hexdigest("sha256", @web_hook.secret, web_hook_body)}"
end

https://github.com/discourse/discourse/blob/75e159f0ed6df4db271c528ed49098ea4a0f25c3/app/jobs/regular/emit_web_hook_event.rb#L155