當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Conn.Privmsg方法代碼示例

本文整理匯總了Golang中github.com/fluffle/goirc/client.Conn.Privmsg方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Privmsg方法的具體用法?Golang Conn.Privmsg怎麽用?Golang Conn.Privmsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/fluffle/goirc/client.Conn的用法示例。


在下文中一共展示了Conn.Privmsg方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ItsAlive

func ItsAlive(conn *irc.Conn, line *irc.Line) {
	if line.Args[0] != conn.Me().Nick {
		// no private query, ignore
		return
	}

	msg := line.Args[1]
	if !strings.HasPrefix(msg, "msg ") {
		//~ log.Printf("unknown prefix for: %s", msg)
		// only accept valid commands
		return
	}

	if line.Nick != frankconf.Master {
		// only answer to master
		log.Printf("only answering to master %s, but was %s", frankconf.Master, line.Nick)
		return
	}

	cmd := strings.SplitN(msg, " ", 3)
	channel := cmd[1]
	msg = cmd[2]

	log.Printf("master command: posting “%s” to %s", msg, channel)
	conn.Privmsg(channel, msg)

}
開發者ID:breunigs,項目名稱:frank,代碼行數:27,代碼來源:itsalive.go

示例2: QueryNick

func (m *NickMap) QueryNick(irc *client.Conn, target, asker, nick string) {
	r := ""
	if user, ok := m.GetUser(nick); ok {
		if asker == nick {
			if user == "" {
				r = fmt.Sprintf("%s: you asked to be ignored by last.fm commands", asker)
			} else {
				r = fmt.Sprintf("%s: your ", asker)
			}
		} else {
			if user == "" {
				r = fmt.Sprintf("%s: %s has asked to be ignored by last.fm commands", asker, nick)
			} else {
				r = fmt.Sprintf("%s: %s's ", asker, nick)
			}
		}
		if user != "" {
			r += fmt.Sprintf("last.fm username is %s (http://last.fm/user/%s)", user, user)
		}
	} else {
		if asker == nick {
			r = fmt.Sprintf("%s: you ", asker)
		} else {
			r = fmt.Sprintf("%s: %s ", asker, nick)
		}
		r += fmt.Sprintf("didn't associate an username")
	}
	irc.Privmsg(target, r)
	return
}
開發者ID:nbyouri,項目名稱:go-lastfm-bot,代碼行數:30,代碼來源:nick_map.go

示例3: RaumBang

func RaumBang(conn *irc.Conn, line *irc.Line) {
	defer func() {
		if r := recover(); r != nil {
			log.Printf("MEGA-WTF:pkg: %v", r)
		}
	}()

	tgt := line.Args[0]
	msg := line.Args[1]

	if tgt != bangRaumChannel || !bangRaumRegex.MatchString(msg) {
		return
	}

	dur := time.Since(bangRaumLast)

	if dur.Seconds() <= 10 {
		log.Printf("WTF: last room stat request was %v seconds ago, skipping", dur)
		return
	}

	log.Printf("Received room stat request from %s\n", line.Nick)
	bangRaumLast = time.Now()

	err := exec.Command("ping", "-q", "-l 3", "-c 3", "-w 1", hostToPing).Run()
	if err != nil {
		conn.Privmsg(tgt, "Raumstatus: Die Weltnetzanfrage wurde nicht erwidert.")
	} else {
		conn.Privmsg(tgt, "Raumstatus: Ein Gerät innerhalb des Raumes beantwortet Weltnetzanfragen.")
	}
}
開發者ID:breunigs,項目名稱:frank,代碼行數:31,代碼來源:raumbang.go

示例4: Tail

func Tail(conn *irc.Conn, channel, filename string, fn func(string) bool) {
	AutoJoin(conn, channel)
	f, err := os.Open(filename, 0, 0)
	if err != nil {
		log.Println(err)
		return
	}
	_, err = f.Seek(0, 2)
	if err != nil {
		log.Println(err)
		return
	}
	b := bufio.NewReader(f)
	go func() {
		for {
			l, err := b.ReadBytes('\n')
			if err != nil {
				if err == os.EOF {
					time.Sleep(1e9)
					b = bufio.NewReader(f)
					continue
				}
				log.Println(err)
				break
			}
			s := string(l[:len(l)-1])
			if fn(s) {
				conn.Privmsg(channel, s)
			}
		}
	}()
}
開發者ID:broady,項目名稱:gobby,代碼行數:32,代碼來源:tail.go

