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


Golang Conn.Notice方法代码示例

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


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

示例1: reportIgnored

func reportIgnored(irc *client.Conn, asker, who string) {
	if asker == who {
		irc.Notice(asker, "You asked to be ignored by last.fm commands")
	} else {
		irc.Notice(asker, fmt.Sprintf("%s asked to be ignored by last.fm commands", who))
	}
}
开发者ID:nbyouri,项目名称:go-lastfm-bot,代码行数:7,代码来源:bot.go

示例2: sendHelp

func sendHelp(irc *client.Conn, nick string) {
	helpStr := `
	Last.fm commands:
	` + *cmdPrefix + `np ($user)?: Shows your now playing song. If you give $user, queries for that $user.
	` + *cmdPrefix + `compare ($user1) ($user2)?: Runs a tasteometer compare between you and $user1, or between $user1 and $user2 if present.
	` + *cmdPrefix + `top5 ((overall|year|month|week) ($user)?)?: Shows the top5 artists in the chosen period for you or the $user.
	` + *cmdPrefix + `whois ($nick)?: Shows your associated last.fm username, or the username associated with $nick.
	` + *cmdPrefix + `aka ($username): Shows the nicks that have been associated with $username.
	A nick can be used in place of a username if it's associated with a last.fm account.
	`
	if *requireAuth {
		helpStr += `Commands that require that you be authenticated with NickServ:`
	}
	// There's also *cmdPrefix + "wp", but we don't document it to not encourage abuse.
	helpStr += `
	` + *cmdPrefix + `ignore: Makes the bot ignore you for most commands. Use ` +
		*cmdPrefix + `setuser or ` + *cmdPrefix + `deluser to be unignored.
	` + *cmdPrefix + `setuser ($username): Associates your nick with the given last.fm $username.
	` + *cmdPrefix + `deluser: Removes your nick's association, if any.
	` // + *cmdPrefix + `wp: Shows what's playing for everyone in the channel.` // uncomment this at your peril :)
	for _, line := range helpSplit.Split(helpStr, -1) {
		if line != "" {
			irc.Notice(nick, line)
		}
	}
}
开发者ID:nbyouri,项目名称:go-lastfm-bot,代码行数:26,代码来源:bot.go

示例3: MessageHandler

func MessageHandler(conn *irc.Conn, line *irc.Line) {
	var googleRegexp = regexp.MustCompile(`\](.+?)\[`)

	if googleRegexp.MatchString(line.Args[1]) {
		for _, match := range googleRegexp.FindAllStringSubmatch(line.Args[1], -1) {
			conn.Notice(channel, match[1])
		}
	}
}
开发者ID:slackwalker,项目名称:gocognito,代码行数:9,代码来源:cognito.go

示例4: eventJoin

func eventJoin(conn *irc.Conn, line *irc.Line) {
	if debug {
		fmt.Printf("Event Join fired: [%s]\n", line)
	}

	if botName != line.Nick {
		conn.Notice(line.Src, line.Nick+", welcome")
	}
}
开发者ID:antiartificial,项目名称:allbot,代码行数:9,代码来源:allbot2.go

示例5: say

func say(conn *irc.Conn, target, message string, a ...interface{}) {
	if len(a) > 0 {
		message = fmt.Sprintf(message, a...)
	}
	text := strings.Replace(message, "\n", " ", -1)
	if isChannel(target) {
		conn.Privmsg(target, text)
	} else {
		conn.Notice(target, text)
	}
}
开发者ID:thevermi,项目名称:rbot,代码行数:11,代码来源:handler.go

示例6: plusplus

func plusplus(c *irc.Conn, line *irc.Line, nick string, plus int) {
	score := 0

	incr()
	lock1.Lock()

	defer func() {
		lock1.Unlock()
		<-time.After(1 * time.Second)
		decr()
		if ref == 0 {
			c.Notice(line.Args[0], fmt.Sprintf("%s (%d)", nick, score))
		}
	}()

	tx, err := db.Begin()
	if err != nil {
		fmt.Printf("Database error: %v\n", err)
		return
	}
	defer tx.Rollback()

	row, err := tx.Query(`select score from plusplus where nick = ?`, strings.ToLower(nick))
	if err != nil {
		fmt.Printf("Database error: %v\n", err)
		return
	}

	if row.Next() {
		err = row.Scan(&score)
		if err != nil {
			fmt.Printf("Database error: %v\n", err)
			row.Close()
			return
		}
	}
	score += plus
	row.Close()

	stmt, err := tx.Prepare(`insert or replace into plusplus (nick, score) values (?, ?)`)
	if err != nil {
		fmt.Printf("Database error: %v\n", err)
		return
	}
	defer stmt.Close()

	_, err = stmt.Exec(strings.ToLower(nick), score)
	if err != nil {
		fmt.Printf("Database error: %v\n", err)
		return
	}
	tx.Commit()
}
开发者ID:mattn,项目名称:go-plusplusbot,代码行数:53,代码来源:plusplusbot.go

