mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
Invite: fix "none yet" message on users created
This commit is contained in:
parent
0e21942cd6
commit
b91302ddf8
5
lang/telegram/en-gb.json
Normal file
5
lang/telegram/en-gb.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "English (GB)"
|
||||
}
|
||||
}
|
11
lang/telegram/en-us.json
Normal file
11
lang/telegram/en-us.json
Normal file
@ -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>."
|
||||
}
|
||||
}
|
8
telegram/go.mod
Normal file
8
telegram/go.mod
Normal file
@ -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
|
||||
)
|
4
telegram/go.sum
Normal file
4
telegram/go.sum
Normal file
@ -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=
|
59
telegram/telegram.go
Normal file
59
telegram/telegram.go
Normal file
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
4
telegram/telegram.txt
Normal file
4
telegram/telegram.txt
Normal file
@ -0,0 +1,4 @@
|
||||
API key: 1785754648:AAG4G6PKZpGDEJM_-MeQHJqD-xUDrrLrTC4
|
||||
|
||||
Name: jfa-bot
|
||||
Username: jfago_bot
|
@ -120,7 +120,7 @@ class DOMInvite implements Invite {
|
||||
get usedBy(): { [name: string]: number } { return this._usedBy; }
|
||||
set usedBy(uB: { [name: string]: number }) {
|
||||
this._usedBy = uB;
|
||||
if (uB.length == 0) {
|
||||
if (Object.keys(uB).length == 0) {
|
||||
this._right.classList.add("empty");
|
||||
this._userTable.innerHTML = `<p class="content">${window.lang.strings("inviteNoUsersCreated")}</p>`;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user