Changed old way to send discord message to the new one
This commit is contained in:
parent
a527849514
commit
1805fa64ea
4 changed files with 21 additions and 24 deletions
|
@ -1,5 +1,13 @@
|
||||||
# Changelog
|
# 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
|
## 3.0.0 - 2019-05-10
|
||||||
### Changed
|
### Changed
|
||||||
- Redesigned application with modular structure based on uber fx
|
- Redesigned application with modular structure based on uber fx
|
|
@ -2,7 +2,6 @@ package discord
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
|
@ -53,10 +52,7 @@ func (h *HandlerProcessor) Process(s *discordgo.Session, m *discordgo.MessageCre
|
||||||
|
|
||||||
if strings.HasPrefix(m.Content, "!galched") {
|
if strings.HasPrefix(m.Content, "!galched") {
|
||||||
LogMessage(m)
|
LogMessage(m)
|
||||||
_, err := s.ChannelMessageSend(m.ChannelID, h.HelpMessage())
|
SendMessage(s, m, h.HelpMessage())
|
||||||
if err != nil {
|
|
||||||
log.Printf("discord: cannot send message [%s]: %v", h.HelpMessage(), err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range h.handlers {
|
for i := range h.handlers {
|
||||||
|
|
|
@ -58,10 +58,7 @@ func (h *SubdayListHandler) Handle(s *discordgo.Session, m *discordgo.MessageCre
|
||||||
message += fmt.Sprintf(" **- %s** от _%s_\n", game, nickname)
|
message += fmt.Sprintf(" **- %s** от _%s_\n", game, nickname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err = s.ChannelMessageSend(m.ChannelID, strings.Trim(message, "\n"))
|
SendMessage(s, m, strings.Trim(message, "\n"))
|
||||||
if err != nil {
|
|
||||||
log.Printf("discord: cannot send message [%s]: %v", message, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubdayAddHandler struct {
|
type SubdayAddHandler struct {
|
||||||
|
|
|
@ -3,14 +3,12 @@ package settings
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "3.0.0"
|
version = "3.0.1"
|
||||||
discordTokenPath = "./tokens/.discordtoken"
|
discordTokenPath = "./tokens/.discordtoken"
|
||||||
subdayDataPath = "./backups/subday"
|
subdayDataPath = "./backups/subday"
|
||||||
subdayDataDuration = 10 // in seconds
|
|
||||||
|
|
||||||
// Permitted roles in discord for subday
|
// Permitted roles in discord for subday
|
||||||
subRole1 = "433672344737677322"
|
subRole1 = "433672344737677322"
|
||||||
|
@ -24,7 +22,6 @@ type (
|
||||||
Version string
|
Version string
|
||||||
DiscordToken string
|
DiscordToken string
|
||||||
SubdayDataPath string
|
SubdayDataPath string
|
||||||
SubdayJobDuration time.Duration
|
|
||||||
PermittedRoles []string
|
PermittedRoles []string
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -39,7 +36,6 @@ func New() (*Settings, error) {
|
||||||
Version: version,
|
Version: version,
|
||||||
DiscordToken: string(discordToken),
|
DiscordToken: string(discordToken),
|
||||||
SubdayDataPath: subdayDataPath,
|
SubdayDataPath: subdayDataPath,
|
||||||
SubdayJobDuration: subdayDataDuration * time.Second,
|
|
||||||
PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole},
|
PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue