hacky colours

v1
Tony Olagbaiye 4 years ago
parent 71531be5e6
commit 8988d969a0
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -130,7 +130,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve
weechat_printf( weechat_printf(
account ? account->buffer : NULL, account ? account->buffer : NULL,
_("%s%s (%s): %s"), _("%s%s (%s): %s"),
weechat_prefix("error"), area, weechat_prefix("network"), area,
log_level_name[level], header); log_level_name[level], header);
for (int i = 1; i < size; i++) for (int i = 1; i < size; i++)
weechat_printf( weechat_printf(
@ -144,7 +144,7 @@ void account__log_emit_weechat(void *const userdata, const xmpp_log_level_t leve
weechat_printf( weechat_printf(
account ? account->buffer : NULL, account ? account->buffer : NULL,
_("%s%s (%s): %s"), _("%s%s (%s): %s"),
weechat_prefix("error"), area, weechat_prefix("network"), area,
log_level_name[level], msg); log_level_name[level], msg);
} }
} }

@ -610,7 +610,9 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
xmpp_send(account->connection, message); xmpp_send(account->connection, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
if (channel->type != CHANNEL_TYPE_MUC) if (channel->type != CHANNEL_TYPE_MUC)
weechat_printf(channel->buffer, "%s: %s", weechat_printf(channel->buffer, "%s%s",
weechat_config_string(account->options[ACCOUNT_OPTION_JID]), user__as_prefix_raw(
account,
weechat_config_string(account->options[ACCOUNT_OPTION_JID])),
body); body);
} }

@ -11,6 +11,7 @@
//#include "oauth.h" //#include "oauth.h"
//#include "teaminfo.h" //#include "teaminfo.h"
#include "account.h" #include "account.h"
#include "user.h"
#include "channel.h" #include "channel.h"
#include "buffer.h" #include "buffer.h"
#include "message.h" #include "message.h"
@ -490,9 +491,11 @@ int command__me(const void *pointer, void *data,
xmpp_message_set_body(message, text); xmpp_message_set_body(message, text);
xmpp_send(ptr_account->connection, message); xmpp_send(ptr_account->connection, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
weechat_printf(ptr_channel->buffer, "* %s %s", if (ptr_channel->type != CHANNEL_TYPE_MUC)
weechat_config_string(ptr_account->options[ACCOUNT_OPTION_JID]), weechat_printf(ptr_channel->buffer, "%s%s %s",
text); weechat_prefix("action"),
weechat_config_string(ptr_account->options[ACCOUNT_OPTION_JID]),
text);
} }
return WEECHAT_RC_OK; return WEECHAT_RC_OK;

@ -10,6 +10,7 @@
#include "plugin.h" #include "plugin.h"
#include "config.h" #include "config.h"
#include "account.h" #include "account.h"
#include "user.h"
#include "channel.h" #include "channel.h"
#include "connection.h" #include "connection.h"
@ -106,11 +107,16 @@ int message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userdata)
} }
if (strcmp(to, channel->id) == 0) if (strcmp(to, channel->id) == 0)
weechat_printf(channel->buffer, "%s [to %s]: %s", from, to, intext); weechat_printf(channel->buffer, "%s[to %s]: %s",
user__as_prefix_raw(account->context, from),
to, intext);
else if (weechat_string_match(intext, "/me *", 0)) else if (weechat_string_match(intext, "/me *", 0))
weechat_printf(channel->buffer, "* %s %s", from, intext+4); weechat_printf(channel->buffer, "%s%s %s",
weechat_prefix("action"), from, intext+4);
else else
weechat_printf(channel->buffer, "%s: %s", from, intext); weechat_printf(channel->buffer, "%s%s",
user__as_prefix_raw(account->context, from),
intext);
xmpp_free(account->context, intext); xmpp_free(account->context, intext);

