summaryrefslogtreecommitdiff |
path: root/jh-discord.py
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-27 12:57:37 +0100 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2019-01-27 12:57:37 +0100 |
commit | 387fd50f7d727ecf9c2df21ef6ed9d134b21324a (patch) | |
tree | cb612034f1c8d6451876f28900ee4a5e4fb85f82 /jh-discord.py | |
parent | dab473ce6eca4788dbec6c7d41649ff26a0d0799 (diff) |
No longer respond to its own messages, chat log.
Diffstat (limited to 'jh-discord.py')
-rw-r--r-- | jh-discord.py | 28 |
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) |