degesch: fix /query
This commit is contained in:
parent
20c36b4b36
commit
15032f9ce7
43
degesch.c
43
degesch.c
@ -1299,6 +1299,27 @@ irc_make_user (struct app_context *ctx, char *nickname)
|
||||
return user;
|
||||
}
|
||||
|
||||
static struct buffer *
|
||||
irc_get_user_buffer (struct app_context *ctx, const char *nickname)
|
||||
{
|
||||
struct buffer *buffer = str_map_find (&ctx->irc_buffer_map, nickname);
|
||||
if (buffer)
|
||||
return buffer;
|
||||
|
||||
struct user *user = str_map_find (&ctx->irc_users, nickname);
|
||||
if (!user)
|
||||
user = irc_make_user (ctx, xstrdup (nickname));
|
||||
|
||||
// Open a new buffer for the user
|
||||
buffer = buffer_new ();
|
||||
buffer->type = BUFFER_PM;
|
||||
buffer->name = xstrdup (nickname);
|
||||
buffer->user = user_ref (user);
|
||||
LIST_APPEND_WITH_TAIL (ctx->buffers, ctx->buffers_tail, buffer);
|
||||
str_map_set (&ctx->irc_buffer_map, user->nickname, buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
irc_channel_on_destroy (void *object, void *user_data)
|
||||
{
|
||||
@ -2116,20 +2137,8 @@ irc_handle_privmsg (struct app_context *ctx, const struct irc_message *msg)
|
||||
}
|
||||
else if (!buffer)
|
||||
{
|
||||
// Get or make a user object
|
||||
char *nickname = irc_cut_nickname (msg->prefix);
|
||||
struct user *user = str_map_find (&ctx->irc_users, nickname);
|
||||
if (!user)
|
||||
user = irc_make_user (ctx, xstrdup (nickname));
|
||||
|
||||
// Open a new buffer for the user
|
||||
buffer = buffer_new ();
|
||||
buffer->type = BUFFER_PM;
|
||||
buffer->name = xstrdup (nickname);
|
||||
buffer->user = user_ref (user);
|
||||
LIST_APPEND_WITH_TAIL (ctx->buffers, ctx->buffers_tail, buffer);
|
||||
str_map_set (&ctx->irc_buffer_map, user->nickname, buffer);
|
||||
|
||||
buffer = irc_get_user_buffer (ctx, nickname);
|
||||
free (nickname);
|
||||
}
|
||||
|
||||
@ -2707,13 +2716,7 @@ handle_command_query (struct app_context *ctx, char *arguments)
|
||||
buffer_send_error (ctx, ctx->server_buffer, "No text to send");
|
||||
else
|
||||
{
|
||||
struct buffer *buffer = str_map_find (&ctx->irc_buffer_map, target);
|
||||
if (!buffer)
|
||||
{
|
||||
// TODO: create a buffer for this user
|
||||
// TODO: see irc_handle_privmsg
|
||||
}
|
||||
buffer_activate (ctx, buffer);
|
||||
buffer_activate (ctx, irc_get_user_buffer (ctx, target));
|
||||
SEND_AUTOSPLIT_PRIVMSG (ctx, target, arguments);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user