My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# twimi (c) Lukasz Grzegorz Maciak

#----------------------------------------------------------------------
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#----------------------------------------------------------------------

ver="0.4.0"

# you can set this to figlet, toilet, cowsay or whatever
whatlet='figlet'

# check if a config file exists, and create one if it does not
if [[ ! -a ~/.twimi ]]; then
echo "Twimi will store your username and password in ~/.twimi"
read -p "username: " -e username
read -p "password: " -e password
echo "Thanks! Writing ~/.twimi"

# if base64 is installed, use it to encrypt password
if [[ -x "/usr/bin/base64" ]]; then
b64psw=$(echo $password | base64)
else
# fall back to plain text
b64psw=$password
fi

echo "username=\"$username\"" >> ~/.twimi
echo "password=\"$b64psw\"" >> ~/.twimi
fi

# load username and password from the config file
source ~/.twimi

# decode password (if base64 is present - else leave it alone)
if [[ -x "/usr/bin/base64" ]]; then password=$(echo $password | base64 -d); fi

# check if curl is installed
if [[ ! -x "/usr/bin/curl" ]]; then
echo "Twim requires curl to be installed"
exit 1
fi

last=""

while [ 0 -le 1 ]
do
clear
echo ""

# display the name in funky text (will be ignored if figlet is missing)
if [[ -x "/usr/bin/$whatlet" ]]; then $whatlet twimi; fi

echo "twimi (c) Lukasz Grzegorz Maciak"
echo ""
echo "[~] $last"

# fetch the most recent twit from your friends list
tmp=$(curl -s --basic --user $username:$password http://twitter.com/statuses/friends_timeline.xml?count=1)

if [[ $tmp =~ \<screen_name\>(.*)\<\/screen_name\> ]]; then sn=${BASH_REMATCH[1]}; fi
if [[ $tmp =~ \<text\>(.*)\<\/text\> ]]; then tx=${BASH_REMATCH[1]}; fi
if [[ $tmp =~ \<created_at\>(.*)\<\/created_at\> ]]; then ct=${BASH_REMATCH[1]}; ct=$(date +"%m/%d/%Y %l:%m %p" -d "$ct"); fi

echo "[F] $ct > [$sn]: $tx"

echo ""

read -p "What are you doing? " -e input

if [ "$input" = "/quit" ]; then break; fi

if [ "$input" = "/help" ]; then
clear
echo ""
if [[ -x "/usr/bin/$whatlet" ]]; then
$whatlet twimi $ver;
fi

echo "twimi $ver"

echo ""
echo "/quit to exit"
echo "/help to see this message"
echo ""
echo "Hit ENTER to continue"
read
continue;
fi

curl -s --basic --user $username:$password --data status="$input" --data source="twimi" http://twitter.com/statuses/update.xml > /dev/null

if [[ "$?" == 0 ]]; then
d=`date +"%m/%d/%Y %l:%m %p"`
last="$d > $input"
else
if [[ -x "/usr/bin/$whatlet" ]]; then $whatlet Error; fi
echo "Oops! Something went wrong. Maybe your internet is down, or maybe Twitter is."
read
fi
done
Show details Hide details

Change log

r10 by maciakl on Sep 10, 2008   Diff
1. discovered that Ubuntu does not have
base64 in it's coreutils package so I
added a fallback mechanism that will use
plain text if the package is not present.

2. Twimi will now query your friend list
for the latest update and display it on
the screen
Go to: 
Project members, sign in to write a code review

Older revisions

r9 by maciakl on Sep 09, 2008   Diff
Added base64 encoding for the password
so that it is not stored in plain text
r8 by maciakl on Aug 28, 2008   Diff
Forgot to increment version
r7 by maciakl on Aug 28, 2008   Diff
Fixed 1 typo in the /help section
All revisions of this file

File info

Size: 3272 bytes, 112 lines

File properties

svn:executable
*
Hosted by Google Code