Code Monkey home page Code Monkey logo

bti's Introduction

bti - bash twitter idiocy

Allows you to pipe your bash input to twitter in an easy and fast manner
to annoy the whole world.

See the man page bti.1 for how to use it and more information.

Be careful if you use this, it is quite easy to end up sending sensitive
data to the world with it.

USE AT YOUR OWN RISK!

Any questions, contact Greg Kroah-Hartman <[email protected]> or @gregkh
on twitter.

bti is developed using git and the tree can be found at:
	git://github.com/gregkh/bti.git
and browsed at:
	http://github.com/gregkh/bti/


About OAuth configuration

If you want to use an OAuth-enabled service (like twitter), you should
configure bti to use the consumer key and secret shipped with the source
code (check the oath.keys file).

For example, you should add the following two lines to your ~/.bti
configuration file:

---8<-------------------
# Consumer key
consumer_key=cZy8DdioswAfu3LJYg6E2w

# Consumer secret
consumer_secret=fnIGGU0T12mMWKjmThUdSeKN32NLWfmnwapwubVQ
---8<-------------------

The next time that you run bti, you will be told to visit an URL that
will provide you a PIN number. You should then input that number in the
bti prompt, and you will be given two new configuration values
(access_token_secret and access_token_key) that you need to add to your
bti configuration file to authenticate requests from bti.

bti's People

Contributors

agimenez avatar ahf avatar amir avatar anisse avatar arssivka avatar bartman avatar eddelbuettel avatar flameeyes avatar gmcharlt avatar gregkh avatar gregoa avatar grobian avatar leif81 avatar mathstuf avatar michel-slm avatar neuschaefer avatar paulrho avatar pferor avatar rrthomas avatar ruckuus avatar scop avatar siers avatar totdb avatar umonkey avatar vjsanjay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bti's Issues

Doing anything results in "unexpected document type"

I'm running Arch Linux with bti 034. I installed the package bti-git from the AUR.

$ bti
tweet: Test
unexpected document type
operation failed
$ bti --action friends
unexpected document type
unexpected document type
operation failed

My ~/bti:

account=<username>
password=<password>
host=quitter.se

Am I doing something wrong?

Proxy issue

bash version 5.1.4

bti --proxy http://127.0.0.1:xxx
or in configure file ~/.bti
proxy=http://127.0.0.1:xxx
or
http_proxy=http://127.0.0.1:xxx bti
doesn't work.
but
https_proxy=http://127.0.0.1:xxx bti
works

does not validate SSL certificates

Heya,

when using identi.ca¹, bti does not check the SSL certificate, leading to a MITM.

to reproduce:

  1. start a httpd with a random cert on port 443
  2. put "127.0.0.1 identi.ca api.identi.ca api.twitter.com twitter.com" in /etc/hosts
  3. call echo blah | bti --account a --password b --host identica

result:

127.0.0.1 - - [01/Jan/2012:22:44:04 +0100] "POST /api/statuses/update.xml HTTP/1.1" 404 1162 "-" "-"
in the access.log of the wrong identi.ca httpd :)

¹: this would apply to twitter too, ofc, here the mitm is limited to the OAuth authentication step though

Implicit linking against -ldl

bti implicitly links againt libdl.so.2 by using dlopen. This breaks in Fedora 13 and above, due to the linking policy of disallowing such implicit DSO linking. The fix is to simply add -ldl to Makefile.in's LIBS = @libs@ declaration

