-
Notifications
You must be signed in to change notification settings - Fork 2
/
subdayNew.go
54 lines (48 loc) · 1.56 KB
/
subdayNew.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package commandHandlers
import (
"log"
"strings"
"time"
"github.com/khades/servbot/ircClient"
"github.com/khades/servbot/models"
"github.com/khades/servbot/repos"
)
func SubdayNew(online bool, chatMessage *models.ChatMessage, chatCommand models.ChatCommand, ircClient *ircClient.IrcClient) {
if chatMessage.IsMod == false {
ircClient.SendPublic(&models.OutgoingMessage{
Channel: chatMessage.Channel,
Body: "Создание сабдня: Вы не модер SMOrc",
User: chatMessage.User})
return
}
_, subdayError := repos.GetLastActiveSubday(&chatMessage.ChannelID)
if subdayError == nil {
log.Println(subdayError)
ircClient.SendPublic(&models.OutgoingMessage{
Channel: chatMessage.Channel,
Body: "Сабдей уже существует",
User: chatMessage.User})
return
}
subsOnly := true
subdayName := strings.TrimSpace(strings.Replace(chatCommand.Body, "allowNonSubs=true", "", 1))
if strings.Contains(chatCommand.Body, "allowNonSubs=true") {
subsOnly = false
}
if subdayName == "" {
subdayName = "Сабдей, созданный " + time.Now().Format(time.UnixDate)
}
created := repos.CreateNewSubday(&chatMessage.ChannelID, subsOnly, &subdayName)
if created == true {
ircClient.SendPublic(&models.OutgoingMessage{
Channel: chatMessage.Channel,
Body: "Сабдей создан! VoHiYo",
User: chatMessage.User})
return
}
ircClient.SendPublic(&models.OutgoingMessage{
Channel: chatMessage.Channel,
Body: "Что-то пошло не так etmSad",
User: chatMessage.User})
return
}