From 22d0e095e3a92052fc1c0d68f009d074c7c04b5f Mon Sep 17 00:00:00 2001 From: alexvanin Date: Sat, 1 Jun 2019 00:07:12 +0300 Subject: [PATCH] Added new subhistory command in subday handler --- changelog.md | 5 +++++ modules/discord/handlers.go | 1 + modules/discord/subdayhandlers.go | 29 ++++++++++++++++++++++++----- modules/settings/settings.go | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 368fc5d..4d4538d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # Changelog +## 3.0.2 - 2019-05-31 +### Added +- Command !subhistory +- Info about 5th short subday + ## 3.0.1 - 2019-05-10 ### Added - Readme file diff --git a/modules/discord/handlers.go b/modules/discord/handlers.go index 37b2dde..05a241c 100644 --- a/modules/discord/handlers.go +++ b/modules/discord/handlers.go @@ -53,6 +53,7 @@ func (h *HandlerProcessor) Process(s *discordgo.Session, m *discordgo.MessageCre if strings.HasPrefix(m.Content, "!galched") { LogMessage(m) SendMessage(s, m, h.HelpMessage()) + return } for i := range h.handlers { diff --git a/modules/discord/subdayhandlers.go b/modules/discord/subdayhandlers.go index 91329da..d5a239c 100644 --- a/modules/discord/subdayhandlers.go +++ b/modules/discord/subdayhandlers.go @@ -38,10 +38,7 @@ func (h *SubdayListHandler) Handle(s *discordgo.Session, m *discordgo.MessageCre log.Print("discord: cannot obtain guild", err) return } - message := "Игры предыдущих сабдеев:\n**20.10.18**: _DmC_ -> _Fable 1_ -> _Overcooked 2_\n" + - "**17.11.18**: _The Witcher_ -> _Xenus: Белое Золото_ -> _NFS: Underground 2_\n" + - "**22.12.18**: _True Crime: Streets of LA_ -> _Serious Sam 3_ -> _Kholat_\n" + - "**26.01.19**: _Disney’s Aladdin_ -> _~~Gothic~~_ -> _Scrapland_ -> _Donut County_\n\n" + + message := "Игры предыдущих сабдеев доступны по команде **!subhistory**\n" + "Список игр для следующего сабдея:\n" for k, v := range h.subday.Database() { nickname := " " @@ -138,10 +135,32 @@ loop: } } +type SubdayHistoryHandler struct{} + +func (h *SubdayHistoryHandler) Signature() string { + return "!subhistory" +} +func (h *SubdayHistoryHandler) Description() string { + return "история прошлых сабдеев" +} +func (h *SubdayHistoryHandler) IsValid(msg string) bool { + return strings.HasPrefix(msg, "!subhistory") +} +func (h *SubdayHistoryHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) { + LogMessage(m) + message := "Игры предыдущих сабдеев:\n**20.10.18**: _DmC_ -> _Fable 1_ -> _Overcooked 2_\n" + + "**17.11.18**: _The Witcher_ -> _Xenus: Белое Золото_ -> _NFS: Underground 2_\n" + + "**22.12.18**: _True Crime: Streets of LA_ -> _Serious Sam 3_ -> _Kholat_\n" + + "**26.01.19**: _Disney’s Aladdin_ -> _~~Gothic~~_ -> _Scrapland_ -> _Donut County_\n" + + "**24.02.19**: _Tetris 99_ -> _~~Bully~~_ -> _~~GTA: Vice City~~_" + SendMessage(s, m, message) +} + func SubdayHandlers(s *subday.Subday, r []string) []MessageHandler { var result []MessageHandler addHandler := &SubdayAddHandler{s, r} listHandler := &SubdayListHandler{s} - return append(result, addHandler, listHandler) + histHandler := new(SubdayHistoryHandler) + return append(result, addHandler, listHandler, histHandler) } diff --git a/modules/settings/settings.go b/modules/settings/settings.go index 6a3c9af..a30095b 100644 --- a/modules/settings/settings.go +++ b/modules/settings/settings.go @@ -6,7 +6,7 @@ import ( ) const ( - version = "3.0.1" + version = "3.0.2" discordTokenPath = "./tokens/.discordtoken" subdayDataPath = "./backups/subday"