gcc -DPACKAGE_NAME="bti" -DPACKAGE_TARNAME="bti" -DPACKAGE_VERSION="026" -DPACKAGE_STRING="bti\ 026" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE="bti" -DVERSION="026" -DHAVE_LIBNSL=1 -DHAVE_LIBPCRE=1 -DHAVE_LIBCURL=1 -DLIBCURL_FEATURE_SSL=1 -DLIBCURL_FEATURE_IPV6=1 -DLIBCURL_FEATURE_LIBZ=1 -DLIBCURL_FEATURE_ASYNCHDNS=1 -DLIBCURL_FEATURE_IDN=1 -DLIBCURL_PROTOCOL_DICT=1 -DLIBCURL_PROTOCOL_FILE=1 -DLIBCURL_PROTOCOL_FTP=1 -DLIBCURL_PROTOCOL_FTPS=1 -DLIBCURL_PROTOCOL_HTTP=1 -DLIBCURL_PROTOCOL_HTTPS=1 -DLIBCURL_PROTOCOL_IMAP=1 -DLIBCURL_PROTOCOL_IMAPS=1 -DLIBCURL_PROTOCOL_LDAP=1 -DLIBCURL_PROTOCOL_LDAPS=1 -DLIBCURL_PROTOCOL_POP3=1 -DLIBCURL_PROTOCOL_POP3S=1 -DLIBCURL_PROTOCOL_RTSP=1 -DLIBCURL_PROTOCOL_SCP=1 -DLIBCURL_PROTOCOL_SFTP=1 -DLIBCURL_PROTOCOL_SMTP=1 -DLIBCURL_PROTOCOL_SMTPS=1 -DLIBCURL_PROTOCOL_TELNET=1 -DLIBCURL_PROTOCOL_TFTP=1 -I. -I/usr/include/readline5 -I/usr/include/libxml2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -c bti.c
bti.c: In function 'parse_configfile':
bti.c:554: warning: unused variable 'file'
CCLD bti
/usr/bin/ld: bti.o: undefined reference to symbol 'dlopen@@GLIBC_2.1'
/usr/bin/ld: note: 'dlopen@@GLIBC_2.1' is defined in DSO /lib/libdl.so.2 so try adding it to the linker command line
/lib/libdl.so.2: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make: *** [bti] Error 1

Color support

Thank you for providing us so good software.
While using bti, I find it's hard to identify userid/search words in flood of characters printted on screen. So I just wonder is it possible to a colorfy the output just like ls --autocolor

HTTP Basic Auth and identi.ca

Is basic auth known to be broken with identi.ca? The last time I had a successful post was with bti 028 a few months ago. I've not tested it since until bti 029 came out, and with both 029 and 030 I get the following with --debug (file attached)

bti uses old pcre library

We have the following bug report in Debian:
https://bugs.debian.org/1000121

Summary: bti uses the old pcre library which is supposed to be faded out in Debian as it's EOL. The maintainer suggests to port bti to the currently maintained pcre2 library.

Cheers,
gregor

error retrieving from URL https://api.twitter.com

Have been using bti for many years with great success. But since a couple of days I'm getting following errors:

echo "test" | bti --action update --debug --verbose

bti - version 034
bti: main: tweet = test
bti: main: config file = /root/.bti
bti: main: host = 0
bti: main: action = 0
bti: send_request: https://api.twitter.com/1.1/statuses/update.json?status=test
bti: send_request: req_url:https://api.twitter.com/1.1/statuses/update.json
bti: send_request: reply:(null)
Error retrieving from URL (https://api.twitter.com/1.1/statuses/update.json?status=test)
operation failed

Any idea what's going on?

Regards,
Allard Munters
Netherlands

Change at Twitter?

I am using bti in a cronjob which tweets pretty regularly. This stopped to work a few hours ago. The account is fine -- could something have changed at their end? Is it a regular garden-variety outage?

Dirk

oauth_split_url_parameters returns 5

I can't login using oauth. I created config file with consumer's keys from README file.
Program requested me to enter PIN from url which was printed at line above. After entering pin program do nothing. Debugging step-by-step showed me where program has incorrect behavior. In my case function oauth_split_url_parameters writes into rc value 5 in function parse_osp_reply (line 740), but case for 5 don't exists and program exits, but I had correct responce.

033 and identi.ca

The changes in 033 for the Twitter API v1.1 are not good for identi.ca. Posting still works (if one ignores the "operation failed" message with exit code 234). Retrieving with -'-action friends --debug' shows returned JSON but no output and again "operation failed"/234).

OTOH I don't know if it's worth to investigate since identi.ca is supposed to switch to pump.io Any Day Now (since 4 weeks). Not sure about other statusnet instances ...

