mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Removed /duck command
This commit is contained in:
parent
6b6ed6a93e
commit
9f2f54b2a0
@ -502,17 +502,6 @@ static struct cmd_t command_defs[] =
|
||||
"Example : /tiny http://www.profanity.im",
|
||||
NULL } } },
|
||||
|
||||
{ "/duck",
|
||||
cmd_duck, parse_args_with_freetext, 1, 1, NULL,
|
||||
{ "/duck query", "Perform search using DuckDuckGo chatbot.",
|
||||
{ "/duck query",
|
||||
"-----------",
|
||||
"Send a search query to the DuckDuckGo chatbot.",
|
||||
"Your chat service must be federated, i.e. allow message to be sent/received outside of its domain.",
|
||||
"",
|
||||
"Example : /duck dennis ritchie",
|
||||
NULL } } },
|
||||
|
||||
{ "/who",
|
||||
cmd_who, parse_args, 0, 2, NULL,
|
||||
{ "/who [status] [group]", "Show contacts/room participants with chosen status.",
|
||||
@ -1693,15 +1682,6 @@ cmd_execute_default(const char * inp)
|
||||
cons_show("Unknown command: %s", inp);
|
||||
break;
|
||||
|
||||
case WIN_DUCK:
|
||||
if (status != JABBER_CONNECTED) {
|
||||
ui_current_print_line("You are not currently connected.");
|
||||
} else {
|
||||
message_send_duck(inp);
|
||||
ui_duck(inp);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -582,7 +582,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
|
||||
_cmd_show_filtered_help("Basic commands", filter, ARRAY_SIZE(filter));
|
||||
|
||||
} else if (strcmp(args[0], "chatting") == 0) {
|
||||
gchar *filter[] = { "/chlog", "/otr", "/duck", "/gone", "/history",
|
||||
gchar *filter[] = { "/chlog", "/otr", "/gone", "/history",
|
||||
"/info", "/intype", "/msg", "/notify", "/outtype", "/status",
|
||||
"/close", "/clear", "/tiny" };
|
||||
_cmd_show_filtered_help("Chat commands", filter, ARRAY_SIZE(filter));
|
||||
@ -616,7 +616,7 @@ cmd_help(gchar **args, struct cmd_help_t help)
|
||||
_cmd_show_filtered_help("Settings commands", filter, ARRAY_SIZE(filter));
|
||||
|
||||
} else if (strcmp(args[0], "other") == 0) {
|
||||
gchar *filter[] = { "/duck", "/vercheck" };
|
||||
gchar *filter[] = { "/vercheck" };
|
||||
_cmd_show_filtered_help("Other commands", filter, ARRAY_SIZE(filter));
|
||||
|
||||
} else if (strcmp(args[0], "navigation") == 0) {
|
||||
@ -1404,40 +1404,6 @@ cmd_roster(gchar **args, struct cmd_help_t help)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_duck(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
char *query = args[0];
|
||||
|
||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// if no duck win open, create it and send a help command
|
||||
if (!ui_duck_exists()) {
|
||||
ui_create_duck_win();
|
||||
|
||||
if (query != NULL) {
|
||||
message_send_duck(query);
|
||||
ui_duck(query);
|
||||
}
|
||||
|
||||
// window exists, send query
|
||||
} else {
|
||||
ui_open_duck_win();
|
||||
|
||||
if (query != NULL) {
|
||||
message_send_duck(query);
|
||||
ui_duck(query);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_status(gchar **args, struct cmd_help_t help)
|
||||
{
|
||||
|
@ -79,7 +79,6 @@ gboolean cmd_decline(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_disco(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_disconnect(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_dnd(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_duck(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_flash(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_gone(gchar **args, struct cmd_help_t help);
|
||||
gboolean cmd_grlog(gchar **args, struct cmd_help_t help);
|
||||
|
@ -295,12 +295,6 @@ handle_room_message(const char * const room_jid, const char * const nick,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
handle_duck_result(const char * const result)
|
||||
{
|
||||
ui_duck_result(result);
|
||||
}
|
||||
|
||||
void
|
||||
handle_incoming_message(char *from, char *message, gboolean priv)
|
||||
{
|
||||
|
@ -71,7 +71,6 @@ void handle_room_role_set_error(const char * const room, const char * const nick
|
||||
const char * const error);
|
||||
void handle_room_role_set(const char * const from, const char * const nick, const char * const role);
|
||||
void handle_room_kick_result_error(const char * const room, const char * const nick, const char * const error);
|
||||
void handle_duck_result(const char * const result);
|
||||
void handle_incoming_message(char *from, char *message, gboolean priv);
|
||||
void handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
|
||||
gboolean priv);
|
||||
|
@ -233,12 +233,6 @@ _ui_win_exists(int index)
|
||||
return (window != NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_ui_duck_exists(void)
|
||||
{
|
||||
return wins_duck_exists();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_ui_xmlconsole_exists(void)
|
||||
{
|
||||
@ -1234,15 +1228,6 @@ _ui_new_chat_win(const char * const to)
|
||||
ui_switch_win(num);
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_create_duck_win(void)
|
||||
{
|
||||
ProfWin *window = wins_new("DuckDuckGo search", WIN_DUCK);
|
||||
int num = wins_get_num(window);
|
||||
ui_switch_win(num);
|
||||
win_save_println(window, "Type ':help' to find out more.");
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_create_xmlconsole_win(void)
|
||||
{
|
||||
@ -1261,57 +1246,6 @@ _ui_open_xmlconsole_win(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_open_duck_win(void)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient("DuckDuckGo search");
|
||||
if (window != NULL) {
|
||||
int num = wins_get_num(window);
|
||||
ui_switch_win(num);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_duck(const char * const query)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient("DuckDuckGo search");
|
||||
if (window != NULL) {
|
||||
win_save_println(window, "");
|
||||
win_save_print(window, '-', NULL, NO_EOL, COLOUR_ME, "", "Query : ");
|
||||
win_save_print(window, '-', NULL, NO_DATE, 0, "", query);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_duck_result(const char * const result)
|
||||
{
|
||||
ProfWin *window = wins_get_by_recipient("DuckDuckGo search");
|
||||
|
||||
if (window != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_EOL, COLOUR_THEM, "", "Result : ");
|
||||
|
||||
glong offset = 0;
|
||||
while (offset < g_utf8_strlen(result, -1)) {
|
||||
gchar *ptr = g_utf8_offset_to_pointer(result, offset);
|
||||
gunichar unichar = g_utf8_get_char(ptr);
|
||||
if (unichar == '\n') {
|
||||
win_save_newline(window);
|
||||
win_save_print(window, '-', NULL, NO_EOL, 0, "", "");
|
||||
} else {
|
||||
gchar *string = g_ucs4_to_utf8(&unichar, 1, NULL, NULL, NULL);
|
||||
if (string != NULL) {
|
||||
win_save_print(window, '-', NULL, NO_DATE | NO_EOL, 0, "", string);
|
||||
g_free(string);
|
||||
}
|
||||
}
|
||||
|
||||
offset++;
|
||||
}
|
||||
|
||||
win_save_newline(window);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ui_outgoing_msg(const char * const from, const char * const to,
|
||||
const char * const message)
|
||||
@ -2993,7 +2927,6 @@ ui_init_module(void)
|
||||
ui_resize = _ui_resize;
|
||||
ui_load_colours = _ui_load_colours;
|
||||
ui_win_exists = _ui_win_exists;
|
||||
ui_duck_exists = _ui_duck_exists;
|
||||
ui_contact_typing = _ui_contact_typing;
|
||||
ui_get_recipients = _ui_get_recipients;
|
||||
ui_incoming_msg = _ui_incoming_msg;
|
||||
@ -3027,10 +2960,6 @@ ui_init_module(void)
|
||||
ui_print_system_msg_from_recipient = _ui_print_system_msg_from_recipient;
|
||||
ui_recipient_gone = _ui_recipient_gone;
|
||||
ui_new_chat_win = _ui_new_chat_win;
|
||||
ui_create_duck_win = _ui_create_duck_win;
|
||||
ui_open_duck_win = _ui_open_duck_win;
|
||||
ui_duck = _ui_duck;
|
||||
ui_duck_result = _ui_duck_result;
|
||||
ui_outgoing_msg = _ui_outgoing_msg;
|
||||
ui_room_join = _ui_room_join;
|
||||
ui_room_roster = _ui_room_roster;
|
||||
|
@ -209,12 +209,6 @@ void (*ui_info)(void);
|
||||
void (*ui_status_private)(void);
|
||||
void (*ui_info_private)(void);
|
||||
|
||||
void (*ui_create_duck_win)(void);
|
||||
void (*ui_open_duck_win)(void);
|
||||
void (*ui_duck)(const char * const query);
|
||||
void (*ui_duck_result)(const char * const result);
|
||||
gboolean (*ui_duck_exists)(void);
|
||||
|
||||
void (*ui_tidy_wins)(void);
|
||||
void (*ui_prune_wins)(void);
|
||||
gboolean (*ui_swap_wins)(int source_win, int target_win);
|
||||
|
@ -62,7 +62,6 @@ typedef enum {
|
||||
WIN_MUC,
|
||||
WIN_MUC_CONFIG,
|
||||
WIN_PRIVATE,
|
||||
WIN_DUCK,
|
||||
WIN_XML
|
||||
} win_type_t;
|
||||
|
||||
|
@ -342,25 +342,6 @@ wins_show_subwin(ProfWin *window)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
wins_duck_exists(void)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
|
||||
while (curr != NULL) {
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_DUCK) {
|
||||
g_list_free(values);
|
||||
return TRUE;
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
|
||||
g_list_free(values);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
wins_xmlconsole_exists(void)
|
||||
{
|
||||
@ -585,7 +566,6 @@ wins_create_summary(void)
|
||||
GString *priv_string;
|
||||
GString *muc_string;
|
||||
GString *muc_config_string;
|
||||
GString *duck_string;
|
||||
GString *xml_string;
|
||||
|
||||
switch (window->type)
|
||||
@ -663,14 +643,6 @@ wins_create_summary(void)
|
||||
|
||||
break;
|
||||
|
||||
case WIN_DUCK:
|
||||
duck_string = g_string_new("");
|
||||
g_string_printf(duck_string, "%d: DuckDuckGo search", ui_index);
|
||||
result = g_slist_append(result, strdup(duck_string->str));
|
||||
g_string_free(duck_string, TRUE);
|
||||
|
||||
break;
|
||||
|
||||
case WIN_XML:
|
||||
xml_string = g_string_new("");
|
||||
g_string_printf(xml_string, "%d: XML console", ui_index);
|
||||
|
@ -52,7 +52,6 @@ gboolean wins_is_current(ProfWin *window);
|
||||
ProfWin * wins_new(const char * const from, win_type_t type);
|
||||
int wins_get_total_unread(void);
|
||||
void wins_resize_all(void);
|
||||
gboolean wins_duck_exists(void);
|
||||
GSList * wins_get_chat_recipients(void);
|
||||
GSList * wins_get_prune_recipients(void);
|
||||
void wins_lost_connection(void);
|
||||
|
@ -135,18 +135,6 @@ _message_send_groupchat_subject(const char * const room, const char * const subj
|
||||
xmpp_stanza_release(message);
|
||||
}
|
||||
|
||||
static void
|
||||
_message_send_duck(const char * const query)
|
||||
{
|
||||
xmpp_conn_t * const conn = connection_get_conn();
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *message = stanza_create_message(ctx, "im@ddg.gg",
|
||||
STANZA_TYPE_CHAT, query, NULL);
|
||||
|
||||
xmpp_send(conn, message);
|
||||
xmpp_stanza_release(message);
|
||||
}
|
||||
|
||||
static void
|
||||
_message_send_invite(const char * const room, const char * const contact,
|
||||
const char * const reason)
|
||||
@ -438,22 +426,8 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
Jid *jid = jid_create(from);
|
||||
|
||||
// handle ddg searches
|
||||
if (strcmp(jid->barejid, "im@ddg.gg") == 0) {
|
||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
|
||||
if (body != NULL) {
|
||||
char *message = xmpp_stanza_get_text(body);
|
||||
if (message != NULL) {
|
||||
handle_duck_result(message);
|
||||
xmpp_free(ctx, message);
|
||||
}
|
||||
}
|
||||
|
||||
jid_destroy(jid);
|
||||
return 1;
|
||||
|
||||
// private message from chat room use full jid (room/nick)
|
||||
} else if (muc_active(jid->barejid)) {
|
||||
if (muc_active(jid->barejid)) {
|
||||
// determine if the notifications happened whilst offline
|
||||
GTimeVal tv_stamp;
|
||||
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
|
||||
@ -533,7 +507,6 @@ message_init_module(void)
|
||||
{
|
||||
message_send = _message_send;
|
||||
message_send_groupchat = _message_send_groupchat;
|
||||
message_send_duck = _message_send_duck;
|
||||
message_send_invite = _message_send_invite;
|
||||
message_send_composing = _message_send_composing;
|
||||
message_send_paused = _message_send_paused;
|
||||
|
@ -164,7 +164,6 @@ void (*message_send_paused)(const char * const recipient);
|
||||
void (*message_send_gone)(const char * const recipient);
|
||||
void (*message_send_invite)(const char * const room, const char * const contact,
|
||||
const char * const reason);
|
||||
void (*message_send_duck)(const char * const query);
|
||||
|
||||
// presence functions
|
||||
void (*presence_subscription)(const char * const jid, const jabber_subscr_t action);
|
||||
|
@ -432,11 +432,6 @@ void cmd_otr_theirfp_shows_message_when_in_private(void **state)
|
||||
test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE);
|
||||
}
|
||||
|
||||
void cmd_otr_theirfp_shows_message_when_in_duck(void **state)
|
||||
{
|
||||
test_cmd_otr_theirfp_from_wintype(WIN_DUCK);
|
||||
}
|
||||
|
||||
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
@ -513,11 +508,6 @@ void cmd_otr_start_shows_message_when_in_private(void **state)
|
||||
test_cmd_otr_start_from_wintype(WIN_PRIVATE);
|
||||
}
|
||||
|
||||
void cmd_otr_start_shows_message_when_in_duck(void **state)
|
||||
{
|
||||
test_cmd_otr_start_from_wintype(WIN_DUCK);
|
||||
}
|
||||
|
||||
void cmd_otr_start_shows_message_when_already_started(void **state)
|
||||
{
|
||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||
|
@ -32,13 +32,11 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state);
|
||||
void cmd_otr_theirfp_shows_message_when_in_console(void **state);
|
||||
void cmd_otr_theirfp_shows_message_when_in_muc(void **state);
|
||||
void cmd_otr_theirfp_shows_message_when_in_private(void **state);
|
||||
void cmd_otr_theirfp_shows_message_when_in_duck(void **state);
|
||||
void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state);
|
||||
void cmd_otr_theirfp_shows_fingerprint(void **state);
|
||||
void cmd_otr_start_shows_message_when_in_console(void **state);
|
||||
void cmd_otr_start_shows_message_when_in_muc(void **state);
|
||||
void cmd_otr_start_shows_message_when_in_private(void **state);
|
||||
void cmd_otr_start_shows_message_when_in_duck(void **state);
|
||||
void cmd_otr_start_shows_message_when_already_started(void **state);
|
||||
void cmd_otr_start_shows_message_when_no_key(void **state);
|
||||
void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state);
|
||||
|
@ -487,13 +487,11 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_otr_theirfp_shows_message_when_in_console),
|
||||
unit_test(cmd_otr_theirfp_shows_message_when_in_muc),
|
||||
unit_test(cmd_otr_theirfp_shows_message_when_in_private),
|
||||
unit_test(cmd_otr_theirfp_shows_message_when_in_duck),
|
||||
unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window),
|
||||
unit_test(cmd_otr_theirfp_shows_fingerprint),
|
||||
unit_test(cmd_otr_start_shows_message_when_in_console),
|
||||
unit_test(cmd_otr_start_shows_message_when_in_muc),
|
||||
unit_test(cmd_otr_start_shows_message_when_in_private),
|
||||
unit_test(cmd_otr_start_shows_message_when_in_duck),
|
||||
unit_test(cmd_otr_start_shows_message_when_already_started),
|
||||
unit_test(cmd_otr_start_shows_message_when_no_key),
|
||||
unit_test(cmd_otr_start_sends_otr_query_message_to_current_recipeint),
|
||||
|
Loading…
Reference in New Issue
Block a user