Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Add stdin support to harold-irc command.
Browse files Browse the repository at this point in the history
  • Loading branch information
spladug committed Jun 26, 2012
1 parent 361655b commit 2eecb7a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions wessex.py
Expand Up @@ -147,13 +147,21 @@ def harold_irc():

parser = argparse.ArgumentParser(description="Send a message to an IRC channel via Harold.")
parser.add_argument("channel", nargs=1, help="IRC channel to send message to")
parser.add_argument("message", nargs="+", help="Message to send.")
parser.add_argument("message", nargs="*", help="Message to send.")
args = parser.parse_args()

try:
harold = connect_harold()
channel = harold.get_irc_channel(args.channel[0])
channel.message(" ".join(args.message))

if args.message:
channel.message(" ".join(args.message))
else:
while True:
line = sys.stdin.readline()
if not line:
break
channel.message(line)
except Exception, e:
print "%s: %s" % (os.path.basename(sys.argv[0]), e)
return 1
Expand Down

0 comments on commit 2eecb7a

Please sign in to comment.