error condition detected: 89 = Invalid or expired token.

251 jacobtey@jacobtey-laptop ~ % bti --debug
bti: session_readline_init: Using libreadline.so for readline library
bti - version 034
tweet: Hello
bti: main: tweet = Hello
bti: main: config file = /home/jacobtey/.bti
bti: main: host = 0
bti: main: action = 0
bti: send_request: https://api.twitter.com/1.1/statuses/update.json?status=Hello
bti: send_request: req_url:https://api.twitter.com/1.1/statuses/update.json
bti: send_request: reply:{"errors":[{"code":89,"message":"Invalid or expired token."}]}
bti: parse_response_json: Got this json response:
bti: parse_response_json: {"errors":[{"code":89,"message":"Invalid or expired token."}]}
key errors json_type_array, Array Length: 1
element[0]
key code int value: 89
(errors->[]->code)
key message string value: Invalid or expired token.
(errors->[]->message)
Got an error code:
code=89
message=Invalid or expired token.
error condition detected: 89 = Invalid or expired token.
operation failed

xsltproc error

The following error occurred during Make.
How can I resolve it?

/usr/bin/xsltproc -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl bti.xml

I/O error : Attempt to load network entity http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
make: *** [bti.1] Error 4

Environment:

$ uname -a
Linux 2.6.35.14-96.fc14.i686 #1 SMP Thu Sep 1 12:49:38 UTC 2011 i686 i686 i386 GNU/Linux

$ xsltproc -V
Using libxml 20707, libxslt 10126 and libexslt 815
xsltproc was compiled against libxml 20707, libxslt 10126 and libexslt 815
libxslt 10126 was compiled against libxml 20707
libexslt 815 was compiled against libxml 20707

identi.ca still mentioned in some places

From a quick grep over 034 for identi.ca and statusnet:

README:bti - bash twitter/identi.ca ididocy
README:Allows you to pipe your bash input to twitter or identi.ca in an easy
README:on twitter or identi.ca.
bti.c:  fprintf(stdout, "bti - send tweet to twitter or identi.ca\n"
bti.c:          fprintf(stderr, "Groups only work in Identi.ca.\n");
bti.c:static const char group_uri[]    = "/../statusnet/groups/timeline/";
bti.example:host=identica
bti.example:# Example of a custom StatusNet installation

(And in bti.c, probably all stuff for groups and for hosts != HOSTS_TWITTER can be removed as well.)

installing issue with JSON-C

Whe I try to ./configure I get this error. I can't find what to do on the web. Thanks in advance por your help (I'm using Ubuntu 12.10):

checking for JSON... no
configure: error: Package requirements (json-c) were not met:

No package 'json-c' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables JSON_CFLAGS
and JSON_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

Buffer overflow

I've installed bti on my (arch linux) machine from the official arch repos.
My bti config contains the consumer key and secret, my twitter account name and plain-text password (not a fan of that!), shrink-urls set to yes, shrink_host set to bit.ly, and my bitly login and key.
I've ran bti once to authenticate with twitter, both it and bitly show up under applications I have authorized in my twitter settings. Today I tried tweeting with it and it crashed from a buffer overflow.

log:
https://gist.github.com/miotatsu/7156091eb144bce002e94d010696b322

Patch to support extended tweets

This is a patch to bti.c to accept the new, longer tweets.

diff --git a/bti.c b/bti.c
index 7f485a8..a4316d3 100644
--- a/bti.c
+++ b/bti.c
@@ -572,7 +572,7 @@ static void json_interpret(json_object *jobj, int nestlevel)
 				printf("%s : %s\n", keystack[2], json_object_get_string(jobj));
 			tweetdetail.created_at = (char *)json_object_get_string(jobj);
 		}
