Discord: Start bot, add !start and pin validity check

The bot should be created by the admin and added to a discord server
mutual to the intended new user(s). On !start in the server,
communication is moved to DMs. Currently !start works, and validity of a
given PIN is checked although nothing it done with this yet.
This commit is contained in:
Harvey Tindall
2021-05-17 23:42:33 +01:00
parent 4b11bbe21f
commit d928df7ab2
8 changed files with 279 additions and 25 deletions
+14
View File
@@ -96,6 +96,7 @@ type appContext struct {
validator Validator
email *Emailer
telegram *TelegramDaemon
discord *DiscordDaemon
info, debug, err logger.Logger
host string
port int
@@ -341,6 +342,10 @@ func start(asDaemon, firstCall bool) {
if err := app.storage.loadTelegramUsers(); err != nil {
app.err.Printf("Failed to load Telegram users: %v", err)
}
app.storage.discord_path = app.config.Section("files").Key("discord_users").String()
if err := app.storage.loadDiscordUsers(); err != nil {
app.err.Printf("Failed to load Discord users: %v", err)
}
app.storage.profiles_path = app.config.Section("files").Key("user_profiles").String()
app.storage.loadProfiles()
@@ -567,6 +572,15 @@ func start(asDaemon, firstCall bool) {
defer app.telegram.Shutdown()
}
}
if discordEnabled {
app.discord, err = newDiscordDaemon(app)
if err != nil {
app.err.Printf("Failed to authenticate with Discord: %v", err)
} else {
go app.discord.run()
defer app.discord.Shutdown()
}
}
} else {
debugMode = false
address = "0.0.0.0:8056"