mirror of https://github.com/hrfee/jfa-go
parent
0e21942cd6
commit
b91302ddf8
@ -0,0 +1,5 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "English (GB)"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "English (US)"
|
||||
},
|
||||
"strings": {
|
||||
"startMessage": "Hi!\nEnter your Jellyfin PIN code here to verify your account.",
|
||||
"invalidPIN": "That PIN was invalid, try again.",
|
||||
"pinSuccess": "Success! You can now return to the sign-up page.",
|
||||
"languageMessage": "Note: See available languages with /lang, and set language with /lang <language code>."
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
module github.com/hrfee/jfa-go/telegram
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
|
||||
)
|
@ -0,0 +1,4 @@
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM=
|
||||
github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog=
|
@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
tg "github.com/go-telegram-bot-api/telegram-bot-api"
|
||||
)
|
||||
|
||||
const (
|
||||
TOKEN = "1785754648:AAG4G6PKZpGDEJM_-MeQHJqD-xUDrrLrTC4"
|
||||
USER = "johnikwock"
|
||||
|
||||
AUTH = "AB-CD-EF"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.Println("Connecting...")
|
||||
bot, err := tg.NewBotAPI(TOKEN)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to initialize bot: %v", err)
|
||||
}
|
||||
bot.Debug = false
|
||||
log.Printf("Authorized Telegram bot \"%s\"", bot.Self.UserName)
|
||||
|
||||
u := tg.NewUpdate(0)
|
||||
u.Timeout = 60
|
||||
|
||||
updates, err := bot.GetUpdatesChan(u)
|
||||
|
||||
for update := range updates {
|
||||
if update.Message == nil {
|
||||
continue
|
||||
}
|
||||
log.Printf("New message from \"@%s\": \"%s\"", update.Message.From.UserName, update.Message.Text)
|
||||
if update.Message.From.UserName != USER {
|
||||
continue
|
||||
}
|
||||
var msg tg.MessageConfig
|
||||
sects := strings.Split(update.Message.Text, " ")
|
||||
if sects[0] == "/start" {
|
||||
msg = tg.NewMessage(update.Message.Chat.ID, fmt.Sprintf("Enter this code on the sign-up page to continue: %s", AUTH))
|
||||
} else if sects[0] != "/auth" || sects[len(sects)-1] != AUTH {
|
||||
log.Println("Invalid command or auth token")
|
||||
msg = tg.NewMessage(update.Message.Chat.ID, "Invalid command or token")
|
||||
} else {
|
||||
msg = tg.NewMessage(update.Message.Chat.ID, "Success!")
|
||||
log.Println("Successful auth")
|
||||
}
|
||||
msg.ReplyToMessageID = update.Message.MessageID
|
||||
|
||||
_, err := bot.Send(msg)
|
||||
if err != nil {
|
||||
log.Printf("Send failed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
API key: 1785754648:AAG4G6PKZpGDEJM_-MeQHJqD-xUDrrLrTC4
|
||||
|
||||
Name: jfa-bot
|
||||
Username: jfago_bot
|
Loading…
Reference in new issue