-		if (strcmp(keystack[2], "text") == 0) {
+		if (strcmp(keystack[2], "full_text") == 0 || strcmp(keystack[2], "text") == 0) {
 			if (debug)
 				printf("%s : %s\n", keystack[2], json_object_get_string(jobj));
 			tweetdetail.text = (char *)json_object_get_string(jobj);
@@ -933,7 +933,7 @@ static int send_request(struct session *session)
 		case ACTION_FRIENDS:
 			snprintf(user_password, sizeof(user_password), "%s:%s",
 				 session->account, session->password);
-			snprintf(endpoint, endpoint_size, "%s%s?page=%d", session->hosturl,
+			snprintf(endpoint, endpoint_size, "%s%s?tweet_mode=extended&page=%d", session->hosturl,
 					friends_uri, session->page);
 			curl_easy_setopt(curl, CURLOPT_URL, endpoint);
 			curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
@@ -948,7 +948,7 @@ static int send_request(struct session *session)
 		case ACTION_REPLIES:
 			snprintf(user_password, sizeof(user_password), "%s:%s",
 				 session->account, session->password);
-			snprintf(endpoint, endpoint_size, "%s%s?page=%d", session->hosturl,
+			snprintf(endpoint, endpoint_size, "%s%s?tweet_mode=extended&page=%d", session->hosturl,
 				replies_uri, session->page);
 			curl_easy_setopt(curl, CURLOPT_URL, endpoint);
 			curl_easy_setopt(curl, CURLOPT_USERPWD, user_password);
@@ -1069,7 +1069,7 @@ static int send_request(struct session *session)
 				session->page);
 			break;
 		case ACTION_REPLIES:
-			sprintf(endpoint, "%s%s?page=%d", session->hosturl,
+			sprintf(endpoint, "%s%s?tweet_mode=extended&page=%d", session->hosturl,
 				mentions_uri, session->page);
 			break;
 		case ACTION_PUBLIC:
@@ -1077,7 +1077,7 @@ static int send_request(struct session *session)
 				public_uri);
 			break;
 		case ACTION_FRIENDS:
-			sprintf(endpoint, "%s%s?page=%d", session->hosturl,
+			sprintf(endpoint, "%s%s?tweet_mode=extended&page=%d", session->hosturl,
 				friends_uri, session->page);
 			break;
 		case ACTION_RETWEET:


Action "public" not very useful ...

We received the following but report in the Debian BTS:

https://bugs.debian.org/787961

The author points out that "--action public" never outputs anything while creating constant network traffic.

AFAICS, the public actions uses the streaming endpoint, so maybe bti at some point needs to stop reading from the stream and/or start outputting contents after some time?

Cheers,
gregor

Twitter API change to 1.1

It seems bti doesn't support the newer twitter API 1.1. Twitter stopped accepting requests with the old API.

$ ./bti --debug
bti: session_readline_init: Using libreadline.so.6 for readline library
bti - version 032
tweet: test
bti: main: tweet = test
bti: main: config file = /home/jes/.bti
bti: main: host = 0
bti: main: action = 0
bti: send_request: https://api.twitter.com/1/statuses/update.xml?status=test
bti: send_request: https://api.twitter.com/1/statuses/update.xml
bti: send_request: The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.

Are there plans to migrate bti to twitter API 1.1?

  • Frank

Do multiline tweet!

Hi! I'm trying to post a multiline tweet using:

#$msg = string with \n
echo "$msg" | bti

But the result is a tweet with just the first line. If message is "Hi!\nHow are you?", bti posts only "Hi!".
Is it a feature that bti lacks support of? Or already there's a way to post multiline tweets?

bti should terminate with an error if the --config file can't be read

[This is forwarded from http://bugs.debian.org/669192]

Currently, if a file specified with the --config option can't be read
(either because it doesn't exist or due to insufficient permissions),
it is ignored:

$ bti --config does-not-exist
Twitter no longer supports HTTP basic authentication.
Both consumer key, and consumer secret are required for bti in order to behave as an OAuth consumer.

This is bad because if, for instance, a ~/.bti file exists and has
a configuration for Twitter, and the file designated by the --config
option is supposed to have a configuration to use Identi.ca, this
means that Twitter will be used unexpectedly. In order to avoid using
a different service (or different account) from expected by mistake,
bti should return with an error as soon as it can't read the specified
config file.

Note: when fixing this bug, make sure that a missing ~/.bti file has
no effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.