mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 06:23:02 +01:00
rm /msg command
This commit is contained in:
parent
361c4cfafc
commit
0396ce6456
@ -571,8 +571,9 @@ ToxWindow new_chat(Tox *m, ToxWindow *prompt, int friendnum)
|
|||||||
ret.onFileData = &chat_onFileData;
|
ret.onFileData = &chat_onFileData;
|
||||||
|
|
||||||
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
|
uint8_t name[TOX_MAX_NAME_LENGTH] = {'\0'};
|
||||||
tox_getname(m, friendnum, name);
|
uint16_t len = tox_getname(m, friendnum, name);
|
||||||
snprintf(ret.name, sizeof(ret.name), "%s", name);
|
memcpy(ret.name, name, len);
|
||||||
|
ret.name[TOXIC_MAX_NAME_LENGTH] = '\0';
|
||||||
|
|
||||||
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
ChatContext *chatwin = calloc(1, sizeof(ChatContext));
|
||||||
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
StatusBar *stb = calloc(1, sizeof(StatusBar));
|
||||||
|
@ -261,39 +261,6 @@ void cmd_join(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_msg(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
|
||||||
{
|
|
||||||
/* check arguments */
|
|
||||||
if (argc < 2) {
|
|
||||||
wprintw(window, "Invalid syntax.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t *name = argv[1];
|
|
||||||
uint8_t *msg = argv[2];
|
|
||||||
|
|
||||||
if (name == NULL || msg == NULL) {
|
|
||||||
wprintw(window, "Invalid syntax.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg[0] != '\"') {
|
|
||||||
wprintw(window, "Messages must be enclosed in quotes.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg[strlen(++msg)-1] = L'\0';
|
|
||||||
int friendnum = get_friendnum(name);
|
|
||||||
|
|
||||||
if (friendnum == -1) {
|
|
||||||
wprintw(window, "Friend '%s' not found.\n", name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tox_sendmessage(m, friendnum, msg, strlen(msg) + 1) == 0)
|
|
||||||
wprintw(window, "Failed to send message.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
void cmd_myid(WINDOW *window, ToxWindow *prompt, Tox *m, int argc, char **argv)
|
||||||
{
|
{
|
||||||
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {0};
|
||||||
|
@ -9,7 +9,6 @@ void cmd_clear(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
|||||||
void cmd_connect(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_connect(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_groupchat(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_groupchat(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_join(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_join(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_msg(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
|
||||||
void cmd_myid(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_myid(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_nick(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_nick(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
void cmd_note(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
void cmd_note(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
||||||
@ -18,7 +17,7 @@ void cmd_status(WINDOW *, ToxWindow *, Tox *m, int, char **);
|
|||||||
|
|
||||||
void execute(WINDOW *window, ToxWindow *prompt, Tox *m, char *u_cmd, int buf_len);
|
void execute(WINDOW *window, ToxWindow *prompt, Tox *m, char *u_cmd, int buf_len);
|
||||||
|
|
||||||
#define NUM_COMMANDS 14
|
#define NUM_COMMANDS 13
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char *name;
|
char *name;
|
||||||
@ -31,7 +30,6 @@ static struct {
|
|||||||
{ "/exit", cmd_quit },
|
{ "/exit", cmd_quit },
|
||||||
{ "/groupchat", cmd_groupchat },
|
{ "/groupchat", cmd_groupchat },
|
||||||
{ "/join", cmd_join },
|
{ "/join", cmd_join },
|
||||||
{ "/msg", cmd_msg },
|
|
||||||
{ "/myid", cmd_myid },
|
{ "/myid", cmd_myid },
|
||||||
{ "/nick", cmd_nick },
|
{ "/nick", cmd_nick },
|
||||||
{ "/note", cmd_note },
|
{ "/note", cmd_note },
|
||||||
|
@ -255,19 +255,6 @@ void disable_chatwin(int f_num)
|
|||||||
friends[f_num].chatwin = -1;
|
friends[f_num].chatwin = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the respective friend number of name. Returns -1 on no match */
|
|
||||||
int get_friendnum(uint8_t *name)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < num_friends; ++i) {
|
|
||||||
if (strcmp(friends[i].name, name) == 0)
|
|
||||||
return friends[i].num;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void friendlist_onInit(ToxWindow *self, Tox *m)
|
static void friendlist_onInit(ToxWindow *self, Tox *m)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user