-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
58 lines (53 loc) · 1.19 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
// "context"
"fmt"
"log"
"strconv"
"github.com/actions-go/toolkit/core"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
type Telegram struct {
token string
id int64
parse_mode string
message string
}
func wrapTelegram() *Telegram {
token, err := core.GetInput("TELEGRAM_TOKEN")
if !err {
fmt.Printf("Error to get Input: TELEGRAM_TOKEN")
}
raw_id, err1 := core.GetInput("TELEGRAM_TO")
if !err1 {
fmt.Printf("Error to get Input: TELEGRAM_TO")
}
parse_mode, err2 := core.GetInput("parse_mode")
if !err2 {
fmt.Printf("Error to get Input: parse_mode")
}
raw, err3 := core.GetInput("message")
if !err3 {
fmt.Printf("Error to get Input: message")
}
id, err4 := strconv.ParseInt(raw_id, 10, 64)
if err4 != nil {
core.Error("Error when convert id to int64")
}
message := tgbotapi.EscapeText(parse_mode, raw)
T := Telegram{token: token}
T.id = id
T.parse_mode = parse_mode
T.message = message
return &T
}
func main() {
Telegram := wrapTelegram()
bot, err := tgbotapi.NewBotAPI(Telegram.token)
if err != nil {
log.Panic(err)
}
bot.Debug = false
msg := tgbotapi.NewMessage(Telegram.id, Telegram.message)
bot.Send(msg)
}