diff --git a/changelog.md b/changelog.md index cb2fbd2..368fc5d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # Changelog +## 3.0.1 - 2019-05-10 +### Added +- Readme file +### Removed +- Removed redundant setting parameter for subday database dumping duration +### Changed +- Changed way of sending messages to the discord channel + ## 3.0.0 - 2019-05-10 ### Changed - Redesigned application with modular structure based on uber fx \ No newline at end of file diff --git a/modules/discord/handlers.go b/modules/discord/handlers.go index a7d9234..37b2dde 100644 --- a/modules/discord/handlers.go +++ b/modules/discord/handlers.go @@ -2,7 +2,6 @@ package discord import ( "fmt" - "log" "strings" "github.com/bwmarrin/discordgo" @@ -53,10 +52,7 @@ func (h *HandlerProcessor) Process(s *discordgo.Session, m *discordgo.MessageCre if strings.HasPrefix(m.Content, "!galched") { LogMessage(m) - _, err := s.ChannelMessageSend(m.ChannelID, h.HelpMessage()) - if err != nil { - log.Printf("discord: cannot send message [%s]: %v", h.HelpMessage(), err) - } + SendMessage(s, m, h.HelpMessage()) } for i := range h.handlers { diff --git a/modules/discord/subdayhandlers.go b/modules/discord/subdayhandlers.go index c481f3e..91329da 100644 --- a/modules/discord/subdayhandlers.go +++ b/modules/discord/subdayhandlers.go @@ -58,10 +58,7 @@ func (h *SubdayListHandler) Handle(s *discordgo.Session, m *discordgo.MessageCre message += fmt.Sprintf(" **- %s** от _%s_\n", game, nickname) } } - _, err = s.ChannelMessageSend(m.ChannelID, strings.Trim(message, "\n")) - if err != nil { - log.Printf("discord: cannot send message [%s]: %v", message, err) - } + SendMessage(s, m, strings.Trim(message, "\n")) } type SubdayAddHandler struct { diff --git a/modules/settings/settings.go b/modules/settings/settings.go index 5b3e139..6a3c9af 100644 --- a/modules/settings/settings.go +++ b/modules/settings/settings.go @@ -3,14 +3,12 @@ package settings import ( "io/ioutil" "log" - "time" ) const ( - version = "3.0.0" - discordTokenPath = "./tokens/.discordtoken" - subdayDataPath = "./backups/subday" - subdayDataDuration = 10 // in seconds + version = "3.0.1" + discordTokenPath = "./tokens/.discordtoken" + subdayDataPath = "./backups/subday" // Permitted roles in discord for subday subRole1 = "433672344737677322" @@ -21,11 +19,10 @@ const ( type ( Settings struct { - Version string - DiscordToken string - SubdayDataPath string - SubdayJobDuration time.Duration - PermittedRoles []string + Version string + DiscordToken string + SubdayDataPath string + PermittedRoles []string } ) @@ -36,10 +33,9 @@ func New() (*Settings, error) { } return &Settings{ - Version: version, - DiscordToken: string(discordToken), - SubdayDataPath: subdayDataPath, - SubdayJobDuration: subdayDataDuration * time.Second, - PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole}, + Version: version, + DiscordToken: string(discordToken), + SubdayDataPath: subdayDataPath, + PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole}, }, nil }