-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
53 lines (44 loc) · 887 Bytes
/
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
package main
import (
"log"
"os"
"time"
"github.com/yanzay/tbot/v2"
)
type application struct {
client *tbot.Client
}
var (
app application
bot *tbot.Server
tgtoken string
newMsg string
newTxHash string
)
func main() {
tgtoken = os.Getenv("TOKEN")
bot = tbot.New(tgtoken)
app.client = bot.Client()
bot.Use(stat)
bot.HandleMessage("show aadao", app.GenTxHandler)
go func() {
for {
oldMsg, err := GetTokensAuto()
if err != nil {
log.Println(err)
}
if oldMsg != newMsg && Txhash != newTxHash {
bot.Use(stat)
chatID := "@atomgov"
_, err = app.client.SendMessage(chatID, "Latest spend by AADAO:\n\n"+oldMsg, tbot.OptParseModeHTML)
if err != nil {
log.Println("Error sending message:", err)
}
newMsg = oldMsg
newTxHash = Txhash
}
time.Sleep(20 * time.Second)
}
}()
log.Fatal(bot.Start())
}