mirror of
				https://github.com/ergochat/ergo.git
				synced 2025-10-31 05:47:22 +01:00 
			
		
		
		
	add UNINVITE command (#1171)
This commit is contained in:
		
							parent
							
								
									42d246b557
								
							
						
					
					
						commit
						4b1e6b04c4
					
				| @ -1524,6 +1524,22 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // Uninvite rescinds a channel invitation, if the inviter can do so. | ||||
| func (channel *Channel) Uninvite(invitee *Client, inviter *Client, rb *ResponseBuffer) { | ||||
| 	if !channel.flags.HasMode(modes.InviteOnly) { | ||||
| 		rb.Add(nil, channel.server.name, "FAIL", "UNINVITE", "NOT_INVITE_ONLY", channel.Name(), inviter.t("Channel is not invite-only")) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if !channel.ClientIsAtLeast(inviter, modes.ChannelOperator) { | ||||
| 		rb.Add(nil, channel.server.name, "FAIL", "UNINVITE", "NOT_PRIVED", channel.Name(), inviter.t("You're not a channel operator")) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	invitee.Uninvite(channel.NameCasefolded()) | ||||
| 	rb.Add(nil, channel.server.name, "UNINVITE", invitee.Nick(), channel.Name()) | ||||
| } | ||||
| 
 | ||||
| // returns who the client can "see" in the channel, respecting the auditorium mode | ||||
| func (channel *Channel) auditoriumFriends(client *Client) (friends []*Client) { | ||||
| 	channel.stateMutex.RLock() | ||||
|  | ||||
| @ -1787,6 +1787,12 @@ func (client *Client) Invite(casefoldedChannel string, channelCreatedAt time.Tim | ||||
| 	return | ||||
| } | ||||
| 
 | ||||
| func (client *Client) Uninvite(casefoldedChannel string) { | ||||
| 	client.stateMutex.Lock() | ||||
| 	defer client.stateMutex.Unlock() | ||||
| 	delete(client.invitedTo, casefoldedChannel) | ||||
| } | ||||
| 
 | ||||
| // Checks that the client was invited to join a given channel | ||||
| func (client *Client) CheckInvited(casefoldedChannel string, createdTime time.Time) (invited bool) { | ||||
| 	config := client.server.Config() | ||||
|  | ||||
| @ -324,6 +324,10 @@ func init() { | ||||
| 			minParams: 1, | ||||
| 			oper:      true, | ||||
| 		}, | ||||
| 		"UNINVITE": { | ||||
| 			handler:   inviteHandler, | ||||
| 			minParams: 2, | ||||
| 		}, | ||||
| 		"UNKLINE": { | ||||
| 			handler:   unKLineHandler, | ||||
| 			minParams: 1, | ||||
|  | ||||
| @ -1113,7 +1113,9 @@ func infoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Resp | ||||
| } | ||||
| 
 | ||||
| // INVITE <nickname> <channel> | ||||
| // UNINVITE <nickname> <channel> | ||||
| func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { | ||||
| 	invite := msg.Command == "INVITE" | ||||
| 	nickname := msg.Params[0] | ||||
| 	channelName := msg.Params[1] | ||||
| 
 | ||||
| @ -1129,7 +1131,12 @@ func inviteHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re | ||||
| 		return false | ||||
| 	} | ||||
| 
 | ||||
| 	channel.Invite(target, client, rb) | ||||
| 	if invite { | ||||
| 		channel.Invite(target, client, rb) | ||||
| 	} else { | ||||
| 		channel.Uninvite(target, client, rb) | ||||
| 	} | ||||
| 
 | ||||
| 	return false | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -541,6 +541,11 @@ For example: | ||||
| 
 | ||||
| Used in connection registration, sets your username and realname to the given | ||||
| values (though your username may also be looked up with Ident).`, | ||||
| 	}, | ||||
| 	"uninvite": { | ||||
| 		text: `UNINVITE <nickname> <channel> | ||||
| 
 | ||||
| UNINVITE rescinds a channel invitation sent for an invite-only channel.`, | ||||
| 	}, | ||||
| 	"users": { | ||||
| 		text: `USERS [parameters] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Shivaram Lingamneni
						Shivaram Lingamneni