10 assert sys.version_info >= (3, 5)
12 if len(sys.argv) != 2:
13 print("Usage: %s <channel>" % sys.argv[0])
15 fifo_dir = os.getenv('MTXBOT_FIFO_DIR', '/run/mtxbot')
16 fifo_path = "%s/%s" % (fifo_dir, sys.argv[1])
18 if not os.path.isdir(fifo_dir):
19 print("Fifo directory %s does not exist!" % fifo_dir, file=sys.stderr)
22 if not stat.S_ISFIFO( os.stat(fifo_path).st_mode ):
23 print("Channel %s does not exist!" % sys.argv[1], file=sys.stderr)
26 for i in range(0, 10):
29 fifo = posix.open(fifo_path, posix.O_WRONLY | posix.O_NONBLOCK)
30 posix.write(fifo, sys.stdin.read().encode())
33 if e.errno == errno.ENXIO:
39 print("Error posting to channel %s!" % sys.argv[1], file=sys.stderr)