summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'jh-discord.py')
-rw-r--r--jh-discord.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/jh-discord.py b/jh-discord.py
index d9e4503..c377175 100644
--- a/jh-discord.py
+++ b/jh-discord.py
@@ -27,6 +27,14 @@ parser.add_argument(
help = 'Discord token.',
)
+parser.add_argument(
+ '-c',
+ '--print-chat',
+ dest='print_chat',
+ help = 'Prints all messages',
+ action="store_true",
+)
+
args = parser.parse_args()
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
@@ -47,8 +55,6 @@ def get_jh_reply ():
c = server.recv(1)
jh_reply += c
- print(jh_reply)
-
if ((jh_reply == b"!P \n") or (jh_reply == b"!N \n")):
is_done = True
else:
@@ -70,9 +76,25 @@ async def on_ready():
@client.event
async def on_message(message):
+ if (message.author.id == client.user.id):
+ return
+
server.sendall(b"?RLR " + bytes(message.content, "utf8") + b"\n")
result = get_jh_reply()
- print("Result: " + result)
+
+ if (args.print_chat):
+ print(
+ str(message.server)
+ + "#"
+ + str(message.channel.name)
+ + " <"
+ + str(message.author.name)
+ + "> "
+ + str(message.content)
+ )
+
+ if (len(result) > 0):
+ print("#" + str(message.channel.name) + " <- " + result)
if (len(result) > 0):
await client.send_message(message.channel, result)