forked from Minecraft/canopeas
Add config for register URL and check for dupes (#12)
Update modules Signed-off-by: Etzelia <etzelia@hotmail.com> Update module Signed-off-by: Etzelia <etzelia@hotmail.com> Start CI Move welcome channel to register table Signed-off-by: Etzelia <etzelia@hotmail.com> Add config for register URL and check for dupes Signed-off-by: Etzelia <etzelia@hotmail.com> Reviewed-on: https://git.canopymc.net/Etzelia/canopeas/pulls/12 Reviewed-by: ZeroHD <joey@ahines.net> Co-Authored-By: Etzelia <etzelia@hotmail.com> Co-Committed-By: Etzelia <etzelia@hotmail.com>discord-sync
parent
4fb7cc2928
commit
74e49546fe
|
@ -37,6 +37,6 @@ steps:
|
||||||
settings:
|
settings:
|
||||||
token:
|
token:
|
||||||
from_secret: gitea_token
|
from_secret: gitea_token
|
||||||
base: https://git.birbmc.com
|
base: https://git.canopymc.net
|
||||||
files:
|
files:
|
||||||
- "canopeas"
|
- "canopeas"
|
|
@ -13,12 +13,6 @@ mc_path = "/home/minecraft/server/"
|
||||||
# fired_role is to check how many time Carolyn has been fired
|
# fired_role is to check how many time Carolyn has been fired
|
||||||
fired_role = "0"
|
fired_role = "0"
|
||||||
|
|
||||||
# register_role is the role to assign to a user after registering
|
|
||||||
register_role = "0"
|
|
||||||
|
|
||||||
# registered_channel is the channel to message to welcome the newly registered user
|
|
||||||
registered_channel = "0"
|
|
||||||
|
|
||||||
# leave_channel is the channel to post leave messages to
|
# leave_channel is the channel to post leave messages to
|
||||||
leave_channel = "0"
|
leave_channel = "0"
|
||||||
|
|
||||||
|
@ -31,6 +25,16 @@ meme_rate = "0"
|
||||||
# Imgur Client ID
|
# Imgur Client ID
|
||||||
imgur_client_id = ""
|
imgur_client_id = ""
|
||||||
|
|
||||||
|
[register]
|
||||||
|
# role is the role to assign to a user after registering
|
||||||
|
role = "0"
|
||||||
|
|
||||||
|
# url is the URL to show to new users
|
||||||
|
url = "https://google.com"
|
||||||
|
|
||||||
|
# welcome_channel is the channel to message to welcome the newly registered user
|
||||||
|
welcome_channel = "0"
|
||||||
|
|
||||||
# ServerAPI options
|
# ServerAPI options
|
||||||
[serverapi]
|
[serverapi]
|
||||||
# API endpoint
|
# API endpoint
|
||||||
|
|
|
@ -35,17 +35,19 @@ type Config struct {
|
||||||
AccessToken string `toml:"access_token"`
|
AccessToken string `toml:"access_token"`
|
||||||
AccessSecret string `toml:"access_secret"`
|
AccessSecret string `toml:"access_secret"`
|
||||||
} `toml:"twitter"`
|
} `toml:"twitter"`
|
||||||
|
StaffRoles []string `toml:"staff_roles"`
|
||||||
StaffRoles []string `toml:"staff_roles"`
|
Echoes []Echo `toml:"echoes"`
|
||||||
Echoes []Echo `toml:"echoes"`
|
Albums []Album `toml:"albums"`
|
||||||
Albums []Album `toml:"albums"`
|
MessageRoles []MessageRole `toml:"message_roles"`
|
||||||
MessageRoles []MessageRole `toml:"message_roles"`
|
Register struct {
|
||||||
RegisterRole string `toml:"register_role"`
|
URL string `toml:"url"`
|
||||||
RegisteredChannel string `toml:"registered_channel"`
|
Role string `toml:"role"`
|
||||||
LeaveChannel string `toml:"leave_channel"`
|
WelcomeChannel string `toml:"welcome_channel"`
|
||||||
FiredRole string `toml:"fired_role"`
|
} `toml:"register"`
|
||||||
MemeRate string `toml:"meme_rate"`
|
LeaveChannel string `toml:"leave_channel"`
|
||||||
Insult struct {
|
FiredRole string `toml:"fired_role"`
|
||||||
|
MemeRate string `toml:"meme_rate"`
|
||||||
|
Insult struct {
|
||||||
Targets []string `toml:"targets"`
|
Targets []string `toml:"targets"`
|
||||||
Comparisons []string `toml:"comparisons"`
|
Comparisons []string `toml:"comparisons"`
|
||||||
Adjectives []string `toml:"adjectives"`
|
Adjectives []string `toml:"adjectives"`
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/go-serverapi"
|
"git.canopymc.net/Etzelia/go-serverapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/falseknees"
|
"git.canopymc.net/Etzelia/falseknees"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/go-serverapi"
|
"git.canopymc.net/Etzelia/go-serverapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -5,10 +5,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/config"
|
"git.canopymc.net/Etzelia/canopeas/config"
|
||||||
"git.birbmc.com/canopeas/database"
|
"git.canopymc.net/Etzelia/canopeas/database"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/go-serverapi"
|
"git.canopymc.net/Etzelia/go-serverapi"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
"github.com/dghubble/go-twitter/twitter"
|
"github.com/dghubble/go-twitter/twitter"
|
||||||
"github.com/dghubble/oauth1"
|
"github.com/dghubble/oauth1"
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/config"
|
"git.canopymc.net/Etzelia/canopeas/config"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/config"
|
"git.canopymc.net/Etzelia/canopeas/config"
|
||||||
"git.birbmc.com/canopeas/imgur"
|
"git.canopymc.net/Etzelia/canopeas/imgur"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package discord
|
package discord
|
||||||
|
|
||||||
import "git.birbmc.com/Etzelia/inspiro"
|
import "git.canopymc.net/Etzelia/inspiro"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
commands = append(commands, &command{
|
commands = append(commands, &command{
|
||||||
|
|
|
@ -7,10 +7,10 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/config"
|
"git.canopymc.net/Etzelia/canopeas/config"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/go-mcm"
|
"git.canopymc.net/Etzelia/go-mcm"
|
||||||
"git.birbmc.com/Etzelia/go-mcm/model/django"
|
"git.canopymc.net/Etzelia/go-mcm/model/django"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bannedPlayersFile = "banned-players.json"
|
const bannedPlayersFile = "banned-players.json"
|
||||||
|
@ -69,7 +69,7 @@ func init() {
|
||||||
}
|
}
|
||||||
} else if len(apps) > 0 {
|
} else if len(apps) > 0 {
|
||||||
if apps[0].Accepted != nil && *apps[0].Accepted {
|
if apps[0].Accepted != nil && *apps[0].Accepted {
|
||||||
return "Please join the server and then re-try this command", nil
|
return fmt.Sprintf("Please join the server at `%s` and then re-try this command", cmd.config.Register.URL), nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return "No player or applications found for that username", nil
|
return "No player or applications found for that username", nil
|
||||||
|
@ -82,16 +82,30 @@ func init() {
|
||||||
return "Your application was denied, good luck finding a new server", nil
|
return "Your application was denied, good luck finding a new server", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accepted
|
// Accepted, check for dupe user
|
||||||
|
guild, err := cmd.session.State.Guild(cmd.message.GuildID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
for _, member := range guild.Members {
|
||||||
|
nick := member.Nick
|
||||||
|
if nick == "" {
|
||||||
|
}
|
||||||
|
nick = member.User.Username
|
||||||
|
if strings.EqualFold(nickname, nick) {
|
||||||
|
return "A member with that name already exists in this Discord. Please contact staff.", nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil {
|
if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.RegisterRole); err != nil {
|
if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't return feedback because this goes in a different channel
|
// Don't return feedback because this goes in a different channel
|
||||||
sendMessage(cmd.session, cmd.config.RegisteredChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false)
|
sendMessage(cmd.session, cmd.config.Register.WelcomeChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false)
|
||||||
return "", nil
|
return "", nil
|
||||||
},
|
},
|
||||||
help: "Register yourself with the Discord",
|
help: "Register yourself with the Discord",
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/database"
|
"git.canopymc.net/Etzelia/canopeas/database"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -5,9 +5,9 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/database"
|
"git.canopymc.net/Etzelia/canopeas/database"
|
||||||
|
|
||||||
"git.birbmc.com/Etzelia/go-serverapi"
|
"git.canopymc.net/Etzelia/go-serverapi"
|
||||||
"go.jolheiser.com/beaver"
|
"go.jolheiser.com/beaver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
10
go.mod
10
go.mod
|
@ -1,12 +1,12 @@
|
||||||
module git.birbmc.com/canopeas
|
module git.canopymc.net/Etzelia/canopeas
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088
|
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451
|
||||||
git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685
|
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0
|
||||||
git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c
|
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304
|
||||||
git.birbmc.com/Etzelia/inspiro v0.0.2
|
git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f
|
||||||
gitea.com/jolheiser/gojang v0.0.7
|
gitea.com/jolheiser/gojang v0.0.7
|
||||||
gitea.com/jolheiser/xkcd v0.0.2
|
gitea.com/jolheiser/xkcd v0.0.2
|
||||||
github.com/bwmarrin/discordgo v0.22.0
|
github.com/bwmarrin/discordgo v0.22.0
|
||||||
|
|
16
go.sum
16
go.sum
|
@ -1,11 +1,11 @@
|
||||||
git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088 h1:M4ZyccJQrio2jZEehRTGDs4LQ8FXx8BF+ng346B1cvY=
|
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 h1:EbxWDS7sOyxv8einE7ps8WsywvlFqyKp3vdvk4PYVw4=
|
||||||
git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088/go.mod h1:BWmpXhZF6Cl/gCGGt0IhJpjnAWjcMBdU+m4nnBEQUk0=
|
git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451/go.mod h1:bgGHtcoYFmNIFgcU4P2LwqANZsJxoygnLI0C6OWE/U4=
|
||||||
git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685 h1:IWiRA9U58aBa2ZW2v7cjDymaxWqr+8DVcskzo4hAU2k=
|
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0 h1:UrwR0Ap4sjoRDfbi/ow76OeBAR9pI+BFKMYU6Jj9EtU=
|
||||||
git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685/go.mod h1:JXB7oUc0CS0NwuFkYcHkzbYEBEMigLldn4VLvwFIhdk=
|
git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0/go.mod h1:M9yjY5mBSK5vGVPru7RG6K5bUfoRH7dTtyQ+MCuJ33g=
|
||||||
git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c h1:S/9aOOsBbE9rJDk43Vh4HOEgHmHxqehd8VMi5fGdHdM=
|
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 h1:gBzoEToJCO1nKbfhfzhGMgSWY6szwDbA8doVmPr3SIY=
|
||||||
git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c/go.mod h1:KH8M3zEZuJw9kNFVE+EOESZaMjSizQzSFiY8bqMd8FY=
|
git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304/go.mod h1:U0H8WgtAzR+L+65odnpUH1lT6z7ylcG6R9keOOTG+fk=
|
||||||
git.birbmc.com/Etzelia/inspiro v0.0.2 h1:/lNp4+RLfAvLGoq69cQ4enYjVNYBP7JzRmSxDvQtVWs=
|
git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f h1:CupD+6/4Vrx0fGDIFf+cu8ponr19or3bCzkPPQXmRJk=
|
||||||
git.birbmc.com/Etzelia/inspiro v0.0.2/go.mod h1:JT9Q/xy8U2Gl/89zfW4Wnag2F1kGm5r6m4QR984lVIg=
|
git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f/go.mod h1:7zYT6obYO7/a3v+gV+uNfNlWK1dJz6Mz7lY9FeRSGOU=
|
||||||
gitea.com/jolheiser/gojang v0.0.7 h1:Q4cG7QYiKQsJtUWgXXiolAH9DCLRoaQ4olaO9OV628U=
|
gitea.com/jolheiser/gojang v0.0.7 h1:Q4cG7QYiKQsJtUWgXXiolAH9DCLRoaQ4olaO9OV628U=
|
||||||
gitea.com/jolheiser/gojang v0.0.7/go.mod h1:r9kj2wv/21Da7VpWz+qmxLexH85o2BAM4NMxeYgQlcY=
|
gitea.com/jolheiser/gojang v0.0.7/go.mod h1:r9kj2wv/21Da7VpWz+qmxLexH85o2BAM4NMxeYgQlcY=
|
||||||
gitea.com/jolheiser/xkcd v0.0.2 h1:HJP83YwSKxSYcoNfpb1ZpAfBvkUAnN+YgeukraXtfrc=
|
gitea.com/jolheiser/xkcd v0.0.2 h1:HJP83YwSKxSYcoNfpb1ZpAfBvkUAnN+YgeukraXtfrc=
|
||||||
|
|
6
main.go
6
main.go
|
@ -6,9 +6,9 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"git.birbmc.com/canopeas/config"
|
"git.canopymc.net/Etzelia/canopeas/config"
|
||||||
"git.birbmc.com/canopeas/database"
|
"git.canopymc.net/Etzelia/canopeas/database"
|
||||||
"git.birbmc.com/canopeas/discord"
|
"git.canopymc.net/Etzelia/canopeas/discord"
|
||||||
|
|
||||||
"go.jolheiser.com/beaver"
|
"go.jolheiser.com/beaver"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue