-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathchimera.pyw
283 lines (217 loc) · 7.65 KB
/
chimera.pyw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# Basic bot dependencies
import discord
from discord.ext.commands import Bot
import platform
import os
import asyncio
from threading import Thread
# Import configurations
import configs
# Import logger
from lib.helpers import Logger
# Imports for system tray icon
from pystray import Icon, Menu, MenuItem
from PIL import Image
import webbrowser
# Modules import - this imports all modules under the modules directory
# IDEs will complain about unresolved references, but it runs as intended
from modules import *
# Create a bot client with a description and a command prefix
client = Bot(description="A remote system administration bot for discord", command_prefix=configs.BOT_PREFIX)
@client.event
async def on_ready():
print('--------')
print('Chimera Remote Administration Bot by CedArctic')
print('--------')
print('Logged in as ' + client.user.name + ' (ID:' + str(client.user.id) + ') | Connected to '
+ str(len(client.guilds)) + ' servers | Connected to ' + str(len(set(client.get_all_members()))) + ' users')
print('--------')
print(f'Current Discord.py Version: {discord.__version__} | Current Python Version: {platform.python_version()}')
print('--------')
print(f'Use this link to invite {client.user.name}:')
print(f'https://discordapp.com/oauth2/authorize?client_id={client.user.id}&scope=bot&permissions=8')
print('--------')
print('Github Link: https://github.com/CedArctic/Chimera')
print('--------')
return await client.change_presence(activity=discord.Game(name='with your PC'))
# Module: openurl
# Description: Opens url in default browser
# Usage: !openurl http://example.com/
@client.command()
@Logger(client)
async def openurl(ctx, url):
await openurl_module.openurl(ctx, url)
# Module: cmd
# Description: Executes cmd command
# Usage: !cmd "command"
@client.command()
@Logger(client)
async def cmd(ctx, cmnd):
await cmd_module.cmd(ctx, cmnd)
# Module: powershell
# Description: Executes powershell command
# Usage: !powershell "command"
@client.command()
@Logger(client)
async def powershell(ctx, cmnd):
await powershell_module.powershell(ctx, cmnd)
# Module: lock
# Description: Locks system
# Usage: !lock or !lock secondsToLock
@client.command()
@Logger(client)
async def lock(ctx, seconds=0):
await lock_module.lock(ctx, seconds)
# Module: appQuitter
# Description: Quits the application
# Usage: !appquitter "Application Name" or !appquitter "Application Name" minutesToQuit
@client.command()
@Logger(client)
async def appquitter(ctx, appName,minutes=0):
await appQuitter_module.appquitter(ctx,appName, minutes)
# Module: sleep
# Description: Puts system to sleep
# Usage: !sleep or !sleep secondsToSleep
@client.command()
@Logger(client)
async def sleep(ctx, seconds=0):
await sleep_module.sleep(ctx, seconds)
# Module: shutdown
# Description: Shuts system down
# Usage: !shutdown or !shutdown secondsToShutdown
@client.command()
@Logger(client)
async def shutdown(ctx, seconds=0):
await shutdown_module.shutdown(ctx, seconds)
# Module: restart
# Description: Restarts system
# Usage: !restart or !restart secondsToRestart
@client.command()
@Logger(client)
async def restart(ctx, seconds=0):
await restart_module.restart(ctx, seconds)
# Module: hibernate
# Description: Hibernates the system
# Usage: !hibernate or !hibernate secondsToHibernation
@client.command()
@Logger(client)
async def hibernate(ctx, seconds=0):
await hibernate_module.hibernate(ctx, seconds)
# Module: logoff
# Description: Logs the user out of the system
# Usage: !logoff or !logoff secondsToLogoff
@client.command()
@Logger(client)
async def logoff(ctx, seconds=0):
await logoff_module.logoff(ctx, seconds)
# Module: screenshot
# Description: Takes a screenshot and sends it back
# Usage: !screenshot or !screenshot secondsToScreenshot
@client.command()
@Logger(client)
async def screenshot(ctx, seconds=0):
await screenshot_module.screenshot(ctx, seconds)
# Module: say
# Description: Uses powershell and a TTS engine to make your computer say something
# Usage: !say "Something to say"
@client.command()
@Logger(client)
async def say(ctx, txt):
await say_module.say(ctx, txt)
# Module: media
# Description: Controls Media Features
# Usage: !media command or !media command times
@client.command()
@Logger(client)
async def media(ctx, command, times=1):
await media_module.media(ctx, command, times)
# Module: camera
# Description: Records a video or takes a photo (no audio)
# Usage: !camera command time
@client.command()
@Logger(client)
async def camera(ctx, command, time=5):
await camera_module.camera(ctx, command, time)
# Module: echo
# Description: Turns command output display to discord chat on and off (works for !cmd and !powershell)
# Usage: !echo off or !echo on
@client.command()
@Logger(client)
async def echo(ctx, status):
await echo_module.echo(ctx, status)
# Module: log
# Description: Turns on of off logs in chat. Also can be used to retrieve Chimera execution logs
# Usage: !log [off|on] | [show] [date (format: YYYY-MM-DD)]
@client.command()
@Logger(client)
async def log(ctx, param, date=None):
await log_module.log(ctx, param, date)
# Module: file
# Description: Allows file download, upload and system navigation
# Usage: !file [command] [[path]|[times]]
@client.command()
@Logger(client)
async def file(ctx, command, *args):
await file_module.file(ctx, command, *args)
# Module: launch
# Description: Launches a shortcut in the shortcuts directory
# Usage: !launch [shortcut]
@client.command()
@Logger(client)
async def launch(ctx, shortcut):
await launch_module.launch(ctx, shortcut)
# Module: helpme
# Description: Allows file download, upload and system navigation
# Usage: !helpme [command]
@client.command()
@Logger(client)
async def helpme(ctx, command=None):
await helpme_module.helpme(ctx, command)
# Module: notification
# Description: Sends a notification to the computer
# Usage: !notification "Notification Content"
@client.command()
@Logger(client)
async def notification(ctx, txt):
await notification_module.notification(ctx, txt)
# System Tray menu functions
# Starts the bot client
def iconRun():
loop = asyncio.get_event_loop()
loop.create_task(client.start(configs.BOT_TOKEN))
t1=Thread(target=loop.run_forever)
t1.start()
# Shows logs folder
def showLogs(): os.startfile("logs")
# Shows shortcuts folder
def showShortcuts(): os.startfile("shortcuts")
# Opens bot invitation link in the browser
def connectInfo(): webbrowser.open(
f'https://discordapp.com/oauth2/authorize?client_id={client.user.id}&scope=bot&permissions=8')
# Exits the application
def applicationExit():
# This doesn't quit the bot client. To do that you need to call client.logout or .close
# This merely stops the icon from showing on the taskbar. A full solution will be implemented later
icon.visible = False
icon.stop()
# About
def about(): webbrowser.open('https://github.com/CedArctic/Chimera/blob/master/README.md')
# Instructions
def instructions(): webbrowser.open('https://github.com/CedArctic/Chimera/blob/master/README.md')
# Create system tray icon and start running the client
def iconSetup():
iconImage = Image.open("Chimera_logo.png")
iconMenu = Menu(
MenuItem("Connect", action=connectInfo, default=True),
MenuItem("Instructions", action=instructions),
MenuItem("Show Logs", action=showLogs),
MenuItem("Show Shortcuts", action=showShortcuts),
MenuItem("About", action=about),
MenuItem("Exit", action=applicationExit),
)
icon = Icon('Chimera', icon=iconImage, menu=iconMenu)
return icon
# Application Entry Point - starts icon and bot client
icon = iconSetup()
iconRun()
icon.run()