コード例 #1
0
ファイル: handler.go プロジェクト: Skullever/digo
func messageDelete(s *discordgo.Session, chanID string, mID string) {
	c := config.Get()
	if !c.KeepTriggers {
		s.ChannelMessageDelete(chanID, mID)
	}
}
コード例 #2
0
ファイル: main.go プロジェクト: Xwth/h-bot
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
	var deleteMessageAuthor bool
	deleteMessageAuthor = true

	text := m.ContentWithMentionsReplaced()

	if m.Author.ID == s.State.User.ID {
		// Ignore self
		return
	}

	channel, _ := s.State.Channel(m.ChannelID)

	if channel.IsPrivate {
		channel.Name = "direct message"
	}

	if strings.HasPrefix(text, "!") || strings.HasPrefix(text, ".") || strings.HasPrefix(text, "bot.") {
		// Ignore shit meant for other bots
		return
	}

	isMentioned := isUserMentioned(s.State.User, m.Mentions) || m.MentionEveryone

	text = strings.Replace(text, "@everyone", "", -1)

	// Log cleaned up message
	fmt.Printf("%20s %20s %20s > %s\n", channel.Name, time.Now().Format(time.Stamp), m.Author.Username, text)

	if shouldIgnore(m.Author) {
		return
	}

	c := config.Get()

	for _, ChannelID := range c.Channels {
		if m.ChannelID == ChannelID {
			linksFound, reply := lewd.ParseLinks(text)

			if linksFound {
				content := strings.Join(lewd.ContentLinks(m.Content)[:], " ")
				if deleteMessageAuthor {
					s.ChannelMessageDelete(m.ChannelID, m.ID)
				}
				s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%s: %s\n%s", m.Author.Username, content, reply))
				return
			}
		}
	}

	// Accept the legacy mention as well and trim it off from text
	if strings.HasPrefix(strings.ToLower(text), "lewdbot, ") {
		text = text[9:]
		isMentioned = true
	}

	if channel.IsPrivate || isMentioned {
		var reply string
		reply = regex.Lewdbot.ReplaceAllString(reply, m.Author.Username)

		// Log our reply
		fmt.Printf("%20s %20s %20s > %s\n", channel.Name, time.Now().Format(time.Stamp), s.State.User.Username, reply)

		s.ChannelMessageSend(m.ChannelID, reply)
	}
}
コード例 #3
0
ファイル: basic_bot.go プロジェクト: Muckfoot/Go
func checkLink(s *discordgo.Session, m string, chanID string, mID string) {
	if strings.Contains(strings.ToLower(m), "www.facebook") {
		s.ChannelMessageDelete(chanID, mID)
	}
}