DiscordScraper 1.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- DiscordLogger/__init__.py +3 -0
- DiscordLogger/config.py +2 -0
- DiscordLogger/main.py +86 -0
- DiscordLogger/test.py +2 -0
- discordscraper-1.0.1.dist-info/METADATA +5 -0
- discordscraper-1.0.1.dist-info/RECORD +9 -0
- discordscraper-1.0.1.dist-info/WHEEL +5 -0
- discordscraper-1.0.1.dist-info/entry_points.txt +3 -0
- discordscraper-1.0.1.dist-info/top_level.txt +1 -0
DiscordLogger/config.py
ADDED
DiscordLogger/main.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Main executor file
|
|
2
|
+
|
|
3
|
+
from discord import *
|
|
4
|
+
import tomllib
|
|
5
|
+
import os
|
|
6
|
+
import pathlib
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
working_directory = f'{os.getcwd()}/DiscordLogger'
|
|
10
|
+
|
|
11
|
+
def run_bot():
|
|
12
|
+
if not tomllib.load(open('DiscordLogger/config.toml','rb'))['token_inserted']:
|
|
13
|
+
print('Token not inserted. Insert before starting bot.')
|
|
14
|
+
return
|
|
15
|
+
else:
|
|
16
|
+
class MyClient(Client):
|
|
17
|
+
async def on_ready(self):
|
|
18
|
+
print('Logged on as', self.user)
|
|
19
|
+
|
|
20
|
+
async def on_message(self, message):
|
|
21
|
+
|
|
22
|
+
pathlib.Path(f'{working_directory}/message_logs/{message.guild}').mkdir(exist_ok=True) # Creates working_directory for server message was sent in
|
|
23
|
+
os.chdir(f'{working_directory}/message_logs/{message.guild}')
|
|
24
|
+
|
|
25
|
+
if message.attachments != []:
|
|
26
|
+
if isinstance(message.attachments[0],Attachment) and message.attachments: # Check
|
|
27
|
+
for sent_attachment in message.attachments:
|
|
28
|
+
with open(f'{message.channel}.txt','a') as file:
|
|
29
|
+
file.write(f'{time.strftime('%d/%m/%Y - %H:%M',time.localtime())} {message.author} (User ID = {message.author.id}):\n')
|
|
30
|
+
file.write(f'\tSent attachment: {sent_attachment.url}\n')
|
|
31
|
+
file.write(f'\tMessage ID {message.id}\n')
|
|
32
|
+
|
|
33
|
+
# Log text messages
|
|
34
|
+
with open(f'{message.channel}.txt','a') as file:
|
|
35
|
+
file.write(f'{time.strftime('%d/%m/%Y - %H:%M',time.localtime())} {message.author} (User ID = {message.author.id}):\n')
|
|
36
|
+
file.write(f'\t{message.content}\n')
|
|
37
|
+
|
|
38
|
+
# Reaction Log (Only logs reactions to messages sent during runtime)
|
|
39
|
+
async def on_reaction_add(self, reaction, user):
|
|
40
|
+
|
|
41
|
+
pathlib.Path(f'{working_directory}/message_logs/{reaction.message.guild}').mkdir(exist_ok=True) # Creates working_directory for server message was sent in
|
|
42
|
+
os.chdir(f'{working_directory}/message_logs/{reaction.message.guild}')
|
|
43
|
+
|
|
44
|
+
with open(f'{reaction.message.channel}.txt','a') as file:
|
|
45
|
+
file.write(f'{time.strftime('%d/%m/%Y - %H:%M',time.localtime())} {user} (User ID = {user.id}):\n')
|
|
46
|
+
if reaction.message.content != '':
|
|
47
|
+
file.write(f'\tReacted {reaction} to: {reaction.message.content}\n')
|
|
48
|
+
else:
|
|
49
|
+
file.write(f'\tReacted {reaction} to attachment\n')
|
|
50
|
+
|
|
51
|
+
file.write(f'\tMessage ID: {reaction.message.id}\n')
|
|
52
|
+
|
|
53
|
+
async def on_reaction_remove(self,reaction,user):
|
|
54
|
+
|
|
55
|
+
pathlib.Path(f'{working_directory}/message_logs/{reaction.message.guild}').mkdir(exist_ok=True) # Creates working_directory for server message was sent in
|
|
56
|
+
os.chdir(f'{working_directory}/message_logs/{reaction.message.guild}')
|
|
57
|
+
|
|
58
|
+
with open(f'{reaction.message.channel}.txt','a') as file:
|
|
59
|
+
file.write(f'{time.strftime('%d/%m/%Y - %H:%M',time.localtime())} {user} (User ID = {user.id}):\n')
|
|
60
|
+
if reaction.message.content != '':
|
|
61
|
+
file.write(f'\tRemoved reaction {reaction} from {reaction.message.content}\n')
|
|
62
|
+
else:
|
|
63
|
+
file.write(f'\tRemoved reaction {reaction} from attachment\n')
|
|
64
|
+
file.write(f'\tMessage ID: {reaction.message.id}\n')
|
|
65
|
+
|
|
66
|
+
# Edit Log
|
|
67
|
+
|
|
68
|
+
async def on_message_edit(self,before,after):
|
|
69
|
+
|
|
70
|
+
pathlib.Path(f'{working_directory}/message_logs/{before.message.guild}').mkdir(exist_ok=True) # Creates working_directory for server message was sent in
|
|
71
|
+
os.chdir(f'{working_directory}/message_logs/{before.message.guild}')
|
|
72
|
+
|
|
73
|
+
with open(f'{before.channel}.txt','a') as file:
|
|
74
|
+
file.write(f'{time.strftime('%d/%m/%Y - %H:%M',time.localtime())} {before.author} (User ID = {before.author.id}):\n')
|
|
75
|
+
file.write(f'\tEdited {before.content} to {after.content}\n')
|
|
76
|
+
|
|
77
|
+
client = MyClient(chunk_guilds_at_startup=False)
|
|
78
|
+
client.run(tomllib.load(open('DiscordLogger/config.toml','rb'))['token'])
|
|
79
|
+
|
|
80
|
+
def update_token():
|
|
81
|
+
new_token = input('Enter static token:\n> ')
|
|
82
|
+
file = open('DiscordLogger/config.toml','w')
|
|
83
|
+
file.write(
|
|
84
|
+
f'token = "{new_token}"\ntoken_inserted = "True"'
|
|
85
|
+
)
|
|
86
|
+
return print('Token updated successfully.')
|
DiscordLogger/test.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
DiscordLogger/__init__.py,sha256=pGbsT4zT2fvS8F_AM5O-6dEQjldk9pBcyPpWh9K3DCU,102
|
|
2
|
+
DiscordLogger/config.py,sha256=PYHRlqy5Ofs9hQq3_QMfGaV60pedBtgQXe2RaMGW_UA,34
|
|
3
|
+
DiscordLogger/main.py,sha256=QptJVaiediMzLjpwn4X413-FmeabsMb9Fxp2HvXagIU,4571
|
|
4
|
+
DiscordLogger/test.py,sha256=IAedeiQJ0juUZ0vR8NFO6_o2V4opEI84Qqz6Qo8IVLE,50
|
|
5
|
+
discordscraper-1.0.1.dist-info/METADATA,sha256=EvtVtbWbk6AoC1UZUs3PRjIpU0ypcGnu5f4SYkLOG4U,131
|
|
6
|
+
discordscraper-1.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
7
|
+
discordscraper-1.0.1.dist-info/entry_points.txt,sha256=29hut7NCMcJbeWtQsMKyZw_pxelNNyL2SuRrcXJ4zAc,109
|
|
8
|
+
discordscraper-1.0.1.dist-info/top_level.txt,sha256=lfkcwnk2IupjbP4P4vZYIA2KwDNtLHV5d6S7CcQa4W0,14
|
|
9
|
+
discordscraper-1.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DiscordLogger
|