From 93014d944b8a0b4518ccf37eb97fc4ac330e82f7 Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 3 Jun 2018 10:40:28 +0200 Subject: [PATCH] split project into multiple files --- config.go | 40 ++++++++++++++++++++++++++++++++++++++++ config.json | 0 main.go | 38 ++++---------------------------------- types.go | 20 ++++++++++++++++++++ 4 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 config.go mode change 100755 => 100644 config.json mode change 100755 => 100644 main.go create mode 100644 types.go diff --git a/config.go b/config.go new file mode 100644 index 0000000..087b638 --- /dev/null +++ b/config.go @@ -0,0 +1,40 @@ +package main + +import ( + "os" + "encoding/json" +) + +type Embed struct { + Message string + QuestionsTitle string + QuestionsText string + BugsTitle string + BugsText string + Image string +} + +type Config struct { + AdminID string + ServerID string + LockedRoleID string + Token string + WelcomeChannel string + GeneralChannel string + SendWelcomeDM bool + RequireAccept bool + ComplaintReceivedMessage string + ModChannel string + WelcomeEmbed Embed + RoleCommands map[string]string +} + + +func readConfig() Config { + file, _ := os.Open("config.json") + conf := Config{} + json.NewDecoder(file).Decode(&conf) + file.Close() + return conf +} + diff --git a/config.json b/config.json old mode 100755 new mode 100644 diff --git a/main.go b/main.go old mode 100755 new mode 100644 index af84329..12d7a1b --- a/main.go +++ b/main.go @@ -2,51 +2,21 @@ package main import ( "fmt" - "encoding/json" "strings" - "os" "os/signal" + "os" "syscall" "regexp" "log" "github.com/bwmarrin/discordgo" ) -type Embed struct { - Message string - QuestionsTitle string - QuestionsText string - BugsTitle string - BugsText string - Image string -} - -type Config struct { - AdminID string - ServerID string - LockedRoleID string - Token string - WelcomeChannel string - GeneralChannel string - SendWelcomeDM bool - RequireAccept bool - ComplaintReceivedMessage string - ModChannel string - WelcomeEmbed Embed - RoleCommands map[string]string -} - var config = readConfig() - -func readConfig() Config { - file, _ := os.Open("config.json") - conf := Config{} - _ = json.NewDecoder(file).Decode(&conf) - file.Close() - return conf -} +var commands []Command +var t CommandType func main() { + fmt.Println(t) dg, err := discordgo.New("Bot " + config.Token) if err != nil { fmt.Println("error: ", err) diff --git a/types.go b/types.go new file mode 100644 index 0000000..9c0053a --- /dev/null +++ b/types.go @@ -0,0 +1,20 @@ +package main + +type CommandType int + +const ( + CommandTypePrefix CommandType = 0 + CommandTypeFullMatch CommandType = 1 + CommandTypeRegex CommandType = 2 +) + +type Command struct { + Input string + Output string + Type CommandType + OutputIsReply bool + DeleteInput bool + DMOnly bool +} + +