mirror of
https://github.com/Tha14/toxic.git
synced 2025-12-16 12:06:35 +01:00
Added sounds
This commit is contained in:
@@ -41,13 +41,14 @@
|
||||
#include "settings.h"
|
||||
#include "input.h"
|
||||
#include "help.h"
|
||||
#include "notify.h"
|
||||
|
||||
extern char *DATA_FILE;
|
||||
|
||||
static GroupChat groupchats[MAX_GROUPCHAT_NUM];
|
||||
static int max_groupchat_index = 0;
|
||||
|
||||
extern struct user_settings *user_settings;
|
||||
extern struct user_settings *user_settings_;
|
||||
|
||||
/* temporary until group chats have unique commands */
|
||||
extern const char glob_cmd_list[AC_NUM_GLOB_COMMANDS][MAX_CMDNAME_SIZE];
|
||||
@@ -134,25 +135,18 @@ static void groupchat_onGroupMessage(ToxWindow *self, Tox *m, int groupnum, int
|
||||
n_len = MIN(n_len, TOXIC_MAX_NAME_LENGTH - 1); /* enforce client max name length */
|
||||
nick[n_len] = '\0';
|
||||
|
||||
/* check if message contains own name and alert appropriately */
|
||||
int alert_type = WINDOW_ALERT_1;
|
||||
bool beep = false;
|
||||
|
||||
char selfnick[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t sn_len = tox_get_self_name(m, (uint8_t *) selfnick);
|
||||
selfnick[sn_len] = '\0';
|
||||
|
||||
int nick_clr = strcmp(nick, selfnick) == 0 ? GREEN : CYAN;
|
||||
|
||||
bool nick_match = strcasestr(msg, selfnick) && strncmp(selfnick, nick, TOXIC_MAX_NAME_LENGTH - 1);
|
||||
|
||||
if (nick_match) {
|
||||
alert_type = WINDOW_ALERT_0;
|
||||
beep = true;
|
||||
/* Only play sound if mentioned */
|
||||
if (strcasestr(msg, selfnick) && strncmp(selfnick, nick, TOXIC_MAX_NAME_LENGTH - 1)) {
|
||||
notify(self, generic_message, NT_WNDALERT_0);
|
||||
nick_clr = RED;
|
||||
}
|
||||
|
||||
alert_window(self, alert_type, beep);
|
||||
else notify(self, unknown, NT_WNDALERT_1);
|
||||
|
||||
char timefrmt[TIME_STR_SIZE];
|
||||
get_time_str(timefrmt, sizeof(timefrmt));
|
||||
@@ -169,22 +163,14 @@ static void groupchat_onGroupAction(ToxWindow *self, Tox *m, int groupnum, int p
|
||||
|
||||
ChatContext *ctx = self->chatwin;
|
||||
|
||||
/* check if message contains own name and alert appropriately */
|
||||
int alert_type = WINDOW_ALERT_1;
|
||||
bool beep = false;
|
||||
|
||||
char selfnick[TOX_MAX_NAME_LENGTH];
|
||||
uint16_t n_len = tox_get_self_name(m, (uint8_t *) selfnick);
|
||||
selfnick[n_len] = '\0';
|
||||
|
||||
bool nick_match = strcasestr(action, selfnick);
|
||||
|
||||
if (nick_match) {
|
||||
alert_type = WINDOW_ALERT_0;
|
||||
beep = true;
|
||||
if (strcasestr(action, selfnick)) {
|
||||
notify(self, generic_message, NT_WNDALERT_0);
|
||||
}
|
||||
|
||||
alert_window(self, alert_type, beep);
|
||||
else notify(self, unknown, NT_WNDALERT_1);
|
||||
|
||||
char nick[TOX_MAX_NAME_LENGTH];
|
||||
n_len = tox_group_peername(m, groupnum, peernum, (uint8_t *) nick);
|
||||
@@ -317,7 +303,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu
|
||||
break;
|
||||
}
|
||||
|
||||
alert_window(self, WINDOW_ALERT_2, false);
|
||||
notify(self, unknown, NT_WNDALERT_2);
|
||||
}
|
||||
|
||||
static void send_group_action(ToxWindow *self, ChatContext *ctx, Tox *m, char *action)
|
||||
@@ -502,7 +488,7 @@ static void groupchat_onInit(ToxWindow *self, Tox *m)
|
||||
|
||||
line_info_init(ctx->hst);
|
||||
|
||||
if (user_settings->autolog == AUTOLOG_ON)
|
||||
if (user_settings_->autolog == AUTOLOG_ON)
|
||||
log_enable(self->name, NULL, ctx->log);
|
||||
|
||||
execute(ctx->history, self, m, "/log", GLOBAL_COMMAND_MODE);
|
||||
|
||||
Reference in New Issue
Block a user