Pages

Bài đăng phổ biến

Saturday, September 28, 2024

How to create a bot to automate daily tasks using Slack

How to create a bot to automate daily tasks using Slack

Nguyen Si Nhan


1. Setting Up Your Slack App
  • Create a Slack App: Sign in to your Slack workspace and head over to https://api.slack.com/quickstart. Choose "From Scratch" and give your app a descriptive name. Click "Create App."
  • Configure OAuth & Permissions: Navigate to the "OAuth & Permissions" section and then "Bot User OAuth Token." Grant your bot the following scopes:
    • channels:history - Access past messages in channels.
    • chat:write - Allow the bot to post messages in channels.
    • commands - Enable the bot to respond to slash commands.
    • groups:history (Optional) - Access past messages in private channels (groups).
    • im:history, im:read, im:write (Optional) - Allow interaction with Direct Messages (DMs).
    • incoming-webhook - Enable receiving messages from webhooks.
  • Optional: User Token Scopes - Define additional permissions for users interacting with the bot, such as channels:read for viewing messages in channels.
  • Restrict API Token Usage (Optional): For added security, consider restricting where your API tokens can be used.
  • Event Subscriptions: Configure URLs for receiving real-time events from Slack. You'll define these URLs in your code (explained in step 2). Here's an example URL: https://automation.0937686468.com/slack/events.

2. Automation Bot Code:

The code for your automation bot can be found here: https://github.com/nhannguyensy/automation-bot-v2/tree/master (by nhannguyensy)

This guide provides a basic framework for setting up your Slack bot. You can customize the code further to automate specific tasks according to your needs.

And the picture below is the result after you finish: 






Thursday, January 12, 2023

[ Solved ] : hudson.remoting.ProxyException: io.fabric8.kubernetes.client.KubernetesClientException: No httpclient implementations found on the context classloader, please ensure your classpath includes an implementation jar

With this error: hudson.remoting.ProxyException: io.fabric8.kubernetes.client.KubernetesClientException: No httpclient implementations found on the context classloader, please ensure your classpath includes an implementation jar 

You can resolve by install this plugin : Pipeline: GitHub Groovy Libraries .




Finish ! 

Tuesday, January 10, 2023

[ Linux ] : Bash script

# Create folder named with month : 
printf '%s\n' {1..12}/01 | xargs -I {} date -d {} +%b | xargs mkdir --
# Create folder named with day:
cd Jan && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Feb && for i in {1..28} ; do mkdir -p $i; done && cd .. && cd Mar && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Apr && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd May && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Jun && for i in {1..30} ; do mkdir -p $i; done && cd .. && cd Jul && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Aug && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Sep && for i in {1..30} ; do mkdir -p $i; done && cd .. && cd Oct && for i in {1..31} ; do mkdir -p $i; done && cd .. && cd Nov && for i in {1..30} ; do mkdir -p $i; done && cd .. && cd Dec && for i in {1..31} ; do mkdir -p $i; done && cd ..