当前位置: 首页>>代码示例>>Golang>>正文


Golang Message.Trailing方法代码示例

本文整理汇总了Golang中github.com/sorcix/irc.Message.Trailing方法的典型用法代码示例。如果您正苦于以下问题:Golang Message.Trailing方法的具体用法?Golang Message.Trailing怎么用?Golang Message.Trailing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/sorcix/irc.Message的用法示例。


在下文中一共展示了Message.Trailing方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: PrivacyFilterIrcmsg

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
}
开发者ID:aftran,项目名称:robustirc,代码行数:13,代码来源:util.go

示例2: CmdPing

// CmdPing is a handler for the /PING command.
func CmdPing(s Server, u *User, msg *irc.Message) error {
	if len(msg.Params) > 0 {
		msg.Trailing = msg.Params[0]
	}
	s.EncodeMessage(u, irc.PONG, []string{s.Name()}, msg.Trailing)
	return nil
}
开发者ID:42wim,项目名称:mm-go-irckit,代码行数:8,代码来源:server_commands.go

示例3: CmdPrivMsg

// CmdPrivMsg is a handler for the /PRIVMSG command.
func CmdPrivMsg(s Server, u *User, msg *irc.Message) error {
	var err error
	if len(msg.Params) > 1 {
		tr := strings.Join(msg.Params[1:], " ")
		msg.Trailing = msg.Trailing + tr
	}
	// empty message
	if msg.Trailing == "" {
		return nil
	}
	query := msg.Params[0]
	if ch, exists := s.HasChannel(query); exists {
		//p := strings.Replace(query, "#", "", -1)
		msg.Trailing = strings.Replace(msg.Trailing, "\r", "", -1)
		// fix non-rfc clients
		if !strings.HasPrefix(msg.Trailing, ":") {
			if len(msg.Params) == 2 {
				msg.Trailing = msg.Params[1]
			}
		}
		// CTCP ACTION (/me)
		if strings.HasPrefix(msg.Trailing, "\x01ACTION ") {
			msg.Trailing = strings.Replace(msg.Trailing, "\x01ACTION ", "", -1)
			msg.Trailing = "*" + msg.Trailing + "*"
		}
		msg.Trailing += " ​"
		post := &model.Post{ChannelId: ch.ID(), Message: msg.Trailing}
		_, err := u.mc.Client.CreatePost(post)
		if err != nil {
			u.MsgSpoofUser("mattermost", "msg: "+msg.Trailing+" could not be send: "+err.Error())
		}
	} else if toUser, exists := s.HasUser(query); exists {
		if query == "mattermost" {
			go u.handleMMServiceBot(toUser, msg.Trailing)
			return nil
		}
		if toUser.MmGhostUser {
			u.mc.SendDirectMessage(toUser.User, msg.Trailing)
			return nil
		}
		err = s.EncodeMessage(u, irc.PRIVMSG, []string{toUser.Nick}, msg.Trailing)
	} else {
		err = s.EncodeMessage(u, irc.ERR_NOSUCHNICK, msg.Params, "No such nick/channel")
	}
	return err
}
开发者ID:42wim,项目名称:mm-go-irckit,代码行数:47,代码来源:server_commands.go

示例4: HandlePirvMsg

func (h *HandlerFuncs) HandlePirvMsg(m *irc.Message) (err error) {

	// Print Private messagess
	log.Printf("%s: %s %s %s\n", h.Name, m.Command, m.Prefix.Name, m.Trailing)

	// Check for portal reference
	if val, ok := responses.Portal[m.Trailing]; ok {

		err = h.ClientConn.PrivMsg(m.Params[0], val)
		if err != nil {

			log.Printf("ircutil.PrivMsg(): %s\n", err)
			return
		}

		return
	}

	// Check for DDG query
	if strings.HasPrefix(m.Trailing, "!ddg") {

		m.Trailing = strings.TrimPrefix(m.Trailing, "!ddg")
		if m.Trailing == "" {

			err = h.ClientConn.PrivMsg(m.Params[0], fmt.Sprintf("%s: %s", m.Prefix.Name, "No Query Specified"))
			if err != nil {

				log.Printf("ircutil.PrivMsg(): %s\n", err)
				return err
			}
			return
		}

		q := &ddg.Client{

			Dial:   h.Dial,
			NoHTML: true,
		}
		_, text, err := q.FeelingLucky(m.Trailing)
		if err != nil {

			log.Printf("ddg.FeelingLucky(): %s\n", err)
		}
		if len(text) < 1 {

			text = "No Results"
		}

		err = h.ClientConn.PrivMsg(m.Params[0], fmt.Sprintf("%s: %s", m.Prefix.Name, text))
		if err != nil {

			log.Printf("ircutil.PrivMsg(): %s\n", err)
			return err
		}
	}

	// Check if message contains URL
	if crawler.IsURL(m.Trailing) {

		if strings.HasPrefix(m.Trailing, "dontcrawl") {

			return
		}

		c := &crawler.Client{
			Dial: h.Dial,
		}
		r, err := c.Crawl(crawler.ExtractUrl(m.Trailing))
		if err != nil {

			log.Printf("crawler.GetTitle(): %s\n", err)
			return nil
		}
		if len(r.Title) > 1 {

			err = h.ClientConn.PrivMsg(m.Params[0], fmt.Sprintf("^ %s", r.Title))
			if err != nil {

				log.Printf("ircutil.PrivMsg(): %s\n", err)
				return err
			}
		}
	}

	return
}
开发者ID:carriercomm,项目名称:HackBot,代码行数:86,代码来源:handlers.go


注:本文中的github.com/sorcix/irc.Message.Trailing方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。