degesch: allow specifying server in /disconnect
This commit is contained in:
		
							
								
								
									
										20
									
								
								degesch.c
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								degesch.c
									
									
									
									
									
								
							@@ -6536,10 +6536,10 @@ handle_command_connect (struct app_context *ctx, char *arguments)
 | 
				
			|||||||
	struct server *s = NULL;
 | 
						struct server *s = NULL;
 | 
				
			||||||
	if (*arguments)
 | 
						if (*arguments)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		char *name = cut_word (&arguments);
 | 
							char *server_name = cut_word (&arguments);
 | 
				
			||||||
		if (!(s = str_map_find (&ctx->servers, name)))
 | 
							if (!(s = str_map_find (&ctx->servers, server_name)))
 | 
				
			||||||
			buffer_send_error (ctx, ctx->global_buffer,
 | 
								buffer_send_error (ctx, ctx->global_buffer, "%s: %s: %s",
 | 
				
			||||||
				"%s: %s: %s", "Can't connect", "no such server", name);
 | 
									"Can't connect", "no such server", server_name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else if (ctx->current_buffer->type == BUFFER_GLOBAL)
 | 
						else if (ctx->current_buffer->type == BUFFER_GLOBAL)
 | 
				
			||||||
		buffer_send_error (ctx, ctx->current_buffer,
 | 
							buffer_send_error (ctx, ctx->current_buffer,
 | 
				
			||||||
@@ -6567,9 +6567,15 @@ handle_command_connect (struct app_context *ctx, char *arguments)
 | 
				
			|||||||
static bool
 | 
					static bool
 | 
				
			||||||
handle_command_disconnect (struct app_context *ctx, char *arguments)
 | 
					handle_command_disconnect (struct app_context *ctx, char *arguments)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// TODO: take server name from the first argument, if any
 | 
					 | 
				
			||||||
	struct server *s = NULL;
 | 
						struct server *s = NULL;
 | 
				
			||||||
	if (ctx->current_buffer->type == BUFFER_GLOBAL)
 | 
						if (*arguments)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							char *server_name = cut_word (&arguments);
 | 
				
			||||||
 | 
							if (!(s = str_map_find (&ctx->servers, server_name)))
 | 
				
			||||||
 | 
								buffer_send_error (ctx, ctx->current_buffer, "%s: %s: %s",
 | 
				
			||||||
 | 
									"Can't disconnect", "no such server", server_name);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (ctx->current_buffer->type == BUFFER_GLOBAL)
 | 
				
			||||||
		buffer_send_error (ctx, ctx->current_buffer,
 | 
							buffer_send_error (ctx, ctx->current_buffer,
 | 
				
			||||||
			"%s: %s", "Can't disconnect", "this buffer is global");
 | 
								"%s: %s", "Can't disconnect", "this buffer is global");
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
@@ -6827,7 +6833,7 @@ g_command_handlers[] =
 | 
				
			|||||||
	  "[<server>]",
 | 
						  "[<server>]",
 | 
				
			||||||
	  handle_command_connect },
 | 
						  handle_command_connect },
 | 
				
			||||||
	{ "disconnect", "Disconnect from the server",
 | 
						{ "disconnect", "Disconnect from the server",
 | 
				
			||||||
	  "[<reason>]",
 | 
						  "[<server> [<reason>]]",
 | 
				
			||||||
	  handle_command_disconnect },
 | 
						  handle_command_disconnect },
 | 
				
			||||||
	{ "list",       "List channels and their topic",
 | 
						{ "list",       "List channels and their topic",
 | 
				
			||||||
	  "[<channel>[,<channel>...]] [<target>]",
 | 
						  "[<channel>[,<channel>...]] [<target>]",
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user