Merge branch 'main' into telegram

pull/97/head
Harvey Tindall 4 years ago committed by GitHub
commit c560ec0f9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,9 +3,9 @@
"name": "English (US)"
},
"strings": {
"startMessage": "Hi!\nEnter your test PIN code here to verify your account.",
"languageMessage": "Note: See available languages with /lang, and set language with /lang <language code>.",
"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."
"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

@ -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…
Cancel
Save