Exemple #1
0
func PrivacyFilterIrcmsg(message *irc.Message) *irc.Message {
	if message == nil {
		return nil
	}
	if message.Command == irc.PRIVMSG || message.Command == irc.NOTICE {
		message.Trailing = "<privacy filtered>"
	}
	if message.Command == irc.PASS {
		message.Params = []string{"<privacy filtered>"}
		message.Trailing = ""
	}
	return message
}
Exemple #2
0
func MessageHandler(s ircx.Sender, m *irc.Message) {
	msg := m.Trailing
	var command string
	if m.Params[0] == name {
		m.Params = []string{m.Name}
	}

	if strings.HasPrefix(strings.ToLower(msg), strings.ToLower(name)) {
		pieces := strings.Split(msg, " ")
		if len(pieces) >= 2 {
			command = pieces[1]
			runCommand(command, pieces, msg, s, m)
			return
		}
	} else if strings.HasPrefix(msg, prefix) {
		pieces := strings.Split(msg, " ")
		if len(pieces) >= 1 {
			command = pieces[0][1:]
			runCommand(command, pieces, msg, s, m)
			return
		}
	} else if strings.HasPrefix(msg, "\x01VERSION") {
		log.Println(ctcp.VersionReply())
		s.Send(&irc.Message{
			Command:  irc.PRIVMSG,
			Params:   m.Params,
			Trailing: ctcp.VersionReply(),
		})
		return
	} else {
		for k := range replies {
			if ok := k.FindAllString(msg, 1); ok != nil {
				s.Send(&irc.Message{
					Command:  irc.PRIVMSG,
					Params:   m.Params,
					Trailing: replies[k],
				})
				return
			}
		}
	}
}
func (net *netImpl) rawHandler(evt *msg.Message) {
	// libmauirc adds the trailing text as a param, remove it.
	evt.Params = evt.Params[:len(evt.Params)-1]
	net.Owner.SendMessage(messages.Container{Type: messages.MsgRaw, Object: messages.RawMessage{Network: net.GetName(), Message: evt.String()}})
}