示例7: onInvite

func onInvite(irc *client.Conn, line *client.Line) {
	who, channel := line.Args[0], line.Args[1]
	log.Println(line.Nick, "invited bot to", channel)
	if who == irc.Me.Nick {
		// some IRCds only allow operators to INVITE, and on registered channels normally only identified users are operators
		// check anyway, since there are some corner cases where that doesn't happen
		if checkIdentified(irc, line.Nick) {
			log.Println("Accepting invite to", channel)
			irc.Join(channel)
		} else {
			irc.Notice(line.Nick, "you must be identified to invite")
			log.Println("Ignoring invite, user is not identified")
		}
	}
}
开发者ID:nbyouri,项目名称:go-lastfm-bot,代码行数:15,代码来源:bot.go

示例8: ranking

func ranking(c *irc.Conn, line *irc.Line) {
	lock1.Lock()
	defer lock1.Unlock()

	rows, err := db.Query(`select nick, score from plusplus order by score desc`)
	if err != nil {
		fmt.Printf("Database error: %v\n", err)
		return
	}
	defer rows.Close()

	rank, nick, score := 1, "", 0
	for rows.Next() {
		rows.Scan(&nick, &score)
		c.Notice(line.Args[0], fmt.Sprintf("%03d: %s (%d)\n", rank, nick, score))
		rank++
		if rank > 5 {
			break
		}
	}
}
开发者ID:mattn,项目名称:go-plusplusbot,代码行数:21,代码来源:plusplusbot.go

示例9: bot_rebuild

func bot_rebuild(irc *client.Conn, line *client.Line) {
	bot := getState(irc)
	if bot.rbnick == "" || bot.rbnick != line.Nick {
		return
	}
	if !strings.HasPrefix(line.Args[1], "rebuild") {
		return
	}
	if bot.rbpw != "" && line.Args[1] != "rebuild "+bot.rbpw {
		return
	}

	// Ok, we should be good to rebuild now.
	irc.Notice(line.Nick, "Beginning rebuild")
	cmd := exec.Command("go", "get", "-u", "github.com/fluffle/sp0rkle/sp0rkle")
	out, err := cmd.CombinedOutput()
	if err != nil {
		irc.Notice(line.Nick, fmt.Sprintf("Rebuild failed: %s", err))
		for _, l := range strings.Split(string(out), "\n") {
			irc.Notice(line.Nick, l)
		}
		return
	}
	bot.quit = true
	bot.reexec = true
	bot.Conn.Quit("Restarting with new build.")
}
开发者ID:b33f,项目名称:sp0rkle,代码行数:27,代码来源:handlers.go

示例10: reportAllNowPlaying

func reportAllNowPlaying(irc *client.Conn, asker, channel string) {
	if !(strings.HasPrefix(channel, "#") || strings.HasPrefix(channel, "&")) {
		log.Println("User", asker, "asked What's Playing...... via PM")
		irc.Privmsg(channel, fmt.Sprintf("%s: this only works on channels", asker))
		return
	}
	log.Println("User", asker, "requested What's Playing on channel", channel)

	if !checkIdentified(irc, asker) {
		r := fmt.Sprintf("%s: you must be identified with NickServ to use this command", asker)
		log.Println(r)
		irc.Privmsg(channel, r)
		return
	}

	if _, ok := whoChannel[channel]; ok {
		log.Println("Channel", channel, "is already executing a What's Playing request")
		return
	}

	whoChannel[channel] = make(chan bool, 1)

	go irc.Who(channel)
	for _ = range whoChannel[channel] { // wait until channel is closed
	}
	delete(whoChannel, channel)

	reportChan := make(chan bool)
	totalReport := len(whoResult[channel]) - 1
	msg := fmt.Sprintf("Reporting now playing for %d nicks in channel %s", totalReport, channel)
	log.Println(msg)
	irc.Notice(asker, msg)

	for _, nick := range whoResult[channel] {
		if nick != irc.Me().Nick {
			n := nick
			go func() {
				rateLimit <- true
				reportChan <- reportNowPlaying(irc, channel, asker, n, true)
				<-rateLimit
			}()
		}
	}
	delete(whoResult, channel)

	okCount, totalCount := 0, 0
	for r := range reportChan {
		if r {
			okCount++
		}
		if totalCount++; totalCount == totalReport {
			break
		}
	}
	close(reportChan)

	msg = fmt.Sprintf("Reported for %d of %d nicks", okCount, totalCount)
	log.Println(msg)
	irc.Notice(asker, msg)

	return
}
开发者ID:Kovensky,项目名称:go-lastfm-bot,代码行数:62,代码来源:all.go


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