~kris/9p

disco

ref: 05c7953a3bb9c5b2a21cfc8f3cf24f54224b7644 disco/events.go -rw-r--r-- 972 bytes
05c7953a — Sean Hinchee Cleaning up v1.0 9 years ago
                                                                                
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
package main

import (
	"strings"

	"bitbucket.org/henesy/disco/DiscordGo"
)

func removeReaction(s *discordgo.Session, r *discordgo.ReactionRemove) {

}

func newReaction(s *discordgo.Session, m *discordgo.ReactionAdd) {
}

// 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)
		}
	}
}