forked from RickvanLoo/discord-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.go
34 lines (27 loc) · 820 Bytes
/
events.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
package main
import (
"strings"
"github.com/Rivalo/discordgo_cli"
)
// This function will be called (due to AddHandler above) every time a new
// message is created on any channel that the autenticated user has access to.
func newMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
//Global Mentions
Mention := "@" + State.Session.User.Username
if strings.Contains(m.ContentWithMentionsReplaced(), Mention) {
go Notify(m.Message)
}
// Do nothing when State is disabled
if !State.Enabled {
return
}
//State Messages
if m.ChannelID == State.Channel.ID {
State.AddMessage(m.Message)
Messages := ReceivingMessageParser(m.Message)
for _, Msg := range Messages {
MessagePrint(m.Timestamp, m.Author.Username, Msg)
//log.Printf("> %s > %s\n", UserName(m.Author.Username), Msg)
}
}
}