@Echo OFF ::::: ASSUME: %USERNAME is set - allows married couples to use the same script with different usernames ::::: USAGE: twitter [what to twitter] - It is far better to just "twitter", and follow the input prompt, because twittering from the command-line can cause weirdness related to command-line parameter processing ::::: If you change MAX_TWITTER_LENGTH, you want to edit the dummy twitter's length later as well: set MAX_TWITTER_LENGTH=140 ::::: Ensure %USERNAME is set: call checkusername ::::: Get twitter if none given at command line: if "%1"=="" goto :prompt_for_twitter goto :get_twitter_from_command_line :prompt_for_twitter echo Enter your twitter (%MAX_TWITTER_LENGTH characters max): echo. ::::: Dummy twitter: We make a fake 140-line twitter, so that as we type, we can see how much space we have left. This is a luxury, not a necesity. set TWITTER=. . eset TWITTER goto :%USERNAME :get_twitter_from_command_line set TWITTER=%& ::::: Must notice if commas were taken out, which they would be: eset TWITTER :echo DEBUG ABORT! :) %+ goto :END ::::: For married couples, this lets us set username and password for 2 different accounts: goto :%USERNAME ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :HUSBAND_USER_NAME set TMPUSERNAME=HUSBAND_USER_NAME set TMPPASSWORD=HUSBAND_PASSWORD goto :checkLength :WIFE_USER_NAME set TMPUSERNAME=WIFE_USER_NAME set TMPPASSWORD=WIFE_PASSWORD goto :checkLength ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::: If the twitter is too long, tell them. Keep looping until it is short enough: :checkLength set LENGTH=%@LEN[%TWITTER] if %LENGTH gt %MAX_TWITTER_LENGTH goto :too_long goto :twitter :too_long echo. echo The maximum length of a twitter is %MAX_TWITTER_LENGTH characters echo Your twitter is too long -- %LENGTH characters echo Please fix: eset TWITTER goto :checkLength ::::: Save the twitter to an internal log file: :twitter ::::: my own internal log file: echo %TWITTER >>%BAT\twitter-%TMPUSERNAME.log echo. ::::: Ask if we should crosspost to LiveJournal: echos LiveJournal post? [Y/n] inkey /c /k"yn[Enter]" %%LJCP echo. if "%LJCP"=="y" .OR. "%@ASCII[%LJCP]"=="64 50 56" goto :LJYes goto :LJNo :LJYes ::::: Livejournal likes to know music and mood, so we get those and set environment variables %MUSIC and %MOOD, to be used by LJTwitter.pl: call get-currently-playing-music echo. call get-current-mood echo. ::::: We can press "Y" to go to the 2 sites we just posted content to.... echos Go to LiveJournal? [Y/n] inkey /c /k"yn[Enter]" %%LJGO :LJNo echos Go to Twitter? [y/N] inkey /c /k"yn[Enter]" %%KEY echo. ::::: Actually submit the actual twitter to Twitter.com: :OLD: doesn't work with ampersands: curl --basic --user "%TMPUSERNAME:%TMPPASSWORD" --data-ascii "status=%TWITTER" "http://twitter.com/statuses/update.json" :NEW: twitter.pl ::::: Now that we have sent our twitter out, go to Twitter / Post to LJ / go to LJ, depending on how the user answered above prompts: if "%KEY"=="y" http://twitter.com/%TMPUSERNAME/with_friends if "%LJCP"=="y" .OR. "%@ASCII[%LJCP]"=="64 50 56" ljtwitter.pl %TWITTER if "%LJGO"=="y" .OR. "%@ASCII[%LJGO]"=="64 50 56" http://%TMPUSERNAME.livejournal.com echo. goto :END ::::: Clean up and unset environment variables: :END unset /q LJGO unset /q LJCP unset /q KEY unset /q TMPUSERNAME unset /q TMPPASSWORD unset /q MAX_TWITTER_LENGTH unset /q LENGTH unset /q TWITTER