~kris/9p

disco

ref: 1f273b8ee7d44d4aaffa382444ccc1c58a77f8ec disco/events.go -rw-r--r-- 987 bytes
1f273b8e — Sean Hinchee partially fix pm's ;; fix @'s ;; fix emoji printing ;; add :u ;; 7 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"

	"github.com/bwmarrin/discordgo"
)

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

}

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

// 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(string(m.Timestamp), m.Author.Username, Msg)
			//log.Printf("> %s > %s\n", UserName(m.Author.Username), Msg)
		}
	}
}