示例5: channelSay

func channelSay(conn *irc.Conn, channel string, text string) {
	if debug {
		fmt.Printf("Channel Say fired:\n")
	}

	conn.Privmsg(channel, text)
}
開發者ID:antiartificial,項目名稱:allbot,代碼行數:7,代碼來源:allbot2.go

示例6: postTitle

func postTitle(conn *irc.Conn, line *irc.Line, title string, prefix string) {
	tgt := line.Args[0]

	secondsAgo := cacheGetSecondsToLastPost(title)
	if secondsAgo <= noRepostWithinSeconds {
		log.Printf("Skipping, because posted %d seconds ago (“%s”)", secondsAgo, title)
		return
	}

	if frankconf.Verbose {
		log.Printf("Title was last posted: %#v (“%s”)", secondsAgo, title)
	}

	log.Printf("nick=%s, target=%s, title=%s", line.Nick, tgt, title)
	// if target is our current nick, it was a private message.
	// Answer the users in this case.
	if tgt == conn.Me().Nick {
		tgt = line.Nick
	}
	if prefix == "" {
		prefix = "Link Info"
	} else {
		prefix = clean(prefix)
	}
	title = clean(title)
	// the IRC spec states that notice should be used instead of msg
	// and that bots should not react to notice at all. However, no
	// real world bot adheres to this. Furthermore, people who can’t
	// configure their client to not highlight them on notices will
	// complain.
	conn.Privmsg(tgt, "["+prefix+"] "+title)
}
開發者ID:breunigs,項目名稱:frank,代碼行數:32,代碼來源:urifind.go

示例7: SendMessage

func SendMessage(conn *irc.Conn, msg string, handler UrlHandler) {
	if &handler != nil {
		conn.Privmsg(RC.Channel, fmt.Sprintf("[%s] %s", handler.Name(), msg))
	} else {
		conn.Privmsg(RC.Channel, msg)
	}
}
開發者ID:cneill,項目名稱:rusty-robot,代碼行數:7,代碼來源:utils.go

示例8: connected

func connected(conn *irc.Conn, line *irc.Line) {
	println("Connected!")
	conn.Pass(config.Password)
	conn.Join(config.Channel)
	conn.Privmsg(config.Channel, "¡Saludos!")
	constantlyReadTwitter(conn)
}
開發者ID:sadasant,項目名稱:Go,代碼行數:7,代碼來源:VEbot.go

示例9: markov

// This is what generates the actual markov chain
func markov(channel string, conn *irc.Conn) {
	markovData.mutex.RLock()
	var markovchain string
	messageLength := random(50) + 10
	for i := 0; i < messageLength; i++ {
		splitchain := strings.Split(markovchain, " ")
		if len(splitchain) < 2 {
			s := []rune(markovData.keys[random(len(markovData.keys))])
			s[0] = unicode.ToUpper(s[0])
			markovchain = string(s)
			continue
		}
		chainlength := len(splitchain)
		searchfor := strings.ToLower(splitchain[chainlength-2] + " " + splitchain[chainlength-1])
		if len(markovData.bigmap[searchfor]) == 0 || strings.LastIndex(markovchain, ".") < len(markovchain)-50 {
			s := []rune(markovData.keys[random(len(markovData.keys))])
			s[0] = unicode.ToUpper(s[0])
			markovchain = markovchain + ". " + string(s)
			continue
		}
		randnext := random(len(markovData.bigmap[searchfor]))
		markovchain = markovchain + " " + markovData.bigmap[searchfor][randnext]
	}
	conn.Privmsg(channel, markovchain+".")
	markovData.mutex.RUnlock()
}
開發者ID:kravlin,項目名稱:sadbot,代碼行數:27,代碼來源:markov.go

示例10: eventPrivmsg

