Skip to content

Commit bf1d8dc

Browse files
authored
Merge pull request #17 from timfanda35/remove-line-notify
Remove deprecated Line Notify feature
2 parents e534ad1 + e6e8b98 commit bf1d8dc

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Send simple message via channel's RESTful API.
44

55
Support channels:
66
- Telegram
7-
- Line Notify
87
- Hangouts Chat
98
- Slack
109
- Discord
@@ -34,25 +33,6 @@ References:
3433
- [從零開始的 Telegram Bot](https://blog.sean.taipei/2017/05/telegram-bot)
3534
- [用 Docker Multi-Stage 編譯出 Go 語言最小 Image](https://blog.wu-boy.com/2017/04/build-minimal-docker-container-using-multi-stage-for-go-app/)
3635

37-
## Line Notify
38-
39-
Send notify message to Line Notify
40-
41-
```
42-
docker run \
43-
-e NOTIFY_LINE_NOTIFY_TOKEN="$NOTIFY_LINE_NOTIFY_TOKEN" \
44-
ghcr.io/timfanda35/simple-channel-notify \
45-
linenotify --message="Notify Message~~~"
46-
```
47-
48-
Environment Variables
49-
- `NOTIFY_LINE_NOTIFY_TOKEN`
50-
51-
References:
52-
53-
- [LINE Notify API Document](https://notify-bot.line.me/doc/en/)
54-
- [自建 LINE Notify 訊息通知](https://www.oxxostudio.tw/articles/201806/line-notify.html)
55-
5636
## Hangouts Chat
5737

5838
Send notify message to Hangouts Chat

main.go

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -49,41 +49,6 @@ func notifyTelegram(message string) {
4949
log.Print("Telegram notified")
5050
}
5151

52-
/*
53-
# Line Notify
54-
55-
Parameters:
56-
- message
57-
58-
Environment variables:
59-
- NOTIFY_LINE_NOTIFY_TOKEN
60-
*/
61-
func notifyLineNotify(message string) {
62-
// Load environment variables
63-
lineNotifyToken, ok := os.LookupEnv("NOTIFY_LINE_NOTIFY_TOKEN")
64-
if !ok {
65-
log.Fatal("NOTIFY_LINE_NOTIFY_TOKEN environment variable is unset")
66-
}
67-
68-
endpoint := "https://notify-api.line.me/api/notify"
69-
data := url.Values{"message": {message}}
70-
body := strings.NewReader(data.Encode())
71-
72-
req, err := http.NewRequest("POST", endpoint, body)
73-
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
74-
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", lineNotifyToken))
75-
76-
client := &http.Client{}
77-
resp, err := client.Do(req)
78-
if err != nil {
79-
panic(err)
80-
}
81-
defer resp.Body.Close()
82-
83-
ioutil.ReadAll(resp.Body)
84-
log.Print("Line Notify notified")
85-
}
86-
8752
/*
8853
# Hangouts Chat
8954
@@ -185,9 +150,6 @@ func main() {
185150
telegramCmd := flag.NewFlagSet("telegram", flag.ExitOnError)
186151
telegramMessage := telegramCmd.String("message", "This is a test message", "message")
187152

188-
lineNotifyCmd := flag.NewFlagSet("linenotify", flag.ExitOnError)
189-
lineNotifyMessage := lineNotifyCmd.String("message", "This is a test message", "message")
190-
191153
hangoutsChatCmd := flag.NewFlagSet("hangoutschat", flag.ExitOnError)
192154
hangoutsChatMessage := hangoutsChatCmd.String("message", "This is a test message", "message")
193155

@@ -198,17 +160,14 @@ func main() {
198160
discordMessage := discordCmd.String("message", "This is a test message", "message")
199161

200162
if len(os.Args) < 2 {
201-
log.Println("Expected 'telegram', 'linenotify', 'hangoutschat', 'slack', or 'discord'")
163+
log.Println("Expected 'telegram', 'hangoutschat', 'slack', or 'discord'")
202164
os.Exit(1)
203165
}
204166

205167
switch os.Args[1] {
206168
case "telegram":
207169
telegramCmd.Parse(os.Args[2:])
208170
notifyTelegram(*telegramMessage)
209-
case "linenotify":
210-
lineNotifyCmd.Parse(os.Args[2:])
211-
notifyLineNotify(*lineNotifyMessage)
212171
case "hangoutschat":
213172
hangoutsChatCmd.Parse(os.Args[2:])
214173
notifyHangoutsChat(*hangoutsChatMessage)
@@ -219,7 +178,7 @@ func main() {
219178
discordCmd.Parse(os.Args[2:])
220179
notifyDiscord(*discordMessage)
221180
default:
222-
log.Println("Expected 'telegram', 'linenotify', 'hangoutschat', 'slack', or 'discord'")
181+
log.Println("Expected 'telegram', 'hangoutschat', 'slack', or 'discord'")
223182
os.Exit(1)
224183
}
225184
}

0 commit comments

Comments
 (0)