diff --git a/.gitignore b/.gitignore index f7275bb..6f9d6b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ venv/ +*.fifo +__pycache__ diff --git a/README.md b/README.md index 5a7f590..dffd05b 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,29 @@ ircpipebot and reversebot make use of the irc module, installable with: +### Pipebot + + + +Testing + + python -u ircpipebot.py | python -u pipebot/echo_split.py + + +Closing the loop + + mkfifo pipe.fifo + cat pipe.fifo | python -u ircpipebot.py > pipe.fifo + + + cat pipe.fifo | python -u ircpipebot.py | python -u pipebot/echo_split.py > pipe.fifo + +or + + cat pipe.fifo | \ + python -u ircpipebot.py | \ + python -u pipebot/echo_split.py \ + > pipe.fifo + + + diff --git a/pipebot/echo.py b/pipebot/echo.py new file mode 100644 index 0000000..ce5f854 --- /dev/null +++ b/pipebot/echo.py @@ -0,0 +1,4 @@ +import sys + +for line in sys.stdin: + print (line) diff --git a/pipebot/echo_split.py b/pipebot/echo_split.py new file mode 100644 index 0000000..6826a57 --- /dev/null +++ b/pipebot/echo_split.py @@ -0,0 +1,7 @@ +import sys + +for line in sys.stdin: + print (line, file=sys.stderr) + time, handle, message = line.split(" ", 2) + message = message.rstrip() + print (f"At {time}, {handle} said: {message}") diff --git a/pipebot/reversebot.py b/pipebot/reversebot.py new file mode 100644 index 0000000..b284a47 --- /dev/null +++ b/pipebot/reversebot.py @@ -0,0 +1,10 @@ +import sys + +for line in sys.stdin: + print (line, file=sys.stderr) + time, handle, msg = line.split(" ", 2) + if "bot" in msg: + words = msg.split() + words.reverse() + msg = " ".join(words) + print (msg)