コード例 #1
0
ファイル: spam_module.go プロジェクト: blackhole12/sweetiebot
func KillSpammer(u *discordgo.User, info *GuildInfo, msg *discordgo.Message, reason string) {
	info.log.Log("Killing spammer ", u.Username, ". Last message sent: \n", msg.ContentWithMentionsReplaced())
	if SBatoi(msg.ChannelID) == info.config.WelcomeChannel {
		BanMember(u, info)
		info.SendMessage(SBitoa(info.config.ModChannel), "Alert: <@"+u.ID+"> was banned for "+reason+" in the welcome channel.")
		return
	}
	SilenceMember(u.ID, info)

	if info.config.MaxSpamRemoveLookback > 0 {
		if sb.IsDBGuild(info) {
			messages := sb.db.GetRecentMessages(SBatoi(u.ID), uint64(info.config.MaxSpamRemoveLookback), SBatoi(info.Guild.ID)) // Retrieve all messages in the past X seconds and delete them.

			for _, v := range messages {
				sb.dg.ChannelMessageDelete(SBitoa(v.channel), SBitoa(v.message))
			}
		}
	} else if info.config.MaxSpamRemoveLookback == 0 {
		sb.dg.ChannelMessageDelete(msg.ChannelID, msg.ID)
	} // otherwise we don't delete anything

	info.SendMessage(SBitoa(info.config.ModChannel), "Alert: <@"+u.ID+"> was silenced for "+reason+". Please investigate.") // Alert admins
}
コード例 #2
0
ファイル: patbot.go プロジェクト: Luukdegram/patbot
// This function will be called (due to above assignment) every time a new
// message is created on any channel that the autenticated user has access to.
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
	message := discordgo.Message{}
	message.Attachments = m.Attachments
	message.Author = m.Author
	message.ChannelID = m.ChannelID
	message.Content = m.Content
	message.EditedTimestamp = m.EditedTimestamp
	message.Embeds = m.Embeds
	message.ID = m.ID
	message.MentionEveryone = m.MentionEveryone
	message.Mentions = m.Mentions
	message.Timestamp = m.Timestamp
	message.Tts = m.Tts
	commandHandler.receiveChannel <- &message
}