#!/bin/bash

CHANNEL="$1"
URL="$2"
PID=`ps -C weechat-curses -o pid=`
PID="${PID/ /}"
kdialog -title "Post to IRC" --yesnocancel "Enter headline or excerpt?"
RETURN=$?

if [ $RETURN -eq 2 ]; then exit; fi

if [ $RETURN -eq 0 ]; then
	HEADLINE=`kdialog --title "Post to IRC" --inputbox "Enter headline or excerpt"`
	if [ $? -eq 1 ]; then exit; fi
	HEADLINE="\"$HEADLINE\" "
else
	HEADLINE=""
fi

echo "$CHANNEL *$HEADLINE$URL" > ~/.weechat/weechat_fifo_$PID

