| 1 | #!/bin/sh |
| 2 | |
| 3 | # This file is called for every message received by libpurple clients (pidgin,finch,...) |
| 4 | # - Following env values are passed to this script: |
| 5 | # - ANSW_FROM (who sent you message) |
| 6 | # - ANSW_MSG (text of the message) |
| 7 | # - ANSW_STATUS (unique ID of status. eg.: available, away,...) |
| 8 | # - ANSW_STATUS_MSG (status message set by user) |
| 9 | # - WARNING: You should mind security (don't let attackers to execute their messages/nicks!) |
| 10 | # - Each line of output is sent as reply to that message |
| 11 | # - You can try to rewrite this script in PERL or C for better performance (or different platform) |
| 12 | # - This script have .exe suffix as i hope it can be eventualy replaced by some binary on windows |
| 13 | # |
| 14 | # Basic example can look like this: |
| 15 | # [ "$ANSW_STATUS" != 'available' ] && echo "<$ANSW_FROM> $ANSW_MSG" && echo "My status: $ANSW_STATUS_MSG"; |
| 16 | # |
| 17 | # There are lot of hacks that you can do with this simple framework if you know some scripting. eg.: |
| 18 | # - Forward your instant messages to email, SMS gateway, text-to-speach (eg. espeak) or something... |
| 19 | # - Smart auto-replying messages based on regular expressions |
| 20 | # - Remote control your music player (or anything else on your computer) using instant messages |
| 21 | # - Simple IRC/Jabber/ICQ bot (accepts PM only, you can run finch in screen on server) |
| 22 | # - Providing some service (Searching web, Weather info, System status, RPG game...) |
| 23 | # - BackDoor (even unintentional one - you've been warned) |
| 24 | # - Loging and analyzing messages |
| 25 | # - Connect IM with Arduino |
| 26 | # - Annoy everyone with spam (and probably get banned everywhere) |
| 27 | # - Anything else that you can imagine... |
| 28 | # |
| 29 | # Maybe you will want to add more hooks for receiving messages, so i've made following script |
| 30 | # - It just executes all +x files in answerscripts.d directory so you should do your magic there |
| 31 | # - To disable some of those scripts just use chmod -x script |
| 32 | |
| 33 | #legacy support, please do NOT use PURPLE_* variables in new scripts, |
| 34 | #this will be removed in future releases: |
| 35 | export PURPLE_FROM="$ANSW_FROM" |
| 36 | export PURPLE_MSG="$ANSW_MSG" |
| 37 | |
| 38 | #this should be modified to use run-parts in future: |
| 39 | dir="$(dirname "$0")"/answerscripts.d |
| 40 | if test -d "$dir"; then |
| 41 | for script in "$dir"/*; do |
| 42 | test -x "$script" && "$script" |
| 43 | done |
| 44 | fi |