Code Monkey home page Code Monkey logo

Comments (3)

northportio avatar northportio commented on May 12, 2024 2

Thanks for queuing me in @K0p1-Git.

I haven't looked into this in-depth yet but I'll explore this more.

My initial answer:

To the best of my knowledge, I may be incorrect here but you basically create the app in slack, copy the webhook to the script and then add the app to the channel (that gives authorization to post in said channel). If you had the app added to multiple channels, I believe that's where the channel name designation matters.

I will look into this more on my spare time but that's my initial answer. Hope that somewhat answers your question.

from cloudflare-ddns-updater.

K0p1-Git avatar K0p1-Git commented on May 12, 2024

Hey @northportio, if its possible do take a look at this.

from cloudflare-ddns-updater.

Sailboat265 avatar Sailboat265 commented on May 12, 2024

@northportio Yep! You're correct however...(Hey! Just my two cents opinion down here)

Afaik, because of security scopes, Webhooks are usually tied to a specific channel. Each webhooks uri is unique, no matter the app, destination channel etc. (You can try create a duplicate webhook, and see that the request uri is different even thought they post to the same channel, from the same app etc)

To implement channel name designation, i think the following steps must be done.

An user needs to go to here. Create an app, and go to OAuth & Permissions, then setup the necessary OAuth permission scopes like channels:read for reading available channels, and chat:write for sending messages.

Then copy the bot user oauth token, it usually starts with xoxb-<...>.

Then post request code shall be like:

#!/bin/bash
slack_api_url="https://slack.com/api/chat.postMessage"
slack_app_token="your-bot-user-oauth-token-here"
slack_channel="general"

slack=$(curl -s -X POST $slack_api_url \
    -H "Authorization: Bearer $slack_app_token" \
    -H "Content-type: application/json; charset=UTF-8" \
    --data "{\"channel\":\"$slack_channel\",\"text\": \"Hello world! I'm sending message to $slack_channel channel.\"}")

If you're interested, you can learn more here!

  1. Message Posting API
  2. Webhooks

from cloudflare-ddns-updater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.