-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from dvgamerr/feat/notifi-line
Feature Notify message.
- Loading branch information
Showing
7 changed files
with
117 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,27 @@ | ||
package act | ||
|
||
type LineNotify struct { | ||
Token string `yaml:"token"` | ||
Minitify bool `yaml:"minitify"` | ||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/go-resty/resty/v2" | ||
) | ||
|
||
func (hoyo *Hoyolab) NotifyMessage(message string) error { | ||
if hoyo.Notify.Token == "" || message == "" { | ||
return nil | ||
} | ||
|
||
raw, err := resty.New().R(). | ||
SetHeaders(map[string]string{"Authorization": fmt.Sprintf("Bearer %s", hoyo.Notify.Token)}). | ||
SetFormData(map[string]string{"message": message}). | ||
Post("https://notify-api.line.me/api/notify") | ||
if err != nil { | ||
return fmt.Errorf("notify::%+v", err) | ||
} | ||
if raw.StatusCode() != 200 { | ||
return fmt.Errorf("notify::%s", raw.Status()) | ||
} | ||
log.Println("NotifyMessage Sending...") | ||
return nil | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters