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


Golang Channel.Name方法代码示例

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


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

示例1: cmdOkick

func cmdOkick(source interface{}, params [][]byte) {
	c := source.(*client.Client)

	var ch *core.Channel
	var target *core.User

	channame := string(params[0])
	if channame[0] == '#' {
		channame = channame[1:]
	}
	if ch = core.FindChannel("", channame); ch == nil {
		return
	}

	if target = core.GetUserByNick(string(params[1])); target == nil {
		return
	}

	perm, err := perm.CheckRemovePerm("", c.User(), target, ch)
	if perm < -1000000 {
		c.SendLineTo(nil, "482", "#%s :%s", ch.Name(), err)
		return
	}

	var message string
	if len(params) > 2 {
		message = string(params[2])
	}
	ch.Remove(nil, nil, target, message)
}
开发者ID:jbeshir,项目名称:OddComm,代码行数:30,代码来源:okick.go

示例2: cmdWho

func cmdWho(source interface{}, params [][]byte) {
	c := source.(*Client)
	channame := string(params[0])
	if channame[0] == '#' {
		channame = channame[1:]
	}

	var ch *core.Channel
	if ch = core.FindChannel("", channame); ch == nil {
		c.SendLineTo(nil, "403", "#%s :No such channel.", channame)
		return
	}

	// If the user isn't on the channel, don't let them check unless they
	// can view private channel data.
	if m := ch.GetMember(c.u); m == nil {
		if ok, err := perm.CheckChanViewData(me, c.u, ch, "members"); !ok {
			c.SendLineTo(nil, "482", "#%s :%s", ch.Name(), err)
			return
		}
	}

	it := ch.Users()
	c.WriteBlock(func() []byte {
		if it == nil {
			return nil
		}

		user := it.User()

		var prefixes string
		if user.Data("away") == "" {
			prefixes += "H"
		} else {
			prefixes += "G"
		}
		if user.Data("op") != "" {
			prefixes += "*"
		}
		prefixes += ChanModes.GetPrefixes(it)

		servername := core.Global.Data("name")
		result := fmt.Sprintf(":%s 352 %s #%s %s %s %s %s %s :0 %s\r\n",
			servername, c.u.Nick(), channame, user.GetIdent(),
			user.GetHostname(), servername, user.Nick(),
			prefixes, user.Data("realname"))

		it = it.ChanNext()
		return []byte(result)
	})

	c.SendLineTo(nil, "315", "%s :End of /WHO list.", params[0])
}
开发者ID:jbeshir,项目名称:OddComm,代码行数:53,代码来源:infocmds.go

示例3: cmdNames

func cmdNames(source interface{}, params [][]byte) {
	c := source.(*Client)
	channame := string(params[0])
	if len(channame) > 0 && channame[0] == '#' {
		channame = channame[1:]
	}

	var ch *core.Channel
	if ch = core.FindChannel("", channame); ch == nil {
		c.SendLineTo(nil, "403", "#%s :No such channel.", channame)
		return
	}

	// If the user isn't on the channel, don't let them check unless they
	// can view private channel data.
	// Otherwise, get their prefixes.
	var myprefix string
	if m := ch.GetMember(c.u); m == nil {
		if ok, err := perm.CheckChanViewData(me, c.u, ch, "members"); !ok {
			c.SendLineTo(nil, "482", "#%s :%s", ch.Name(), err)
			return
		}
		myprefix = "="
	} else {
		myprefix = ChanModes.GetPrefixes(m)
	}

	it := ch.Users()
	c.WriteBlock(func() []byte {
		if it == nil {
			return nil
		}

		names := fmt.Sprintf(":%s 353 %s %s #%s :",
			core.Global.Data("name"), c.u.Nick(), myprefix,
			channame)

		for ; it != nil; it = it.ChanNext() {
			name := ChanModes.GetPrefixes(it) + it.User().Nick()
			if len(names)+len(name) > 508 {
				break
			}
			names += " " + name
		}

		names += "\r\n"
		return []byte(names)
	})

	c.SendLineTo(nil, "366", "#%s :End of /NAMES list", channame)
}
开发者ID:jbeshir,项目名称:OddComm,代码行数:51,代码来源:infocmds.go

示例4: cmdOpflags

func cmdOpflags(source interface{}, params [][]byte) {
	c := source.(*Client)
	channame := string(params[0])
	if channame[0] == '#' {
		channame = channame[1:]
	}

	var ch *core.Channel
	if ch = core.FindChannel("", channame); ch == nil {
		c.SendLineTo(nil, "403", "#%s :No such channel.", channame)
		return
	}

	// If the user isn't on the channel, don't let them check unless they
	// can view private channel data.
	if m := ch.GetMember(c.u); m == nil {
		if ok, err := perm.CheckChanViewData(me, c.u, ch, "members"); !ok {
			c.SendLineTo(nil, "482", "#%s :%s", ch.Name(), err)
			return
		}
	}

	var target *core.User
	if target = core.GetUserByNick(string(params[1])); target == nil {
		c.SendLineTo(nil, "401", "%s :No such user.", params[1])
		return
	}

	var m *core.Membership
	if m = ch.GetMember(target); m == nil {
		c.SendLineTo(nil, "304", ":OPFLAGS #%s: %s is not in the channel.", ch.Name(), target.Nick())
		return
	}
	if ok, err := perm.CheckMemberViewData(me, c.u, m, "op"); !ok {
		c.SendLineTo(nil, "482", "#%s :%s: %s", ch.Name(), target.Nick(), err)
		return
	}

	var flags string
	if flags = m.Data("op"); flags == "" {
		c.SendLineTo(nil, "304", ":OPFLAGS #%s: %s has no channel op flags.", ch.Name(), target.Nick())
		return
	}

	if flags == "on" {
		flags = perm.DefaultChanOp()
	}
	c.SendLineTo(nil, "304", ":OPFLAGS #%s: %s has channel op flags: %s", ch.Name(), target.Nick(), flags)
}
开发者ID:jbeshir,项目名称:OddComm,代码行数:49,代码来源:infocmds.go


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