-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
62 lines (46 loc) · 1.32 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
59
60
61
62
package main
import (
"io/ioutil"
"log"
"reverseGifBot/utils"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
func main() {
bot, err := tgbotapi.NewBotAPI("1802468177:AAET5EL6gU6fTKAqh05MIravDbdPcDFeFWY")
if err != nil {
log.Panic(err)
}
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil { // ignore any non-Message Updates
continue
}
if update.Message.Animation == nil {
errMsg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hey "+ update.Message.From.FirstName+", Send a GIF file")
errMsg.ReplyToMessageID = update.Message.MessageID
bot.Send(errMsg)
continue
}
mp4filePath, _ := bot.GetFileDirectURL(update.Message.Animation.FileID)
utils.Reverse(mp4filePath)
gifBytes, err := ioutil.ReadFile("./files/reversed.mp4")
if err != nil {
panic(err)
}
photoFileBytes := tgbotapi.FileBytes{
Name: "./files/reversed.mp4",
Bytes: gifBytes,
}
msg := tgbotapi.NewAnimationUpload(update.Message.Chat.ID, photoFileBytes)
msg.ReplyToMessageID = update.Message.MessageID
resp, err := bot.Send(msg)
if err != nil {
log.Println("error is -----", err)
}
log.Println("response is -----", resp)
}
}