本文整理匯總了Golang中github.com/fluffle/sp0rkle/bot.Context.Privmsg方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.Privmsg方法的具體用法?Golang Context.Privmsg怎麽用?Golang Context.Privmsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/sp0rkle/bot.Context
的用法示例。
在下文中一共展示了Context.Privmsg方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: tellCheck
func tellCheck(ctx *bot.Context) {
nick := ctx.Nick
if ctx.Cmd == client.NICK {
// We want the destination nick, not the source.
nick = ctx.Target()
}
r := rc.TellsFor(nick)
for i := range r {
if ctx.Cmd == client.NICK {
if r[i].Chan != "" {
ctx.Privmsg(string(r[i].Chan), nick+": "+r[i].Reply())
}
ctx.Reply("%s", r[i].Reply())
} else {
ctx.Privmsg(ctx.Nick, r[i].Reply())
if r[i].Chan != "" {
ctx.ReplyN("%s", r[i].Reply())
}
}
rc.RemoveId(r[i].Id)
}
if len(r) > 0 {
delete(listed, ctx.Nick)
}
}
示例2: Remind
func Remind(r *reminders.Reminder, ctx *bot.Context) {
delta := r.RemindAt.Sub(time.Now())
if delta < 0 {
return
}
c := make(chan struct{})
running[r.Id] = c
go func() {
select {
case <-time.After(delta):
ctx.Privmsg(string(r.Chan), r.Reply())
// TODO(fluffle): Tie this into state tracking properly.
ctx.Privmsg(string(r.Target), r.Reply())
// This is used in snooze to reinstate reminders.
finished[strings.ToLower(string(r.Target))] = r
if pc != nil {
if s := pc.GetByNick(string(r.Target)); s.CanPush() {
push.Push(s, "Reminder from sp0rkle!", r.Reply())
}
}
Forget(r.Id, false)
case <-c:
return
}
}()
}
示例3: literal
// Factoid literal: 'literal key' => info about factoid
func literal(ctx *bot.Context) {
key := ToKey(ctx.Text(), false)
if count := fc.GetCount(key); count == 0 {
ctx.ReplyN("I don't know anything about '%s'.", key)
return
} else if count > 10 && ctx.Public() {
ctx.ReplyN("I know too much about '%s', ask me privately.", key)
return
}
if facts := fc.GetAll(key); facts != nil {
for _, fact := range facts {
// Use Privmsg directly here so that the results aren't output
// via the plugin system and contain the literal data.
ctx.Privmsg(ctx.Target(), fmt.Sprintf(
"[%3.0f%%] %s", fact.Chance*100, fact.Value))
}
} else {
ctx.ReplyN("Something literally went wrong :-(")
}
}
示例4: pushEnable
// pushEnable generates a URL to start the OAuth dance for a nick.
// Once the user visits this URL and approves the access, they
// get redirected back to /oauth/auth, which is handled by
// authTokenRedirect below. There, we complete the OAuth dance
// and redirect to /oauth/devices (chooseDevice) which lists
// the user's devices and accepts a POST to choose a target
// device for push notifications. Once this is done, we push
// a confirmation notification to the chosen device with a 6
// digit pin and require that they msg that to us via IRC.
func pushEnable(ctx *bot.Context) {
if s := pc.GetByNick(ctx.Nick); s != nil {
if s.HasAlias(ctx.Nick) {
ctx.ReplyN("Your nick is already used as an alias for %s.", s.Nick)
return
}
if s.CanPush() {
ctx.ReplyN("Pushes already enabled.")
return
}
ctx.Privmsg(ctx.Nick, "Hmm. Deleting partially-complete state...")
pc.DelState(s)
}
s, err := pc.NewState(ctx.Nick)
if err != nil {
ctx.ReplyN("Error creating push state: %v", err)
return
}
// Privmsg the URL so randoms don't click it.
ctx.Privmsg(ctx.Nick, "Hi! Visit the following URL while logged into "+
"the account you want to use to push to your device.")
ctx.Privmsg(ctx.Nick, push.AuthCodeURL(s))
}