projects
/
irker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7907f46
)
Some feature enhancements for irk.
author
Eric S. Raymond
<esr@thyrsus.com>
Sun, 7 Oct 2012 07:23:33 +0000
(
03:23
-0400)
committer
Eric S. Raymond
<esr@thyrsus.com>
Sun, 7 Oct 2012 07:23:33 +0000
(
03:23
-0400)
irk
patch
|
blob
|
history
diff --git
a/irk
b/irk
index 50ddc8fbc82b3f4321df7fa6122a8926b959c5d1..320787ebc366b5e4db6026ead9210ac63249ac0f 100755
(executable)
--- a/
irk
+++ b/
irk
@@
-4,16
+4,22
@@
# First argument must be a channel URL. If it does not begin with "irc",
# the base URL for freenode is prepended.
#
# First argument must be a channel URL. If it does not begin with "irc",
# the base URL for freenode is prepended.
#
-# Second argument must be a payload string.
+# Second argument must be a payload string. Standard C-style escapes
+# such as \n and \t are decoded.
#
import json
import socket
import sys
#
import json
import socket
import sys
-s = socket.create_connection(("localhost", 6659))
target = sys.argv[1]
if not "irc:" in target:
target = "irc://chat.freenode.net/{0}".format(target)
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:])}
+message = " ".join(sys.argv[2:])
+message = message.decode('string_escape')
+data = {"to": target, "privmsg" : message}
print(json.dumps(data))
print(json.dumps(data))
-s.sendall(json.dumps(data))
+try:
+ s = socket.create_connection(("localhost", 6659))
+ s.sendall(json.dumps(data))
+except socket.error, e:
+ sys.stderr.write("irkerd: server launch failed: %r\n" % e)