Beispiel #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)
}
Beispiel #2
0
// 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)
}
Beispiel #3
0
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)
}
Beispiel #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")
}