aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-03-05 23:54:21 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-03-05 23:54:21 +0100
commit9e5798e922dc03fced416bdb4fcb2e9a213a9d48 (patch)
tree2111f5ef84e6addf4c4005a85d8fc97d9e0b8c0b
parent550604f7de4ee54715ec22f08a7fc65b19747e3f (diff)
downloaddiscord-9e5798e922dc03fced416bdb4fcb2e9a213a9d48.zip
discord-9e5798e922dc03fced416bdb4fcb2e9a213a9d48.tar.bz2
Fixes JH socket usage.
-rw-r--r--jh-discord.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/jh-discord.py b/jh-discord.py
index 9b0d059..96e1e92 100644
--- a/jh-discord.py
+++ b/jh-discord.py
@@ -38,6 +38,7 @@ parser.add_argument(
)
args = parser.parse_args()
+is_connected = False
server = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client = discord.Client()
@@ -70,14 +71,22 @@ def get_jh_reply ():
@client.event
async def on_ready():
+ global is_connected
+ global server
+ global args
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
- server.connect(args.destination)
+ if (not is_connected):
+ server.connect(args.destination)
+ is_connected = True
@client.event
async def on_message(message):
+ global server
+ global args
+
if (message.author.id == client.user.id):
return
@@ -112,6 +121,7 @@ def exit_if_disconnected ():
if ((not client.is_logged_in) or client.is_closed):
print("Timed out.")
+ server.close()
sys.exit()
threading.Thread(target=exit_if_disconnected).start()