本文整理汇总了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
}
示例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
}
示例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
}
示例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
}