X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=purple%2Fanswerscripts.sh;h=3b72f961a438905d4ff97246aae90e2777e110b8;hb=b1866b8c5dc9289d195f78dd77c6007131781d14;hp=4dc0e8abc244928a48f588e5b29803677b74d4b4;hpb=2bcad731832754d3f67219355f1a9878bd38e27d;p=mirrors%2Flibpurple-core-answerscripts.git diff --git a/purple/answerscripts.sh b/purple/answerscripts.sh index 4dc0e8a..3b72f96 100755 --- a/purple/answerscripts.sh +++ b/purple/answerscripts.sh @@ -1,32 +1,9 @@ -#!/bin/sh - +#!/bin/bash +# # This file is called for every message received by libpurple clients (pidgin,finch,...) -# - Following env values are passed to this script: -# - ANSW_MSG (text of the message) -# - ANSW_FROM (who sent you message) -# - ANSW_PROTOCOL (protocol used to deliver the message. eg.: jabber, irc,...) -# - ANSW_STATUS (unique ID of status. eg.: available, away,...) -# - ANSW_STATUS_MSG (status message set by user) -# - WARNING: You should mind security (don't let attackers to execute their messages/nicks!) -# - Each line of output is sent as reply to that message -# - You can try to rewrite this script in PERL or C for better performance (or different platform) +# - You can try to rewrite this script in PERL or C for better performance (or different platform) - let me know # - On M$ Windows answerscripts.exe from libpurple directory will be called instead of this script # -# Basic example can look like this: -# [ "$ANSW_STATUS" != 'available' ] && echo "<$ANSW_FROM> $ANSW_MSG" && echo "My status: $ANSW_STATUS_MSG"; -# -# There are lot of hacks that you can do with this simple framework if you know some scripting. eg.: -# - Forward your instant messages to email, SMS gateway, text-to-speach (eg. espeak) or something... -# - Smart auto-replying messages based on regular expressions -# - Remote control your music player (or anything else on your computer) using instant messages -# - Simple IRC/Jabber/ICQ bot (accepts PM only, you can run finch in screen on server) -# - Providing some service (Searching web, Weather info, System status, RPG game...) -# - BackDoor (even unintentional one - you've been warned) -# - Loging and analyzing messages -# - Connect IM with Arduino -# - Annoy everyone with spam (and probably get banned everywhere) -# - Anything else that you can imagine... -# # Maybe you will want to add more hooks for receiving messages, so i've made following script # - It just executes all +x files in answerscripts.d directory so you should do your magic there # - To disable some of those scripts simply use: chmod -x ./script @@ -35,16 +12,11 @@ # - AB?!_ scripts without numbers are NOT executed! # - 00 executed immediately, zero or single line output (parallel async processing) # - 01-48 executed immediately, multiline output (serial processing) -# - 49 delay script (adds random delay to emulate human factor) +# - 49 delay script (adds random delay to emulate human factor, no user scripts at this level!) # - 50 executed after delay, zero or single line output (parallel async processing) # - 51-79 executed after delay, multiline output (serial processing) # - 80-99 reserved for future -#legacy support, please do NOT use PURPLE_* variables in new scripts, -#this will be removed in future releases: -export PURPLE_FROM="$ANSW_FROM" -export PURPLE_MSG="$ANSW_MSG" - #this may be modified to use run-parts from coreutils in future (can't get it to work): dir="$(dirname "$0")"; cd "$dir" #chdir to ~/.purple/ or similar @@ -54,7 +26,8 @@ if test -d "$dir"; then #sleep at 49 (this can be replaced by 49-delay.sh, but this should be faster) [ $i -eq 49 ] && { - sleep $[ 2 + ($RANDOM % 8) ]; #2-9 seconds of sleep + find "$dir"/[5-9][0-9]-* -executable | grep . >/dev/null && #check if it's worth waiting + sleep $(( 2 + ($RANDOM % 8) )); #2-9 seconds of sleep continue; }