summaryrefslogtreecommitdiff |
path: root/jh-discord.py
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-07-27 13:46:29 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2020-07-27 13:46:29 +0200 |
commit | d47ad50a03fecbafe87514d2a601f1073c121147 (patch) | |
tree | c237c7bee70669f3c25e9eda9dee21674f2e0526 /jh-discord.py | |
parent | 72ef0918580d015d11c4fc464a424e6411dfdc3d (diff) |
Adds a new parameter to use msg author instead.
Diffstat (limited to 'jh-discord.py')
-rw-r--r-- | jh-discord.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/jh-discord.py b/jh-discord.py index af849c3..24ef483 100644 --- a/jh-discord.py +++ b/jh-discord.py @@ -3,6 +3,7 @@ import asyncio import argparse import socket import threading +import random from threading import Lock import sys import time @@ -31,6 +32,14 @@ parser.add_argument( ) parser.add_argument( + '-u', + '--username-chance', + dest='username_chance', + type = int, + help = 'Chance [0-100] to focus on username instead.', +) + +parser.add_argument( '-c', '--print-chat', dest='print_chat', @@ -83,7 +92,7 @@ async def on_disconnect (): time.sleep(10) server.shutdown() server.close() - + @client.event async def on_connect (): global args @@ -118,7 +127,14 @@ async def on_message(message): server_mutex.acquire() has_lock = True - server.sendall(b"?RLR " + msg + b"\n") + + if (random.randint(1, 100) <= args.username_chance): + server.sendall(b"?RL " + msg + b"\n") + result = get_jh_reply() + msg = (message.author.display_name.encode('utf-8')) + server.sendall(b"?RR " + msg + b"\n") + else: + server.sendall(b"?RLR " + msg + b"\n") result = get_jh_reply() server_mutex.release() |