Skip to content

Commit 88ba3af

Browse files
committed
FInal changes
1 parent cd263ea commit 88ba3af

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Discord Windows Controller Bot
22

3-
The Discord Windows Controller Bot is a Python bot designed to control Windows operations through Discord commands. It can perform tasks like locking your workstation and monitoring mouse movement in a specified channel. Follow these steps to set up and run the bot.
3+
The Discord Windows Controller Bot is a Python bot designed to control Windows operations through Discord commands. It can perform tasks like locking your workstation and monitoring mouse movement in a specified channel as well as saving files you send to the local workstation. Follow these steps to set up and run the bot.
44

55
## Step 1: Clone the Repository
66

@@ -97,6 +97,7 @@ If you still face issues, try the following:
9797
1. In the project folder, create a text file named "key.txt."
9898
2. Paste the copied bot token into the "key.txt" file and save it.
9999
3. Get your Channel ID and your own ID from Discord, and paste them into the "config.json" file.
100+
4. Create a folder where you would want the files to be saved to locally, and copy the path to the `file_save_path` variable
100101

101102
Example:
102103

@@ -105,7 +106,8 @@ Example:
105106
"command_channel_id": 1137276176451079374,
106107
"author_id": 637917562920429309,
107108
"log_channel_id": 1137693326543122128,
108-
"mouse_log_channel_id": 1137693326543123128
109+
"mouse_log_channel_id": 1137693326543123128,
110+
"file_save_path": "insert/file/path"
109111
}
110112
```
111113

bot.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import asyncio
66
import pyautogui
77
from commands.mouse_movement import monitor_mouse_movement
8+
from aiohttp.client_exceptions import ClientConnectorError
89

910
KEY_PATH = "key.txt"
1011
CONFIG_PATH = "config.json"
@@ -35,7 +36,7 @@ async def network_monitor():
3536
async def main():
3637
if os.path.exists(KEY_PATH):
3738
with open(KEY_PATH, "r") as f:
38-
TOKEN = f.read()
39+
TOKEN = f.read().strip()
3940
else:
4041
TOKEN = ""
4142

@@ -87,14 +88,27 @@ async def on_message(message):
8788
from commands.help_command import execute_help_command
8889
await execute_help_command(client, message, config)
8990

91+
async def start_bot():
92+
while True:
93+
try:
94+
# Start the network monitoring task
95+
network_task = asyncio.create_task(network_monitor())
96+
97+
# Start the client
98+
await client.start(TOKEN)
99+
except ClientConnectorError:
100+
print("Failed to connect to Discord. Retrying in 30 seconds...")
101+
await asyncio.sleep(30)
102+
except KeyboardInterrupt:
103+
print("Interrupt received. Shutting down gracefully...")
104+
break
105+
except Exception as e:
106+
print(f"An unexpected error occurred: {e}")
107+
print("Restarting the bot in 30 seconds...")
108+
await asyncio.sleep(30)
109+
90110
try:
91-
# Start the network monitoring task
92-
network_task = asyncio.create_task(network_monitor())
93-
94-
# Start the client
95-
await client.start(TOKEN)
96-
except KeyboardInterrupt:
97-
print("Interrupt received. Shutting down gracefully...")
111+
await start_bot()
98112
finally:
99113
# Cancel all running tasks
100114
tasks = [t for t in asyncio.all_tasks() if t is not asyncio.current_task()]

0 commit comments

Comments
 (0)