Difference between revisions of "Events"
m (inserted link to nds) |
|||
| Line 17: | Line 17: | ||
=== Download completed === | === Download completed === | ||
| − | When a Download completed event is triggered, | + | When a Download completed event is triggered, the following variables can be accessed: |
* %NAME - the name of the downloaded file with full path | * %NAME - the name of the downloaded file with full path | ||
* %FILE - the name of the downloaded file without path | * %FILE - the name of the downloaded file without path | ||
* %HASH - the ed2k hash of the downloaded file | * %HASH - the ed2k hash of the downloaded file | ||
* %SIZE - the size in bytes of the downloaded file | * %SIZE - the size in bytes of the downloaded file | ||
| + | * %DLACTIVETIME - the total time the download was active | ||
=== New chat session === | === New chat session === | ||
| Line 52: | Line 53: | ||
# Used in conjuction with aMule's Event feature | # Used in conjuction with aMule's Event feature | ||
# | # | ||
| − | # Call like this: doneDL.sh "%NAME" "%FILE" %HASH %SIZE | + | # Call like this: doneDL.sh "%NAME" "%FILE" %HASH %SIZE %DLACTIVETIME |
# | # | ||
# Enter your email address here: | # Enter your email address here: | ||
| Line 61: | Line 62: | ||
Hash=$3 | Hash=$3 | ||
Size=$4 | Size=$4 | ||
| + | DlActiveTime=$5 | ||
{ | { | ||
echo aMule completed this download: | echo aMule completed this download: | ||
| Line 71: | Line 73: | ||
echo -n Size: $Size bytes | echo -n Size: $Size bytes | ||
if [ $Size -gt 102400 ] ; then echo " ("$(($(($Size / 1024)) / 1024)) "Mb)" ; fi | if [ $Size -gt 102400 ] ; then echo " ("$(($(($Size / 1024)) / 1024)) "Mb)" ; fi | ||
| + | echo Dowload Active Time: $DlActiveTime | ||
echo | echo | ||
echo -------------------------------------------------------------------- | echo -------------------------------------------------------------------- | ||
Revision as of 20:07, 2 December 2006
Events are actions aMule can take upon when certain things happen. This actions can be configured on the Events tab of the Usage_Preferences notebook.
There are two kinds of Events supported at the moment:
- Download completed
- New chat session
When one of these events is triggered, you can configure aMule to execute a
- core command
- GUI command
A core command is a command that will be executed by a flavor of aMule that has a core (aMule daemon or aMule monolithic). A GUI command is a command that will be executed by a flavor of aMule that has GUI (aMule GUI or aMule monolithic). Notice that if you specify both, aMule monolithic will execute both.
Download completed
When a Download completed event is triggered, the following variables can be accessed:
- %NAME - the name of the downloaded file with full path
- %FILE - the name of the downloaded file without path
- %HASH - the ed2k hash of the downloaded file
- %SIZE - the size in bytes of the downloaded file
- %DLACTIVETIME - the total time the download was active
New chat session
When a New chat session event is triggered, one variable can be accessed:
- %Sender - username of the person initiating the chat
Syntax
To call an external script, enter the script name in the core command field, followed by the optional variables. For example:
- MyScript.sh %NAME %FILE %HASH %SIZE
Note: If the filename contains spaces, the variable names should be enclosed in quotes like this:
- MyScript.sh "%NAME" "%FILE" %HASH %SIZE
You need to make sure your script in your PATH or that you supply the pathname.
Examples
Here the bash script by Ezeltje from aMule-Forum which will send you an email every time a download is completed. To use it, enter your email address where indicated and save it to a location in your PATH. Then add this line:
- doneDL.sh "%NAME" "%FILE" %HASH %SIZE
to the Core command field of the Download completed section of the Events page. It will now be invoked everytime aMule finishes a download.
#!/bin/bash
#
# doneDL.sh - sends an email upon completion of an aMule download
# Used in conjuction with aMule's Event feature
#
# Call like this: doneDL.sh "%NAME" "%FILE" %HASH %SIZE %DLACTIVETIME
#
# Enter your email address here:
eMail=
#
NameShort=$1
NameLong=$2
Hash=$3
Size=$4
DlActiveTime=$5
{
echo aMule completed this download:
echo ------------------------------
echo
echo File: "$NameLong"
echo Hash: $Hash
echo -n "Time: "
date | awk '{print $4 " " $5}'
echo -n Size: $Size bytes
if [ $Size -gt 102400 ] ; then echo " ("$(($(($Size / 1024)) / 1024)) "Mb)" ; fi
echo Dowload Active Time: $DlActiveTime
echo
echo --------------------------------------------------------------------
cas
echo -n "Resident memory: "
echo $(ps u -C amule --no-headers | awk '{print $6}') kB
echo -n "Virtual memory: "
echo $(ps u -C amule --no-headers | awk '{print $5}') kB
echo --------------------------------------------------------------------
} | mail -s "$NameShort" $eMail