本文整理匯總了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)
}
示例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
}
示例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.")
}
}
示例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)
}
}
}()
}
示例5: channelSay
func channelSay(conn *irc.Conn, channel string, text string) {
if debug {
fmt.Printf("Channel Say fired:\n")
}
conn.Privmsg(channel, text)
}
示例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)
}
示例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)
}
}
示例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)
}
示例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()
}
示例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
}
}
示例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)], " "))
}
示例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)
}
}
示例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)
}
示例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?!")
}
}
}
示例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)
}
}