@ -23,11 +23,25 @@ const char *user__get_colour_for_nicklist(struct t_user *user)
return weechat_info_get("nick_color_name", user->profile.display_name); return weechat_info_get("nick_color_name", user->profile.display_name);
} }
const char *user__as_prefix_raw(struct t_account *account,
const char *name)
{
static char result[2048];
(void) account;
snprintf(result, sizeof(result), "%s%s\t",
weechat_info_get("nick_color", name),
name);
return result;
}
const char *user__as_prefix(struct t_account *account, const char *user__as_prefix(struct t_account *account,
struct t_user *user, struct t_user *user,
const char *name) const char *name)
{ {
static char result[256]; static char result[2048];
(void) account; (void) account;
@ -39,7 +53,7 @@ const char *user__as_prefix(struct t_account *account,
} }
struct t_user *user__bot_search(struct t_account *account, struct t_user *user__bot_search(struct t_account *account,
const char *bot_id) const char *bot_id)
{ {
struct t_user *ptr_user; struct t_user *ptr_user;
@ -58,7 +72,7 @@ struct t_user *user__bot_search(struct t_account *account,
} }
struct t_user *user__search(struct t_account *account, struct t_user *user__search(struct t_account *account,
const char *id) const char *id)
{ {
struct t_user *ptr_user; struct t_user *ptr_user;
@ -76,8 +90,8 @@ struct t_user *user__search(struct t_account *account,
} }
void user__nicklist_add(struct t_account *account, void user__nicklist_add(struct t_account *account,
struct t_channel *channel, struct t_channel *channel,
struct t_user *user) struct t_user *user)
{ {
struct t_gui_nick_group *ptr_group; struct t_gui_nick_group *ptr_group;
struct t_gui_buffer *ptr_buffer; struct t_gui_buffer *ptr_buffer;
@ -89,7 +103,7 @@ void user__nicklist_add(struct t_account *account,
"+" : "..."); "+" : "...");
weechat_nicklist_add_nick(ptr_buffer, ptr_group, weechat_nicklist_add_nick(ptr_buffer, ptr_group,
user->profile.display_name, user->profile.display_name,
user->is_away ? user->is_away ?
"weechat.color.nicklist_away" : "weechat.color.nicklist_away" :
user__get_colour_for_nicklist(user), user__get_colour_for_nicklist(user),
user->is_away ? "+" : "", user->is_away ? "+" : "",
@ -98,7 +112,7 @@ void user__nicklist_add(struct t_account *account,
} }
struct t_user *user__new(struct t_account *account, struct t_user *user__new(struct t_account *account,
const char *id, const char *display_name) const char *id, const char *display_name)
{ {
struct t_user *new_user, *ptr_user; struct t_user *new_user, *ptr_user;

@ -53,23 +53,26 @@ struct t_channel;
const char *user__get_colour(struct t_user *user); const char *user__get_colour(struct t_user *user);
const char *user__as_prefix_raw(struct t_account *account,
const char *name);
const char *user__as_prefix(struct t_account *account, const char *user__as_prefix(struct t_account *account,
struct t_user *user, struct t_user *user,
const char *name); const char *name);
struct t_user *user__bot_search(struct t_account *account, struct t_user *user__bot_search(struct t_account *account,
const char *bot_id); const char *bot_id);
struct t_user *user__search(struct t_account *account, struct t_user *user__search(struct t_account *account,
const char *id); const char *id);
struct t_user *user__new(struct t_account *account, struct t_user *user__new(struct t_account *account,
const char *id, const char *display_name); const char *id, const char *display_name);
void user__free_all(struct t_account *account); void user__free_all(struct t_account *account);
void user__nicklist_add(struct t_account *account, void user__nicklist_add(struct t_account *account,
struct t_channel *channel, struct t_channel *channel,
struct t_user *user); struct t_user *user);
#endif /*WEECHAT_XMPP_USER_H*/ #endif /*WEECHAT_XMPP_USER_H*/

Loading…
Cancel
Save