From: Daniel Cordero Date: Tue, 16 Jun 2009 20:55:02 +0000 (+0059) Subject: Support for replying to notices X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/commitdiff_plain/fd562ddb1a223ca6623c05761305a103e6a85dfb?ds=sidebyside Support for replying to notices Allow the user to specify a single ID so that interfaces can show the nice "in reply to" links (or "in context" for status.net installations). --- diff --git a/bti-bashcompletion b/bti-bashcompletion index ff5d9a2..3dfdff0 100644 --- a/bti-bashcompletion +++ b/bti-bashcompletion @@ -5,10 +5,10 @@ _bti() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" if [[ "${cur}" == -* ]] ; then - COMPREPLY=( $(compgen -W "-a -A -p -P -H -b -d -v -s -n -g -h + COMPREPLY=( $(compgen -W "-a -A -p -P -H -b -d -v -s -n -g -h -r --account --action --password --proxy --host --bash \ --user --debug --dry-run --shrink-urls --page --version --verbose \ - --help" -- ${cur}) ) + --help --replyto" -- ${cur}) ) fi if [[ "${prev}" == "--host" ]] ; then diff --git a/bti.1 b/bti.1 index daeed37..64ae815 100644 --- a/bti.1 +++ b/bti.1 @@ -22,7 +22,7 @@ bti \- send a tweet to twitter\&.com or identi\&.ca from the command line .SH "SYNOPSIS" .HP \w'\fBbti\fR\ 'u -\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-action\ action\fR] [\fB\-\-user\ screenname\fR] [\fB\-\-host\ HOST_NAME\fR] [\fB\-\-proxy\ PROXY:PORT\fR] [\fB\-\-logfile\ LOGFILE\fR] [\fB\-\-config\ CONFIGFILE\fR] [\fB\-\-page\ PAGENUMBER\fR] [\fB\-\-bash\fR] [\fB\-\-shrink\-urls\fR] [\fB\-\-debug\fR] [\fB\-\-dry\-run\fR] [\fB\-\-verbose\fR] [\fB\-\-version\fR] [\fB\-\-help\fR] +\fBbti\fR [\fB\-\-account\ account\fR] [\fB\-\-password\ password\fR] [\fB\-\-action\ action\fR] [\fB\-\-user\ screenname\fR] [\fB\-\-host\ HOST_NAME\fR] [\fB\-\-proxy\ PROXY:PORT\fR] [\fB\-\-logfile\ LOGFILE\fR] [\fB\-\-config\ CONFIGFILE\fR] [\fB\-\-replyto\ ID\fR] [\fB\-\-page\ PAGENUMBER\fR] [\fB\-\-bash\fR] [\fB\-\-shrink\-urls\fR] [\fB\-\-debug\fR] [\fB\-\-dry\-run\fR] [\fB\-\-verbose\fR] [\fB\-\-version\fR] [\fB\-\-help\fR] .SH "DESCRIPTION" .PP bti sends a tweet message to twitter\&.com or identi\&.ca\&. @@ -72,6 +72,15 @@ Specify a logfile for bti to write status messages to\&. LOGFILE is in relation Specify a config file for bti to read from\&. By default, bti looks in the ~/\&.bti file for config values\&. This default location can be overridden by setting a specific file with this option\&. .RE .PP +\fB\-\-replyto ID\fR +.RS 4 +Status ID of a single post to which you want to create a threaded reply to\&. +.sp +For twitter, this is ignored unless the message starts with the @name of the owner of the post with the status ID\&. +.sp +For status\&.net, this can link any two messages into context with each other\&. Status\&.net will also link a message that contains an @name without this without regard to context\&. +.RE +.PP \fB\-\-shrink\-urls\fR .RS 4 Scans the tweet text for valid URL patterns and passes each through the supplied bti\-shrink\-urls script\&. The script will pass the URL to a web service that shrinks the URLs, making it more suitable for micro\-blogging\&. diff --git a/bti.c b/bti.c index 3987dec..ae32c37 100644 --- a/bti.c +++ b/bti.c @@ -83,6 +83,7 @@ struct session { char *hosturl; char *hostname; char *configfile; + char *replyto; int bash; int interactive; int shrink_urls; @@ -118,6 +119,7 @@ static void display_help(void) fprintf(stdout, " --host HOST\n"); fprintf(stdout, " --logfile logfile\n"); fprintf(stdout, " --config configfile\n"); + fprintf(stdout, " --replyto ID\n"); fprintf(stdout, " --shrink-urls\n"); fprintf(stdout, " --page PAGENUMBER\n"); fprintf(stdout, " --bash\n"); @@ -243,6 +245,7 @@ static void session_free(struct session *session) { if (!session) return; + free(session->replyto); free(session->password); free(session->account); free(session->tweet); @@ -467,6 +470,12 @@ static int send_request(struct session *session) CURLFORM_COPYCONTENTS, "bti", CURLFORM_END); + if (session->replyto) + curl_formadd(&formpost, &lastptr, + CURLFORM_COPYNAME, "in_reply_to_status_id", + CURLFORM_COPYCONTENTS, session->replyto, + CURLFORM_END); + curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost); slist = curl_slist_append(slist, "Expect:"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); @@ -1066,6 +1075,7 @@ int main(int argc, char *argv[], char *envp[]) { "page", 1, NULL, 'g' }, { "version", 0, NULL, 'v' }, { "config", 1, NULL, 'c' }, + { "replyto", 1, NULL, 'r' }, { } }; struct session *session; @@ -1114,7 +1124,7 @@ int main(int argc, char *argv[], char *envp[]) parse_configfile(session); while (1) { - option = getopt_long_only(argc, argv, "dp:P:H:a:A:u:c:hg:G:snVv", + option = getopt_long_only(argc, argv, "dp:P:H:a:A:u:c:hg:G:sr:nVv", options, NULL); if (option == -1) break; @@ -1136,6 +1146,10 @@ int main(int argc, char *argv[], char *envp[]) dbg("page = %d\n", page_nr); session->page = page_nr; break; + case 'r': + session->replyto = strdup(optarg); + dbg("in_reply_to_status_id = %s\n", session->replyto); + break; case 'p': if (session->password) free(session->password); diff --git a/bti.xml b/bti.xml index 58b9250..41da4d5 100644 --- a/bti.xml +++ b/bti.xml @@ -34,6 +34,7 @@ + @@ -140,6 +141,24 @@ + + + + + Status ID of a single post to which you want to create a threaded + reply to. + + + For twitter, this is ignored unless the message starts with the + @name of the owner of the post with the status ID. + + + For status.net, this can link any two messages into context with + each other. Status.net will also link a message that contains an + @name without this without regard to context. + + +