2019-06-28 09:37:37 +00:00
|
|
|
package discord
|
|
|
|
|
|
|
|
import (
|
2019-06-30 15:05:54 +00:00
|
|
|
dsmodel "dorisbot/models/discord"
|
2019-06-28 09:37:37 +00:00
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func messageCreateEvt(s *discordgo.Session, evt *discordgo.MessageCreate) {
|
2019-06-30 15:05:54 +00:00
|
|
|
// skip bot message
|
|
|
|
if evt.Author.ID == client.ID {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if len(evt.Content) == 0 {
|
|
|
|
return
|
|
|
|
}
|
2019-06-28 09:37:37 +00:00
|
|
|
guildID := evt.GuildID
|
|
|
|
channelID := evt.ChannelID
|
|
|
|
uid := evt.Author.ID
|
|
|
|
_ = channelID
|
|
|
|
_ = uid
|
|
|
|
|
2019-06-30 15:05:54 +00:00
|
|
|
server, err := dsmodel.GetDiscordServerByID(guildID)
|
2019-06-28 09:37:37 +00:00
|
|
|
if err != nil {
|
2019-06-30 15:05:54 +00:00
|
|
|
log.Println("get server err :: ", err)
|
2019-06-28 09:37:37 +00:00
|
|
|
return
|
|
|
|
}
|
2019-06-30 15:05:54 +00:00
|
|
|
|
|
|
|
cmd, keyword, payload := parseTextMessage(evt.Content)
|
|
|
|
|
|
|
|
_ = cmd
|
|
|
|
_ = payload
|
|
|
|
if !keyword && server == nil {
|
|
|
|
return
|
2019-06-28 09:37:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func guildMemberAddEvt(s *discordgo.Session, evt *discordgo.GuildMemberAdd) {}
|
|
|
|
|
|
|
|
func guildMemberRemoveEvt(s *discordgo.Session, evt *discordgo.GuildMemberRemove) {}
|
|
|
|
|
|
|
|
func rateLimitEvt(s *discordgo.Session, evt *discordgo.RateLimit) {}
|
|
|
|
|
|
|
|
func connectEvt(s *discordgo.Session, evt *discordgo.Connect) {
|
|
|
|
log.Println(":: Connect ::")
|
|
|
|
client.connected = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func disconnectEvt(s *discordgo.Session, evt *discordgo.Disconnect) {
|
|
|
|
log.Println(":: Disconnect ::")
|
|
|
|
client.connected = false
|
|
|
|
}
|