Added /duck command to perform searches using duckduckgo chat bot
This commit is contained in:
@@ -265,7 +265,7 @@ cons_show_wins(void)
|
||||
switch (window->type)
|
||||
{
|
||||
case WIN_CHAT:
|
||||
wprintw(console->win, "%d: chat %s", i + 1, window->from);
|
||||
wprintw(console->win, "%d: Chat %s", i + 1, window->from);
|
||||
PContact contact = contact_list_get_contact(window->from);
|
||||
|
||||
if (contact != NULL) {
|
||||
@@ -282,7 +282,7 @@ cons_show_wins(void)
|
||||
break;
|
||||
|
||||
case WIN_PRIVATE:
|
||||
wprintw(console->win, "%d: private %s", i + 1, window->from);
|
||||
wprintw(console->win, "%d: Private %s", i + 1, window->from);
|
||||
|
||||
if (window->unread > 0) {
|
||||
wprintw(console->win, ", %d unread", window->unread);
|
||||
@@ -291,7 +291,7 @@ cons_show_wins(void)
|
||||
break;
|
||||
|
||||
case WIN_MUC:
|
||||
wprintw(console->win, "%d: room %s", i + 1, window->from);
|
||||
wprintw(console->win, "%d: Room %s", i + 1, window->from);
|
||||
|
||||
if (window->unread > 0) {
|
||||
wprintw(console->win, ", %d unread", window->unread);
|
||||
@@ -299,6 +299,11 @@ cons_show_wins(void)
|
||||
|
||||
break;
|
||||
|
||||
case WIN_DUCK:
|
||||
wprintw(console->win, "%d: DuckDuckGo search", i + 1);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,20 @@ ui_windows_full(void)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ui_duck_exists(void)
|
||||
{
|
||||
int i;
|
||||
for (i = 1; i < NUM_WINS; i++) {
|
||||
if (windows[i] != NULL) {
|
||||
if (windows[i]->type == WIN_DUCK)
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
ui_contact_typing(const char * const from)
|
||||
{
|
||||
@@ -712,6 +726,54 @@ ui_new_chat_win(const char * const to)
|
||||
ui_switch_win(win_index);
|
||||
}
|
||||
|
||||
void
|
||||
ui_create_duck_win(void)
|
||||
{
|
||||
int win_index = _new_prof_win("DuckDuckGo search", WIN_DUCK);
|
||||
ui_switch_win(win_index);
|
||||
win_print_time(windows[win_index], '-');
|
||||
wprintw(windows[win_index]->win, "Type ':help' to find out more.\n");
|
||||
}
|
||||
|
||||
void
|
||||
ui_open_duck_win(void)
|
||||
{
|
||||
int win_index = _find_prof_win_index("DuckDuckGo search");
|
||||
if (win_index != NUM_WINS) {
|
||||
ui_switch_win(win_index);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ui_duck(const char * const query)
|
||||
{
|
||||
int win_index = _find_prof_win_index("DuckDuckGo search");
|
||||
if (win_index != NUM_WINS) {
|
||||
win_print_time(windows[win_index], '-');
|
||||
wprintw(windows[win_index]->win, "\n");
|
||||
win_print_time(windows[win_index], '-');
|
||||
wattron(windows[win_index]->win, COLOUR_ME);
|
||||
wprintw(windows[win_index]->win, "Query : ");
|
||||
wattroff(windows[win_index]->win, COLOUR_ME);
|
||||
wprintw(windows[win_index]->win, query);
|
||||
wprintw(windows[win_index]->win, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ui_duck_result(const char * const result)
|
||||
{
|
||||
int win_index = _find_prof_win_index("DuckDuckGo search");
|
||||
if (win_index != NUM_WINS) {
|
||||
win_print_time(windows[win_index], '-');
|
||||
wattron(windows[win_index]->win, COLOUR_THEM);
|
||||
wprintw(windows[win_index]->win, "Result : ");
|
||||
wattroff(windows[win_index]->win, COLOUR_THEM);
|
||||
wprintw(windows[win_index]->win, result);
|
||||
wprintw(windows[win_index]->win, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ui_outgoing_msg(const char * const from, const char * const to,
|
||||
const char * const message)
|
||||
|
||||
@@ -110,6 +110,12 @@ void ui_status_room(const char * const contact);
|
||||
void ui_status(void);
|
||||
void ui_status_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);
|
||||
|
||||
// create windows
|
||||
void create_title_bar(void);
|
||||
void create_status_bar(void);
|
||||
|
||||
@@ -32,7 +32,8 @@ typedef enum {
|
||||
WIN_CONSOLE,
|
||||
WIN_CHAT,
|
||||
WIN_MUC,
|
||||
WIN_PRIVATE
|
||||
WIN_PRIVATE,
|
||||
WIN_DUCK
|
||||
} win_type_t;
|
||||
|
||||
typedef struct prof_win_t {
|
||||
|
||||
Reference in New Issue
Block a user