https://github.com/winterhart/farfetch
slack API minimal library
https://github.com/winterhart/farfetch
api golang slack
Last synced: about 1 month ago
JSON representation
slack API minimal library
- Host: GitHub
- URL: https://github.com/winterhart/farfetch
- Owner: Winterhart
- License: agpl-3.0
- Created: 2020-05-18T16:07:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-11T19:30:31.000Z (over 4 years ago)
- Last Synced: 2025-05-18T14:43:05.484Z (about 1 year ago)
- Topics: api, golang, slack
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Farfetch
A tiny piece software to send files and messages using slack API

Image from: http://pixelartmaker.com/art/f740b9b40b4942d
## Overview
- Library to send message and upload file to Slack
- You can compile and use as binary
- You can also import and use it in your code
## Setup
This library needs three variables to work:
- A slack-web hook (`hook`)
- A slack token (`token`)
- You also need to choose a slack channel (`channel id`)
### How to get the hook?
- https://api.slack.com/messaging/webhooks
### How to get the token?
- https://api.slack.com/authentication/token-types
### How to get the channel id?
- https://www.wikihow.com/Find-a-Channel-ID-on-Slack-on-PC-or-Mac
## Usage
You can use this project in two distinct ways.
#### as a binary
Append your `env` with the following variable: `SLACK_HOOK` your web-hook, `SLACK_TOKEN` your token
and `SLACK_CH` your channel id.
Then build the binary
```bash
go build cmd/main.go
```
Make the generated `farfetch` binary file executable
```bash
chmod +x ./farfetch
```
Then you can use the binary:
```bash
./farfetch send hello
```
Will send `hello` using your slack-bot to your designated slack channel.
```bash
./farfetch upload ~/pictures/photo.png
```
Will upload the file `photo.png` to your designated slack channel...
#### as a package
You can use this project as a package in your golang project.
```golang
package main
import (
"os"
"github.com/winterhart/farfetch"
)
func main() {
webHook := os.Getenv(`SLACK_HOOK`)
slack := farfetch.NewFarfetchImpl(webHook, "", "")
slack.SendMessage("This message is from another project using Farfetch! ")
}
```