make method reciever naming consistent
This commit is contained in:
parent
d7a400e7a6
commit
975d763cc1
38
state.go
38
state.go
@ -293,56 +293,56 @@ func (ch Channel) Admins(c *Client) []*User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// addUser adds a user to the users list.
|
// addUser adds a user to the users list.
|
||||||
func (c *Channel) addUser(nick string) {
|
func (ch *Channel) addUser(nick string) {
|
||||||
if c.UserIn(nick) {
|
if ch.UserIn(nick) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.UserList = append(c.UserList, ToRFC1459(nick))
|
ch.UserList = append(ch.UserList, ToRFC1459(nick))
|
||||||
sort.Strings(c.UserList)
|
sort.Strings(ch.UserList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteUser removes an existing user from the users list.
|
// deleteUser removes an existing user from the users list.
|
||||||
func (c *Channel) deleteUser(nick string) {
|
func (ch *Channel) deleteUser(nick string) {
|
||||||
nick = ToRFC1459(nick)
|
nick = ToRFC1459(nick)
|
||||||
|
|
||||||
j := -1
|
j := -1
|
||||||
for i := 0; i < len(c.UserList); i++ {
|
for i := 0; i < len(ch.UserList); i++ {
|
||||||
if c.UserList[i] == nick {
|
if ch.UserList[i] == nick {
|
||||||
j = i
|
j = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if j != -1 {
|
if j != -1 {
|
||||||
c.UserList = append(c.UserList[:j], c.UserList[j+1:]...)
|
ch.UserList = append(ch.UserList[:j], ch.UserList[j+1:]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy returns a deep copy of a given channel.
|
// Copy returns a deep copy of a given channel.
|
||||||
func (c *Channel) Copy() *Channel {
|
func (ch *Channel) Copy() *Channel {
|
||||||
nc := &Channel{}
|
nc := &Channel{}
|
||||||
*nc = *c
|
*nc = *ch
|
||||||
|
|
||||||
_ = copy(nc.UserList, c.UserList)
|
_ = copy(nc.UserList, ch.UserList)
|
||||||
|
|
||||||
// And modes.
|
// And modes.
|
||||||
nc.Modes = c.Modes.Copy()
|
nc.Modes = ch.Modes.Copy()
|
||||||
|
|
||||||
return nc
|
return nc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Len returns the count of users in a given channel.
|
// Len returns the count of users in a given channel.
|
||||||
func (c *Channel) Len() int {
|
func (ch *Channel) Len() int {
|
||||||
return len(c.UserList)
|
return len(ch.UserList)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserIn checks to see if a given user is in a channel.
|
// UserIn checks to see if a given user is in a channel.
|
||||||
func (c *Channel) UserIn(name string) bool {
|
func (ch *Channel) UserIn(name string) bool {
|
||||||
name = ToRFC1459(name)
|
name = ToRFC1459(name)
|
||||||
|
|
||||||
for i := 0; i < len(c.UserList); i++ {
|
for i := 0; i < len(ch.UserList); i++ {
|
||||||
if c.UserList[i] == name {
|
if ch.UserList[i] == name {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,8 +352,8 @@ func (c *Channel) UserIn(name string) bool {
|
|||||||
|
|
||||||
// Lifetime represents the amount of time that has passed since we have first
|
// Lifetime represents the amount of time that has passed since we have first
|
||||||
// joined the channel.
|
// joined the channel.
|
||||||
func (c *Channel) Lifetime() time.Duration {
|
func (ch *Channel) Lifetime() time.Duration {
|
||||||
return time.Since(c.Joined)
|
return time.Since(ch.Joined)
|
||||||
}
|
}
|
||||||
|
|
||||||
// createChannel creates the channel in state, if not already done.
|
// createChannel creates the channel in state, if not already done.
|
||||||
|
Loading…
Reference in New Issue
Block a user