mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added tiny command
This commit is contained in:
parent
ee6ac9be26
commit
ea5c1f0fa4
@ -33,6 +33,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "prof_autocomplete.h"
|
#include "prof_autocomplete.h"
|
||||||
|
#include "tinyurl.h"
|
||||||
|
|
||||||
static gboolean _handle_command(const char * const command,
|
static gboolean _handle_command(const char * const command,
|
||||||
const char * const inp);
|
const char * const inp);
|
||||||
@ -43,6 +44,7 @@ static gboolean _cmd_who(const char * const inp);
|
|||||||
static gboolean _cmd_ros(const char * const inp);
|
static gboolean _cmd_ros(const char * const inp);
|
||||||
static gboolean _cmd_connect(const char * const inp);
|
static gboolean _cmd_connect(const char * const inp);
|
||||||
static gboolean _cmd_msg(const char * const inp);
|
static gboolean _cmd_msg(const char * const inp);
|
||||||
|
static gboolean _cmd_tiny(const char * const inp);
|
||||||
static gboolean _cmd_close(const char * const inp);
|
static gboolean _cmd_close(const char * const inp);
|
||||||
static gboolean _cmd_set_beep(const char * const inp);
|
static gboolean _cmd_set_beep(const char * const inp);
|
||||||
static gboolean _cmd_set_notify(const char * const inp);
|
static gboolean _cmd_set_notify(const char * const inp);
|
||||||
@ -77,6 +79,7 @@ static struct cmd_t commands[] = {
|
|||||||
{ "/help", _cmd_help },
|
{ "/help", _cmd_help },
|
||||||
{ "/prefs", _cmd_prefs },
|
{ "/prefs", _cmd_prefs },
|
||||||
{ "/msg", _cmd_msg },
|
{ "/msg", _cmd_msg },
|
||||||
|
{ "/tiny", _cmd_tiny },
|
||||||
{ "/online", _cmd_online },
|
{ "/online", _cmd_online },
|
||||||
{ "/quit", _cmd_quit },
|
{ "/quit", _cmd_quit },
|
||||||
{ "/ros", _cmd_ros },
|
{ "/ros", _cmd_ros },
|
||||||
@ -277,6 +280,42 @@ _cmd_msg(const char * const inp)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_tiny(const char * const inp)
|
||||||
|
{
|
||||||
|
char *usr = NULL;
|
||||||
|
char *msg = NULL;
|
||||||
|
|
||||||
|
jabber_conn_status_t conn_status = jabber_connection_status();
|
||||||
|
|
||||||
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
|
cons_show("You are not currently connected.");
|
||||||
|
} else {
|
||||||
|
// copy input
|
||||||
|
char inp_cpy[strlen(inp) + 1];
|
||||||
|
strcpy(inp_cpy, inp);
|
||||||
|
|
||||||
|
// get user
|
||||||
|
strtok(inp_cpy, " ");
|
||||||
|
usr = strtok(NULL, " ");
|
||||||
|
if ((usr != NULL) && (strlen(inp) > (6 + strlen(usr) + 1))) {
|
||||||
|
// get message
|
||||||
|
msg = strndup(inp+6+strlen(usr)+1, strlen(inp)-(6+strlen(usr)+1));
|
||||||
|
if (msg != NULL) {
|
||||||
|
char *tinyurl = tinyurl_get(msg);
|
||||||
|
jabber_send(tinyurl, usr);
|
||||||
|
win_show_outgoing_msg("me", usr, tinyurl);
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: /tiny user@host url");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: /tiny user@host url");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_close(const char * const inp)
|
_cmd_close(const char * const inp)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "contact_list.h"
|
#include "contact_list.h"
|
||||||
|
#include "tinyurl.h"
|
||||||
|
|
||||||
static void _profanity_shutdown(void);
|
static void _profanity_shutdown(void);
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ profanity_init(const int disable_tls)
|
|||||||
jabber_init(disable_tls);
|
jabber_init(disable_tls);
|
||||||
command_init();
|
command_init();
|
||||||
contact_list_init();
|
contact_list_init();
|
||||||
|
tinyurl_init();
|
||||||
atexit(_profanity_shutdown);
|
atexit(_profanity_shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,6 +362,7 @@ cons_help(void)
|
|||||||
cons_show("/prefs : Show current UI preferences.");
|
cons_show("/prefs : Show current UI preferences.");
|
||||||
cons_show("/connect user@host : Login to jabber.");
|
cons_show("/connect user@host : Login to jabber.");
|
||||||
cons_show("/msg user@host mesg : Send mesg to user.");
|
cons_show("/msg user@host mesg : Send mesg to user.");
|
||||||
|
cons_show("/tiny user@host url : Send url as tinyurl");
|
||||||
cons_show("/close : Close a chat window.");
|
cons_show("/close : Close a chat window.");
|
||||||
cons_show("/who : Find out who is online.");
|
cons_show("/who : Find out who is online.");
|
||||||
cons_show("/ros : List all contacts.");
|
cons_show("/ros : List all contacts.");
|
||||||
@ -518,10 +519,6 @@ _create_windows(void)
|
|||||||
wprintw(_cons_win, "\n");
|
wprintw(_cons_win, "\n");
|
||||||
_win_show_time(_cons_win);
|
_win_show_time(_cons_win);
|
||||||
wprintw(_cons_win, "Type '/help' to get started.\n");
|
wprintw(_cons_win, "Type '/help' to get started.\n");
|
||||||
|
|
||||||
tinyurl_init();
|
|
||||||
char *url = tinyurl_get("http://www.london2012.com/schedule-and-results/");
|
|
||||||
cons_show(url);
|
|
||||||
}
|
}
|
||||||
prefresh(_cons_win, 0, 0, 1, 0, rows-3, cols-1);
|
prefresh(_cons_win, 0, 0, 1, 0, rows-3, cols-1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user