aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/twitter/twitter.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/twitter/twitter.c')
-rw-r--r--protocols/twitter/twitter.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/protocols/twitter/twitter.c b/protocols/twitter/twitter.c
index b2039171..5f6156a6 100644
--- a/protocols/twitter/twitter.c
+++ b/protocols/twitter/twitter.c
@@ -304,7 +304,7 @@ static void twitter_main_loop_start(struct im_connection *ic)
struct groupchat *twitter_groupchat_init(struct im_connection *ic)
{
- char *name_hint;
+ char *name_hint, *tmp;
struct groupchat *gc;
struct twitter_data *td = ic->proto_data;
GSList *l;
@@ -315,7 +315,14 @@ struct groupchat *twitter_groupchat_init(struct im_connection *ic)
td->timeline_gc = gc = imcb_chat_new(ic, "twitter/timeline");
- name_hint = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);
+ tmp = set_getstr(&ic->acc->set, "channel_name");
+
+ if (tmp == NULL || strlen(tmp) == 0) {
+ name_hint = g_strdup_printf("%s_%s", td->prefix, ic->acc->user);
+ } else {
+ name_hint = g_strdup(tmp);
+ }
+
imcb_chat_name_hint(gc, name_hint);
g_free(name_hint);
@@ -518,6 +525,23 @@ static char *set_eval_commands(set_t * set, char *value)
}
}
+static char *set_eval_channel_name(set_t * set, char *value)
+{
+ size_t len;
+
+ if (value == NULL) {
+ return NULL;
+ }
+
+ len = strlen(value);
+
+ if (len < MAX_NICK_LENGTH && len > 0) {
+ return value;
+ } else {
+ return NULL;
+ }
+}
+
static char *set_eval_mode(set_t * set, char *value)
{
if (g_strcasecmp(value, "one") == 0 ||
@@ -572,6 +596,12 @@ static void twitter_init(account_t * acc)
s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc);
+ s = set_add(&acc->set, "long_ids", "false", set_eval_bool, acc);
+ s->flags |= ACC_SET_OFFLINE_ONLY;
+
+ s = set_add(&acc->set, "channel_name", NULL, set_eval_channel_name, acc);
+ s->flags |= ACC_SET_OFFLINE_ONLY;
+
s = set_add(&acc->set, "_last_tweet", "0", NULL, acc);
s->flags |= SET_HIDDEN | SET_NOSAVE;
@@ -649,8 +679,13 @@ static void twitter_login(account_t * acc)
imcb_add_buddy(ic, name, NULL);
imcb_buddy_status(ic, name, OPT_LOGGED_IN, NULL, NULL);
- td->log = g_new0(struct twitter_log_data, TWITTER_LOG_LENGTH);
+ td->long_ids = set_getbool(&ic->acc->set, "long_ids");
+ td->log_length = (td->long_ids) ? TWITTER_LONG_LOG_LENGTH : TWITTER_SHORT_LOG_LENGTH;
+
+ td->log = g_new0(struct twitter_log_data, td->log_length);
+ td->filter_log = g_new0(struct twitter_log_data, td->log_length);
td->log_id = -1;
+ td->filter_log_id = -1;
s = set_getstr(&ic->acc->set, "mode");
if (g_strcasecmp(s, "one") == 0) {
@@ -894,7 +929,7 @@ static guint64 twitter_message_id_from_command_arg(struct im_connection *ic, cha
if (arg[0] == '#') {
arg++;
}
- if (parse_int64(arg, 16, &id) && id < TWITTER_LOG_LENGTH) {
+ if (parse_int64(arg, 16, &id) && id < td->log_length) {
bu = td->log[id].bu;
id = td->log[id].id;
} else if (parse_int64(arg, 10, &id)) {
@@ -985,7 +1020,8 @@ static void twitter_handle_command(struct im_connection *ic, char *message)
twitter_report_spam(ic, screen_name);
goto eof;
- } else if (g_strcasecmp(cmd[0], "rt") == 0 && cmd[1]) {
+ } else if ((g_strcasecmp(cmd[0], "rt") == 0 ||
+ g_strcasecmp(cmd[0], "retweet") == 0) && cmd[1]) {
id = twitter_message_id_from_command_arg(ic, cmd[1], NULL);
td->last_status_id = 0;