// Called when incoming privmsg
// channel boolean evaluates true for channel privmsgs, false for bot privmsgs
func eventPrivmsg(conn *irc.Conn, line *irc.Line, channel bool) {
	if debug {
		fmt.Printf("Event PrivMSG fired: [%s] [%b]\n", line, channel)

	}

	// Determine what type of privmsg it is (channel||to bot)
	if channel {
		if debug {
			fmt.Printf("Line args: [%s]\n", line.Args[1])
		}

		var lastLine = strings.Split(line.Args[1], " ")

		if lastLine[0] == strings.ToLower("!say") {
			triggerSay(conn, lastLine, line.Args[0]) // why can't we pass line.Args?
		}

		if lastLine[0] == strings.ToLower("!ll") {
			var temp = findNickLastLine("testfile.txt", lastLine[1])
			fmt.Println("line:" + temp)
			conn.Privmsg(line.Args[0], temp)
		}

		// Silence Bot
		if lastLine[0] == strings.ToLower("!muzzle") {
			if muzzle == false {
				muzzle = true
				channelSay(conn, line.Args[0], "Muzzle enabled")
			} else {
				muzzle = false
				channelSay(conn, line.Args[0], "Muzzle disabled")
			}
			fmt.Printf("Muzzle set to: [%s]\n", muzzle)
		}

		if lastLine[0] == strings.ToLower("!op") {
			if line.Nick != botName && line.Nick == "arti" {
				//TODO do op
				conn.Mode(line.Args[0], "+o") // do we need to add a key arg?
			}
			//TODO do unauthorized message?
		}

		/*select {
		case strings.ToLower("!say"):
			triggerSay(conn, lastLine, line.Args[0]) // why can't we pass line.Args?
			fallthrough
		default:
			fmt.Println("No match.")
		}*/
	} else {
		// PrivMSG is to bot.
		if debug {
			fmt.Printf("Line args: [%s]\n", line.Args[1])
		}
		//TODO bot privmsg handling
	}
}
開發者ID:antiartificial,項目名稱:allbot,代碼行數:61,代碼來源:allbot2.go

示例11: triggerSay

func triggerSay(conn *irc.Conn, lastLine []string, channel string) {
	if debug {
		fmt.Printf("Trigger Say fired: [%s]\n", lastLine)
	}

	//TODO ponder if sanity checking is better per function or @higher level
	conn.Privmsg(channel, strings.Join(lastLine[1:len(lastLine)], " "))
}
開發者ID:antiartificial,項目名稱:allbot,代碼行數:8,代碼來源:allbot2.go

示例12: saySomething

func saySomething(conn *irc.Conn, channel string, ns *nonsentence.Nonsentence) {
	sentence, err := ns.Make()
	if err != nil {
		log.Printf("Error while making sentence: %v", err)
	} else {
		conn.Privmsg(channel, sentence)
	}
}
開發者ID:GEPWNAGE,項目名稱:Pipo,代碼行數:8,代碼來源:main.go

示例13: printMetadataForKey

func printMetadataForKey(c *irc.Conn, channel string, key string) {
	r, _, _ := http.Get("http://gdata.youtube.com/feeds/api/videos/" + key)
	if r.StatusCode != http.StatusOK {
		return
	}
	var m Video = Video{xml.Name{}, ""}
	xml.Unmarshal(r.Body, &m)
	c.Privmsg(channel, "  -> "+m.Title)
}
開發者ID:broady,項目名稱:gobby,代碼行數:9,代碼來源:youtuber.go

示例14: respond

func respond(conn *irc.Conn, line *irc.Line) {
	if strings.EqualFold(line.Args[0], "#candlepin") {
		msg := strings.ToLower(line.Args[1])
		if strings.Contains(msg, "over 9000") ||
			strings.Contains(msg, "over nine thousand") {
			conn.Privmsg("#candlepin", "WHAT?! NINE THOUSAND?!")
		}

	}
}
開發者ID:jbowes,項目名稱:slugbot,代碼行數:10,代碼來源:nappa.go

示例15: respond

func (m *Privmsg) respond(includeToNick bool, conn *irc.Conn, format string, args ...interface{}) {
	msg := fmt.Sprintf(format, args...)
	if m.Public() {
		if includeToNick {
			msg = fmt.Sprintf("%s: %s", m.Nick, msg)
		}
		conn.Privmsg(m.Channel, msg)
	} else {
		conn.Privmsg(m.Nick, msg)
	}
}
開發者ID:nemith,項目名稱:mipples,代碼行數:11,代碼來源:irc.go


注:本文中的github.com/fluffle/goirc/client.Conn.Privmsg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。