- Timestamp:
- 2015-01-26T07:50:54Z (10 years ago)
- Branches:
- master
- Children:
- 12fe5ea
- Parents:
- dfaa46d
- git-author:
- William Pettersson <william.pettersson@…> (11-01-15 05:08:37)
- git-committer:
- dequis <dx@…> (26-01-15 07:50:54)
- Location:
- protocols/twitter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/twitter/twitter.c
rdfaa46d rce402b2 539 539 540 540 s = set_add(&acc->set, "strip_newlines", "false", set_eval_bool, acc); 541 542 s = set_add(&acc->set, "format_string", "\002[\002%i\002]\002 %c", NULL, acc); 543 s = set_add(&acc->set, "retweet_format_string", "\002[\002%i\002]\002 RT @%a: %c", NULL, acc); 544 s = set_add(&acc->set, "reply_format_string", "\002[\002%i->%r\002]\002 %c", NULL, acc); 541 545 542 546 s = set_add(&acc->set, "_last_tweet", "0", NULL, acc); -
protocols/twitter/twitter_lib.c
rdfaa46d rce402b2 63 63 guint64 reply_to; 64 64 gboolean from_filter; 65 struct twitter_xml_status *rt; 65 66 }; 66 67 … … 88 89 g_free(txs->text); 89 90 txu_free(txs->user); 91 txs_free(txs->rt); 90 92 g_free(txs); 91 93 } … … 489 491 if (rtxs) { 490 492 g_free(txs->text); 491 txs->text = g_strdup _printf("RT @%s: %s", rtxs->user->screen_name,rtxs->text);493 txs->text = g_strdup(rtxs->text); 492 494 txs->id = rtxs->id; 493 txs _free(rtxs);495 txs->rt = rtxs; 494 496 } 495 497 } else if (entities) { … … 609 611 } 610 612 613 /** 614 * Function to properly format a tweet as per the users configuration. 615 */ 616 static char *twitter_msg_get_text(struct im_connection *ic, int log_id, int reply_to, 617 struct twitter_xml_status *txs, const char *prefix) { 618 gchar * format = set_getstr(&ic->acc->set, "format_string"); 619 GString * text = g_string_new(NULL); 620 621 gchar *c; 622 if (reply_to != -1) 623 format = set_getstr(&ic->acc->set, "reply_format_string"); 624 if (txs->rt) 625 format = set_getstr(&ic->acc->set, "retweet_format_string"); 626 627 for (c = format; *c ; c++) { 628 if (!(*c == '%' && *(c+1))) { 629 text = g_string_append_c(text, *c); 630 continue; 631 } 632 c++; // Move past the % 633 switch (*c) { 634 case 'i': 635 g_string_append_printf(text, "%02x", log_id); 636 break; 637 case 'r': 638 if (reply_to != -1) // In case someone does put %r in the wrong format_string 639 g_string_append_printf(text, "%02x", reply_to); 640 break; 641 case 'a': 642 if (txs->rt) // In case someone does put %a in the wrong format_string 643 text = g_string_append(text, txs->rt->user->screen_name); 644 break; 645 case 'c': 646 text = g_string_append(text, txs->text); 647 break; 648 default: 649 text = g_string_append_c(text, *c); 650 } 651 } 652 text = g_string_prepend(text, prefix); 653 return g_string_free(text, FALSE); 654 } 655 611 656 /* Will log messages either way. Need to keep track of IDs for stream deduping. 612 657 Plus, show_ids is on by default and I don't see why anyone would disable it. */ … … 647 692 td->log[td->log_id].id = txs->rt_id; 648 693 649 if (set_getbool(&ic->acc->set, "show_ids")) { 650 if (reply_to != -1) 651 return g_strdup_printf("\002[\002%02x->%02x\002]\002 %s%s", 652 td->log_id, reply_to, prefix, txs->text); 653 else 654 return g_strdup_printf("\002[\002%02x\002]\002 %s%s", 655 td->log_id, prefix, txs->text); 656 } else { 657 if (*prefix) 658 return g_strconcat(prefix, txs->text, NULL); 659 else 660 return NULL; 661 } 694 return twitter_msg_get_text(ic, td->log_id, reply_to, txs, prefix); 662 695 } 663 696
Note: See TracChangeset
for help on using the changeset viewer.