From d47ad50a03fecbafe87514d2a601f1073c121147 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Mon, 27 Jul 2020 13:46:29 +0200 Subject: Adds a new parameter to use msg author instead. --- jh-discord.py | 20 ++++++++++++++++++-- 1 file 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 @@ -30,6 +31,14 @@ parser.add_argument( help = 'Discord token.', ) +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', @@ -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() -- cgit v1.2.3-70-g09d2