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


Golang Context.Privmsg方法代码示例

本文整理汇总了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)
	}
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:25,代码来源:handlers.go

示例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
		}
	}()
}
开发者ID:fluffle,项目名称:sp0rkle,代码行数:26,代码来源:reminddriver.go

示例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 :-(")
	}
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:22,代码来源:commands.go

示例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))
}
开发者ID:gundalow,项目名称:sp0rkle,代码行数:32,代码来源:pushbullet.go


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