DiscordScraper 1.0.1__tar.gz

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.
@@ -0,0 +1,3 @@
1
+ from DiscordLogger.main import *
2
+ from DiscordLogger.test import *
3
+ from DiscordLogger.config import *
@@ -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.')
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: DiscordScraper
3
+ Version: 1.0.1
4
+ Requires-Dist: discord.py-self[voice]>=2.1.0
5
+ Dynamic: requires-dist
@@ -0,0 +1,10 @@
1
+ README.md
2
+ setup.py
3
+ DiscordLogger/__init__.py
4
+ DiscordLogger/main.py
5
+ DiscordScraper.egg-info/PKG-INFO
6
+ DiscordScraper.egg-info/SOURCES.txt
7
+ DiscordScraper.egg-info/dependency_links.txt
8
+ DiscordScraper.egg-info/entry_points.txt
9
+ DiscordScraper.egg-info/requires.txt
10
+ DiscordScraper.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ discord-logger = DiscordLogger.main:run_bot
3
+ update-token = DiscordLogger.main:update_token
@@ -0,0 +1 @@
1
+ discord.py-self[voice]>=2.1.0
@@ -0,0 +1 @@
1
+ DiscordLogger
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: DiscordScraper
3
+ Version: 1.0.1
4
+ Requires-Dist: discord.py-self[voice]>=2.1.0
5
+ Dynamic: requires-dist
@@ -0,0 +1,24 @@
1
+ # DiscordLogger
2
+
3
+ ## About
4
+ DiscordLogger is a screen-scraping Discord Self-Bot, built with the Discord.py-Self API with voice functionality.
5
+ This project aims to log messages, reactions, edits, attachments (via Discord CDN URL), and voice conversations.
6
+
7
+ ## What works
8
+ Text, reaction, edit, and image attachment logging currently works.
9
+
10
+ ## Future plans
11
+ I plan to implement voice call recording.
12
+
13
+ ## Important information
14
+ It shall be noted that self-bots are against Discord's TOS. As such, it is recommended that you do not use your personal account to run the self-bot, but rather, an alternative account.
15
+
16
+ ## Dependencies
17
+ In order to run this package, [``discord.py-self[voice]``](https://discordpy-self.readthedocs.io/en/latest/intro.html) must be installed in the same folder as the main, and config py files.
18
+
19
+ ## Running the Program
20
+ Ensure that the account token for which you are logging from is pasted into the ``config.py`` file. (You may need to run the ``config.py`` file to update the token)
21
+
22
+ Since this is a CLI tool, you simply execute ``python main.py`` in your system terminal in order to execute the program.
23
+
24
+ Logged message data is stored in the form of a .txt file under the appropriately named ``message_logs`` directory.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name='DiscordScraper',
5
+ version='1.0.1',
6
+ packages=find_packages(),
7
+ install_requires=[
8
+ 'discord.py-self[voice]>=2.1.0'
9
+ ],
10
+ entry_points={
11
+ 'console_scripts': [
12
+ 'discord-logger=DiscordLogger.main:run_bot',
13
+ 'update-token=DiscordLogger.main:update_token'
14
+ ]
15
+ },
16
+ )