Send Events to IRC

Come up with a useful post-processing script? Share it here!
Post Reply
knatsch
Newbie
Newbie
Posts: 17
Joined: April 15th, 2009, 7:23 am

Send Events to IRC

Post by knatsch »

I'm looking for a post processing script which announces finished downloads to an IRC Channel.
It also would be nice to get a message when sabnzbd started with an NZB, but AFAIK there is currently no way to launch an external script for this event?
I don't know if it is even possible to send messages from the shell to an eggdrop bot...any IRC experts here?
phrac
Newbie
Newbie
Posts: 3
Joined: February 26th, 2009, 4:09 pm

Re: Send Events to IRC

Post by phrac »

This isn't too hard of a task.  Just out of curiosity, I have created a php script that connects to IRC and then tells a bot to say something on the channel.

There are plenty of tutorials on how to connect to IRC using PHP, perl, or any other language out there and its not very hard.  It took about 20 minutes of coding to accomplish this.  I'll clean up my PHP code and post it here for others to see.
knatsch
Newbie
Newbie
Posts: 17
Joined: April 15th, 2009, 7:23 am

Re: Send Events to IRC

Post by knatsch »

Nice to hear that :) I am looking forward to your PHP!
phrac
Newbie
Newbie
Posts: 3
Joined: February 26th, 2009, 4:09 pm

Re: Send Events to IRC

Post by phrac »

Alright,

Most of this code was stolen from another website, I just adapted it a little bit.

Basically, it connect to an IRC server, waits for a response from nickserv then sends a few commands to a bot living on a channel.  It can either be an eggdrop bot or any other bot that supports the "say" command.

This script takes 1 argument, what you want it to say.  So I call this script from my post processing script like this: /usr/local/bin/botsay "file download details here"

Remember to change your PHP path and all the variables and then make the script executable.

Your bot may or may not require authentication to use the "say" command so comment out the auth line if you don't need it.

You can also comment out the echo bits in the script, they are simply there for debugging.

let me know if you need any help with this, its really pretty simple.

For some reason, the forum software wont let me use the code tag, so I have included a pastebin link:
http://pastebin.com/fed0efe4
knatsch
Newbie
Newbie
Posts: 17
Joined: April 15th, 2009, 7:23 am

Re: Send Events to IRC

Post by knatsch »

Thanks for your PHP :)
Question: Isn't this a bad solution? As I understand, the PHP connects for each message to the IRC Server just to handover the message to the eggdrop. Isn't there a way to give the message directly to the bot without joining and leaving the IRC network?
phrac
Newbie
Newbie
Posts: 3
Joined: February 26th, 2009, 4:09 pm

Re: Send Events to IRC

Post by phrac »

yeah, its probably not the best solution, but I am on a private IRC network (that I run) so I don't mind it.

If you're looking for a cleaner solution, check out this thread: http://forums.sabnzbd.org/index.php?topic=1353.0

There is a eggdrop script that can connect to sabnzbd.  I'm sure it would be easy to make it announce to the channel when a download is completed.
knatsch
Newbie
Newbie
Posts: 17
Joined: April 15th, 2009, 7:23 am

Re: Send Events to IRC

Post by knatsch »

I am now using a slightly different method I want to share.
Besides sabnzbd, a glftpd and a sitebot with zipscript is running on my box. Whenever a download finishes, sabnzbd calls my postprocessing script which starts with the following lines:

Code: Select all

#!/bin/bash
echo `date "+%a %b %e %T %Y"` USENETMESSAGE: \"$3\" >> /path/to/glftpd/ftp-data/logs/glftpd.log
This writes the event to glftpd.log which is monitored by the sitebot.

To get this event recognized by the bot, you need to add the following to /path/to/eggdrop/scripts/pzs-ng/dZSbot.conf:

Code: Select all

set msgtypes(DEFAULT)         "ADDUSER GADDUSER CHGRPADD CHGRPDEL ADDIP DELIP READDED DELUSER PURGED KILLED SYSOP BADHOSTMASK BADMSGINVITE BADPASSWORD 
BANNEDHOST DELETED LOGIN LOGOUT IPNOTADDED KILLGHOST TAGLINE TIMEOUT DEBUG INVITE MSGINVITE REQFILLED REQUEST TURGEN WHOIS USENETMESSAGE"
set disable(USENETMESSAGE)    0
set variables(USENETMESSAGE)  "%var1"
And last but not least add this line to your favorite zipscript theme, in my case /path/to/eggdrop/scripts/pzs-ng/themes/dakrer.zst:

Code: Select all

announce.USENETMESSAGE                         = "[%c4{%b{USENET}}] %var1"
haxogen
Newbie
Newbie
Posts: 1
Joined: October 26th, 2012, 4:56 pm

Re: Send Events to IRC

Post by haxogen »

This is an updated (up-fancied) version of what knatsch did in 2009.

Here is the bash script for your SABnzbd:

Code: Select all

#!/bin/bash
case $7 in
	0)
		STATUS="OK"
		;;
	1)
		STATUS="Verification failed"
		;;
	2)
		STATUS="Unpack failed"
		;;
	3)
		STATUS="Unpack+Verification failed"
		;;
	*)
		STATUS="Unknown"
		;;
esac

if [ "$5" = "*" ]; then
	CATEGORY="DEFAULT"
else
	CATEGORY=$5
fi

echo `date "+%a %b %e %T %Y"` USENETMESSAGE: \"$3\" \"$CATEGORY\" \"$6\" \"$STATUS\" >> /path/to/glftpd/ftp-data/logs/glftpd.log
This is what you need in ngBot.conf:

Code: Select all

# SABNZD 2 GLFTPD
set msgtypes(DEFAULT)         "ADDUSER GADDUSER CHGRPADD CHGRPDEL ADDIP DELIP READDED DELUSER PURGED KILLED SYSOP BADHOSTMASK BADMSGINVITE BADPASSWORD
BANNEDHOST DELETED LOGIN LOGOUT IPNOTADDED KILLGHOST TAGLINE TIMEOUT DEBUG INVITE MSGINVITE REQFILLED REQUEST TURGEN WHOIS USENETMESSAGE"
set disable(USENETMESSAGE)    0
set variables(USENETMESSAGE)  "%nzb_path %nzb_category %nzb_group %nzb_status"
And here is an excerpt from my theme:

Code: Select all

announce.USENETMESSAGE                   = "%b{%c3{NZB-DONE}} in %c8{%nzb_category} : -> %b{%c8{%nzb_path}} from %c1{%nzb_group} with %b{Post-Process: %c1{%nzb_status}} by %c1{SABnzbd}."
In the end it looks like this, when done properly:
Image

Have fun and keep glftpd alive.
henkie2
Newbie
Newbie
Posts: 1
Joined: November 16th, 2012, 10:56 pm

Re: Send Events to IRC

Post by henkie2 »

Nice update haxogen, any idee how to get this work for windows (ioftpd/eggdrop)
For some reason it wont logs on ioftpd.log (created a bat on sabnzbd/script)
*had to change some parameters
knatsch
Newbie
Newbie
Posts: 17
Joined: April 15th, 2009, 7:23 am

Re: Send Events to IRC

Post by knatsch »

Thanks for the improved version haxogen! Works perfectly ;D
Post Reply