ByteCrunch

 
 

shroudBNC & Prowl for iPhone

With Prowl you can send customized notifications over Apples Push Notification service. The main purpose is to redirect your growl notifications to your iPhone, but they also provide an api to send custom messages via http-requests.

I’ve wrote a quick & dirty tcl script for shroudBNC which forwards private messages and channel mentions to your iPhone when you’re offline.

If you are using psyBNC instead of sBNC you might be interested in this and stop wasting your time here.

You need Perl for converting whitespaces and other stuff.
Obviously you need a running sBNC installation, too.

Put the following file in the “scripts”-folder:
sbnc/scripts/prowl.tcl

internalbind server prowl:log

proc prowl:log {client parameters} {
	set prowluser "YOUR_SBNC_USERNAME"

    if {[string equal [getctx] $prowluser] && ![getbncuser $client hasclient]} {
        if {[string match -nocase *${::botnick}* [lindex $parameters 3]]} {
        	set msg "[lrange $parameters 2 2] - [lrange $parameters 0 0]: [lrange $parameters 3 end]"
	    	set msg_escaped [exec echo $msg | perl -MURI::Escape -lne "print uri_escape(\$_)"]
	    	exec wget -O /dev/null -q --no-check-certificate https://prowl.weks.net/publicapi/add?apikey=YOUR_API_KEY&priority=0&application=sBNC&event=Channel&description=$msg_escaped > /dev/null
        }
        if {[string match -nocase *${::botnick}* [lindex $parameters 2]]} {
	    	set msg "[lrange $parameters 0 0]: [lrange $parameters 3 end]"
	    	set msg_escaped [exec echo $msg | perl -MURI::Escape -lne "print uri_escape(\$_)"]
	    	exec wget -O /dev/null -q --no-check-certificate https://prowl.weks.net/publicapi/add?apikey=YOUR_API_KEY&priority=0&application=sBNC&event=Qry&description=$msg_escaped > /dev/null
        }
    }
}


Don’t forget to replace YOUR_SBNC_USERNAME and YOUR_API_KEY with the correct values. You can find your api key here

Now you have to include your new script:
/sbnc/sbnc.tcl
source "scripts/prowl.tcl"

Rehash your tcl engine within an irc client connected to sBNC as admin:
/msg -sbnc tcl :rehash

Disconnect from your bouncer and message yourself from another connection.

It should be working now!

Plz note: There is user management at all – but this could be easily added i.e. by a switch-statement which sets the right api key for the individual users.

Feel free to improve this script and to give feedback.


Comments