本文整理匯總了Golang中github.com/fluffle/goirc/client.Conn.Mode方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Mode方法的具體用法?Golang Conn.Mode怎麽用?Golang Conn.Mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goirc/client.Conn
的用法示例。
在下文中一共展示了Conn.Mode方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: unban
func unban(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "oh")
if channel == "" || args == "" {
return
}
ch := conn.GetChannel(channel)
if ch == nil {
say(conn, target, "%s: Unable to get channel information about %s", nick.Nick, channel)
return
}
bans := strings.TrimSpace(args)
split := strings.Fields(bans)
for i, ban := range split {
if strings.Index(ban, "@") != -1 {
// it's already a host, do nothing
continue
}
if b, ok := ch.Bans[ban]; ok {
// we've seen this nick banned before
split[i] = b
} else if n := conn.GetNick(ban); n != nil {
// the user is in one of our channels, here's our best guess
split[i] = "*!*@" + n.Host
}
}
bans = strings.Join(split, " ")
modestring := "-" + strings.Repeat("b", len(bans)) + " " + bans
conn.Mode(channel, modestring)
}
示例2: ban
func ban(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "oh")
if channel == "" || args == "" {
return
}
bans := strings.TrimSpace(args)
split := strings.Fields(bans)
// turn nicks into *!*@host
for i, ban := range split {
if strings.Index(ban, "@") != -1 {
// already a host
continue
}
n := conn.GetNick(ban)
if n == nil {
//couldn't find the nick, so just cross our fingers
continue
}
split[i] = "*!*@" + n.Host
}
bans = strings.Join(split, " ")
modestring := "+" + strings.Repeat("b", len(bans)) + " " + bans
conn.Mode(channel, modestring)
}
示例3: 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
}
}
示例4: devoice
func devoice(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "v")
if channel == "" {
return
}
if args == "" {
conn.Mode(channel, "-v "+nick.Nick)
} else {
voices := strings.TrimSpace(args)
count := strings.Count(voices, " ") + 1
modestring := "-" + strings.Repeat("v", count) + " " + voices
conn.Mode(channel, modestring)
}
}
示例5: op
func op(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "o")
if channel == "" {
return
}
if args == "" {
conn.Mode(channel, "+o "+nick.Nick)
} else {
ops := strings.TrimSpace(args)
count := strings.Count(ops, " ") + 1
modestring := "+" + strings.Repeat("o", count) + " " + ops
conn.Mode(channel, modestring)
}
}
示例6: dehalfop
func dehalfop(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "oh")
if channel == "" {
return
}
if args == "" {
conn.Mode(channel, "-h "+nick.Nick)
} else {
if !hasAccess(conn, nick, channel, "o") {
return
}
halfops := strings.TrimSpace(args)
count := strings.Count(halfops, " ") + 1
modestring := "-" + strings.Repeat("h", count) + " " + halfops
conn.Mode(channel, modestring)
}
}
示例7: kickban
func kickban(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "oh")
if channel == "" || args == "" {
return
}
split := strings.SplitN(args, " ", 2)
n := conn.GetNick(split[0])
if n == nil || (split[0] != nick.Nick &&
(!hasAccess(conn, nick, channel, "o") && hasAccess(conn, n, channel, "oh"))) {
return
}
conn.Mode(channel, "+b *!*@"+n.Host)
reason := "(" + nick.Nick + ")"
if len(split) == 2 {
reason += " " + split[1]
}
conn.Kick(channel, split[0], reason)
}
示例8: BanManager
func BanManager(conn *irc.Conn) {
for {
time.Sleep(60000000000)
c, err := config.ReadDefault("bans.list")
if err != nil {
panic(fmt.Sprintf("Config error: %s", err))
}
if !c.HasOption("timed", "count") {
continue
}
count, err := c.Int("timed", "count")
if err != nil || count == 0 {
continue
}
banlist := make([]string, count)
for i := 0; i < count; i++ {
squid := strconv.Itoa(count - i)
banlist[i], _ = c.String("timed", squid)
}
for e := count; e > 0; e-- {
split := strings.SplitN(banlist[e-1], " ", 3)
expiry, _ := strconv.Atoi64(split[2])
if expiry <= time.Seconds() {
c, _ = config.ReadDefault("bans.list")
host, _ := c.String("#"+split[0], split[1]+".host")
conn.Mode("#"+split[0], "-b "+host)
banLogDel("#"+split[0], split[1])
c.RemoveOption("timed", strconv.Itoa(count))
count -= 1
c.AddOption("timed", "count", strconv.Itoa(count))
c.AddOption("#"+split[0], split[1]+".status", "EXPIRED")
c.RemoveOption("#"+split[0], split[1]+".timer")
c.WriteFile("bans.list", 0644, "Ban List")
}
}
}
}
示例9: handleJoin
func handleJoin(conn *irc.Conn, line *irc.Line) {
// autovoice users with v flag
if line.Nick == conn.Me.Nick {
return
}
channel := conn.GetChannel(line.Args[0])
if channel == nil || !channel.Modes.Moderated {
return
}
privs := conn.Me.Channels[channel]
if !(privs.Op || privs.Admin || privs.HalfOp || privs.Owner) {
return
}
nick := conn.GetNick(line.Nick)
if nick == nil {
return
}
if hasAccess(conn, nick, line.Nick, "v") {
conn.Mode(line.Args[0], "+v "+line.Nick)
}
}
示例10: tempban
func tempban(conn *irc.Conn, nick *irc.Nick, args, target string) {
channel, args := parseAccess(conn, nick, target, args, "oh")
if channel == "" || args == "" {
return
}
ch := conn.GetChannel(channel)
if ch == nil {
say(conn, target, "%s: Unable to get channel information about %s", nick.Nick, channel)
return
}
args = strings.TrimSpace(args)
split := strings.SplitN(args, " ", 3)
dur, err := strconv.Atoi64(split[1])
if dur < 5 {
dur = 5
split[1] = "5"
}
if err != nil {
say(conn, channel, "Format: !tb <nick> <minutes> <reason>")
return
}
n := conn.GetNick(split[0])
if n == nil || (split[0] != nick.Nick &&
(!hasAccess(conn, nick, channel, "o") && hasAccess(conn, n, channel, "oh"))) {
return
}
conn.Mode(channel, "+b *!*@"+n.Host)
reason := "(" + nick.Nick + ")"
if len(split) == 3 {
reason += " " + split[2]
}
reason += " (" + split[1] + " min.)"
conn.Kick(channel, split[0], reason)
expiry := time.Seconds() + dur*60
banLogAdd("*!*@"+n.Host, split[0], reason, channel, expiry)
}