예제 #1
0
// Update the prefix on a membership entry.
func (p *ModeParser) updatePrefix(m *core.Membership) {
	var prefix string
	for it := p.prefixes; it != nil; it = it.next {
		if m.Data(it.metadata) != "" {
			prefix += string(it.prefix)
		}
	}
	m.SetData("", nil, strconv.Uitoa64(p.id)+" prefixes", prefix)
}
예제 #2
0
파일: view.go 프로젝트: jbeshir/OddComm
// CheckMemberViewDataPerm returns the full permissions value for
// CheckMemberViewData.
func CheckMemberViewDataPerm(pkg string, u *core.User, m *core.Membership, name string) (int, os.Error) {
	f := func(h interface{}) (int, os.Error) {
		f, ok := h.(func(string, *core.User, *core.Membership, string) (int, os.Error))
		if ok && f != nil {
			return f(pkg, u, m, name)
		}
		return 0, nil
	}

	return runPermHooks(checkMemberViewData[m.Channel().Type()], f, false)
}
예제 #3
0
파일: infocmds.go 프로젝트: jbeshir/OddComm
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)
}
예제 #4
0
// GetPrefixes returns the prefixes for a membership entry.
func (p *ModeParser) GetPrefixes(m *core.Membership) string {
	return m.Data(strconv.Uitoa64(p.id) + " prefixes")
}