本文整理匯總了Golang中github.com/fluffle/goirc/client.Line.Copy方法的典型用法代碼示例。如果您正苦於以下問題:Golang Line.Copy方法的具體用法?Golang Line.Copy怎麽用?Golang Line.Copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goirc/client.Line
的用法示例。
在下文中一共展示了Line.Copy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleRegexp
func (self *Module) handleRegexp(eventMode Event, trigger string, line *irc.Line) {
self.reMut.RLock()
defer self.reMut.RUnlock()
for _, reM := range self.reTriggers[eventMode] {
if reM.trigger.MatchString(trigger) {
go reM.fn(line.Copy())
}
}
}
示例2: handleString
func (self *Module) handleString(eventMode Event, trigger string, line *irc.Line) {
trigger = strings.ToLower(trigger)
evT := eventTrigger{eventMode, trigger}
self.stMut.RLock()
defer self.stMut.RUnlock()
for _, fn := range self.stTriggers[evT] {
go fn(line.Copy())
}
}
示例3: context
func context(conn *client.Conn, line *client.Line) *Context {
ctx := &Context{conn: conn, Line: line.Copy(), rws: bot.rewriters}
// This is a bit of a dirty hack; context() returns nil to ignore a line.
// TODO(fluffle): Ignores based on masks (or more likely regex).
if ctx.Nick != "" && conf.Ns(ignoreNs).String(strings.ToLower(ctx.Nick)) != "" {
return nil
}
if ctx.Cmd != client.PRIVMSG {
return ctx
}
ctx.Args[1], ctx.Addressed = util.RemovePrefixedNick(
strings.TrimSpace(ctx.Args[1]), ctx.Me())
// If we're being talked to in private, line.Args[0] will contain our Nick.
// We should consider this as "addressing" us, and set Addressed = true
if ctx.Args[0] == ctx.Me() {
ctx.Addressed = true
}
return ctx
}
示例4: transformLine
func transformLine(line *client.Line) *base.Line {
// We want line.Args[1] to contain the (possibly) stripped version of itself
// but modifying the pointer will result in other goroutines seeing the
// change, so we need to copy line for our own edification.
nl := &base.Line{Line: line.Copy()}
if nl.Cmd != "PRIVMSG" {
return nl
}
nl.Args[1], nl.Addressed = util.RemovePrefixedNick(
strings.TrimSpace(line.Args[1]), irc.Me.Nick)
// If we're being talked to in private, line.Args[0] will contain our Nick.
// To ensure the replies go to the right place (without performing this
// check everywhere) test for this and set line.Args[0] == line.Nick.
// We should consider this as "addressing" us too, and set Addressed = true
if nl.Args[0] == irc.Me.Nick {
nl.Args[0] = nl.Nick
nl.Addressed = true
}
return nl
}
示例5: bot_privmsg
// Do some standard processing on incoming lines and dispatch a bot_privmsg
func bot_privmsg(irc *client.Conn, line *client.Line) {
bot := getState(irc)
l, p := util.RemovePrefixedNick(strings.TrimSpace(line.Args[1]), irc.Me.Nick)
// We want line.Args[1] to contain the (possibly) stripped version of itself
// but modifying the pointer will result in other goroutines seeing the
// change, so we need to copy line for our own edification.
nl := &base.Line{Line: *line.Copy()}
nl.Args[1] = l
nl.Addressed = p
// If we're being talked to in private, line.Args[0] will contain our Nick.
// To ensure the replies go to the right place (without performing this
// check everywhere) test for this and set line.Args[0] == line.Nick.
// We should consider this as "addressing" us too, and set Addressed = true
if nl.Args[0] == irc.Me.Nick {
nl.Args[0] = nl.Nick
nl.Addressed = true
}
bot.Dispatch("bot_privmsg", nl)
}