From 2248748ccb09dd25e9e4d91e062682b30b8046ee Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 6 Oct 2012 07:00:07 -0400 Subject: [PATCH] Remove a dependecy on netcat. --- irk | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/irk b/irk index 2ccab51..50ddc8f 100755 --- a/irk +++ b/irk @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env python # Illustrates how to test irkerd. # # First argument must be a channel URL. If it does not begin with "irc", @@ -6,12 +6,14 @@ # # Second argument must be a payload string. # -channel=$1 -message=$2 +import json +import socket +import sys -case $channel in -irc:*) ;; -*) channel="irc://chat.freenode.net/$channel" -esac - -echo "{\"to\":\"$channel\",\"privmsg\":\"$message\"}" | netcat localhost 6659 +s = socket.create_connection(("localhost", 6659)) +target = sys.argv[1] +if not "irc:" in target: + target = "irc://chat.freenode.net/{0}".format(target) +data = {"to": target, "privmsg" : " ".join(sys.argv[2:])} +print(json.dumps(data)) +s.sendall(json.dumps(data)) -- 2.26.2