-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKillswitch.py
More file actions
64 lines (54 loc) · 2.45 KB
/
Copy pathKillswitch.py
File metadata and controls
64 lines (54 loc) · 2.45 KB
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
import os
import requests
from sys import exit
import time
import toml
from lib.colors import BColors
from lib import prints
VERSION = '3.0.1'
if __name__ == '__main__':
try:
# Enable ANSI codes (required for Prints/Color)
os.system('')
prints.print_info(f'Running Version {VERSION}')
prints.print_info('Hold up! You are about to killswitch the Webhooks provided in config.toml,')
prints.print_info('which will cause the script to stop functioning for all members!')
prints.print_info('You should only do this if you assume that someone is abusing the Webhooks')
prints.print_info('to damage the Discord Server.')
prints.print_info('Do you want to continue? (Enter "KILLSWITCH" to continue)')
choice = input()
if choice != 'KILLSWITCH':
exit(0)
# Read configuration file
config = toml.load('./config.toml')
webhook_urls = {config['webhook_url']}
for command in config['commands']:
if config['commands'][command]["override_webhook"]:
webhook_urls.add(config['commands'][command]["override_webhook"])
# Try to delete Webhooks
for webhook_url in webhook_urls:
while True:
try:
response = requests.delete(webhook_url)
match response.status_code:
# Deletion was successful
case 204:
prints.print_info(BColors.GREEN + 'Webhook deleted successfully.')
break
# Webhook not exists or was already deleted
case 404:
prints.print_error('Webhook not exists or was already deleted.')
break
# Unknown HTML Status Code
case _:
prints.print_error(f'Unexpected HTTP Status Code. ({response.status_code})')
break
# Unknown connection error
except requests.exceptions.ConnectionError as e:
prints.print_error(e)
time.sleep(5)
prints.print_info('All Webhooks have been processed.')
input()
except KeyboardInterrupt:
prints.print_info(BColors.YELLOW + 'Program closed by user (CTRL+C)')
exit(0)