/
main.go
60 lines (47 loc) · 1.28 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
package main
import (
"fmt"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
jsonconfig "github.com/nikserg/go-json-config"
)
type Config struct {
BotToken string
}
func main() {
fmt.Println("Start")
var config Config
jsonconfig.ReadConfig("config.json", &config)
fmt.Printf("TG token %v \n", config.BotToken)
bot, err := tgbotapi.NewBotAPI(config.BotToken)
if err != nil {
panic(err)
}
bot.Debug = true
fmt.Printf("Authorized on account %s", bot.Self.UserName)
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message != nil { // If we got a message
fmt.Printf("[%s] %v", update.Message.From.UserName, update.Message)
for _, photo := range update.Message.Photo {
picUrl, _ := bot.GetFileDirectURL(photo.FileID)
isNotFake, fakeMessage := CheckYandex(picUrl)
// if isNotFake {
// isNotFake, fakeMessage = CheckTineye(picUrl)
// }
var resultMessage string
if !isNotFake {
resultMessage = "❌ fake \n"
resultMessage += fakeMessage
} else {
resultMessage = "✅ not fake"
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, resultMessage)
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
break
}
}
}
}