diff --git a/README.md b/README.md
index 0b11609..d245ec4 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,21 @@
📝 Discord Scraper 📝
-Scrapes messages in chanel
-⭐ Don't forget to leave a star! ⭐
-
-🔩 V2 Coming soon! 🔩
+Scrapes messages in channel or private message.
+DUE TO DISCORDPY BEING BITCHES AND REMOVING ABILITY TO SELF BOT, THIS SCRAPER DOESNT WORK ANYMORE
+## Installation:
+1. Run `install.bat` or run in cmd `pip install -r _req.txt`
+2. Config your token, prefix and command in `config.json`
## Usage:
-1. Config settings and token in `config.json`
-2. Open install.bat
-3. Open start.bat
-4. In channel write `!scrape `
-5. Scraped messages will be saved in `scraped/name-of-channel`
-
-## Settings:
-![Settings Showcase](https://camo.githubusercontent.com/91fb91dbef076670a6791ffdea7bcf3591e36643/68747470733a2f2f7768657265732d6d792d74612e636f2f74504a58576c2e706e67)
+1. Open start.bat
+2. In channel/DM write `!scrape /all` or the command in your prompt
+3. Scraped messages will be saved in `scrape/Guild Name/name-of-channel`
+## Differences between original and fork
+1. Shows progress in command prompt. (Scraped x out of y message(s))
+2. Shows status in window title (waiting command, amount scraped on channel, done)
+3. Customizable prefix and command! `default: !scrape`
## Showcase:
-![Showcase](https://i.imgur.com/jQEmM9K.png)
+![Showcase](https://ella-nelson.wheres-my-ta.co/5UmLAQpwz.png)
`WARN: Using a selfbot is against TOS, It's not my fault if you get a ban when someone reports you`
diff --git a/requirements.txt b/_req.txt
similarity index 100%
rename from requirements.txt
rename to _req.txt
diff --git a/config.json b/config.json
index b9c805e..21b44c0 100644
--- a/config.json
+++ b/config.json
@@ -1,3 +1,5 @@
{
- "token": "token-here"
+ "token": "token-here",
+ "prefix": "!",
+ "command": "scrape"
}
diff --git a/install.bat b/install.bat
new file mode 100644
index 0000000..d2441ae
--- /dev/null
+++ b/install.bat
@@ -0,0 +1,5 @@
+@echo off
+cls
+title installing requirements
+pip install -r _req.txt
+pause
\ No newline at end of file
diff --git a/main.py b/main.py
index 64ea929..9512d94 100644
--- a/main.py
+++ b/main.py
@@ -2,41 +2,49 @@
import json
import os
import discord
-
+from datetime import datetime
from discord.ext import (
commands,
tasks
)
+with open("config.json") as f:
+ config = json.load(f)
+
+token = config["token"]
+cmd = config["command"]
+command_prefix=config["prefix"]
+
client = discord.Client()
client = commands.Bot(
- command_prefix="!",
+ command_prefix=config["prefix"],
self_bot=True
)
client.remove_command('help')
-with open('config.json') as f:
- config = json.load(f)
-
-token = config.get("token")
+
os.system('cls')
-print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Discord Chat Scraper made by {Fore.WHITE}LnX{Fore.LIGHTBLACK_EX} | Licensed under {Fore.WHITE}MIT {Fore.LIGHTBLACK_EX}License")
-print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You can follow me on Github: {Fore.WHITE}https://github.com/lnxcz")
+print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Discord Chat Scraper made by {Fore.CYAN}LnX{Fore.LIGHTBLACK_EX}, fork by {Fore.YELLOW}TabbyGarf{Fore.LIGHTBLACK_EX}")
+print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Licensed under {Fore.WHITE}MIT {Fore.LIGHTBLACK_EX}License")
+print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You can follow LnX on Github: {Fore.WHITE}https://github.com/lnxcz")
+print(f"{Fore.WHITE}[ {Fore.CYAN}§ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You can follow me there too: {Fore.WHITE}https://github.com/TabbyGarf")
print(f"\n{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Bot is ready!")
-print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Write {Fore.WHITE}!scrape {Fore.LIGHTBLACK_EX} to log messages\n")
+print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Write {Fore.YELLOW}{command_prefix}{Fore.CYAN}{cmd}{Fore.WHITE} {Fore.LIGHTBLACK_EX} to log messages\n")
+print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Write {Fore.YELLOW}{command_prefix}{Fore.CYAN}{cmd}{Fore.WHITE} all{Fore.LIGHTBLACK_EX} to log every message\n")
+os.system("title awaiting command")
def Init():
- if config.get('token') == "token-here":
+ if config["token"] == "token-here":
os.system('cls')
print(f"\n\n{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX}You didnt put your token in the config.json file\n\n"+Fore.RESET)
exit()
else:
- token = config.get('token')
+ token = config["token"]
try:
client.run(token, bot=False, reconnect=True)
os.system(f'Discord message scraper')
@@ -45,26 +53,56 @@ def Init():
exit()
-@client.command()
-async def scrape(ctx, amount: int):
- f = open(f"scraped/{ctx.message.channel}.txt","w+", encoding="UTF-8")
- total = amount
- print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraping {Fore.WHITE}{amount}{Fore.LIGHTBLACK_EX} messages to {Fore.WHITE}scraped/{ctx.message.channel}.txt{Fore.LIGHTBLACK_EX}!")
- async for message in ctx.message.channel.history(limit=amount):
+@client.command(name=cmd)
+async def scrape(ctx, amount: str):
+ time = datetime.now()
+ ft = time.strftime("%Y%m%d-%H%M%S")
+ if (ctx.message.guild != None):
+ filename = "scraped/{}/{}-{}.txt".format(ctx.message.guild.name,ctx.message.channel,ft)
+ else:
+ filename = "scraped/Direct Messages/{}-{}.txt".format(ctx.message.channel,ft)
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
+ f = open(filename, "w+", encoding = "UTF-8")
+ count = 1
+
+ if amount == "all":
+ all = True
+ print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Counting the amount of messages, this might take a while...")
+ os.system("title counting messages...")
+ amount = len([m async for m in ctx.message.channel.history(limit=None)])
+
+ else:
+ all = False
+ amount = int(amount)
+ total = int(amount)
+
+ if all == True:
+ print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraping {Fore.WHITE}all{Fore.LIGHTBLACK_EX} messages to {Fore.WHITE}{filename}{Fore.LIGHTBLACK_EX}!")
+ else:
+ print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraping {Fore.WHITE}{amount}{Fore.LIGHTBLACK_EX} messages to {Fore.WHITE}{filename}{Fore.LIGHTBLACK_EX}!")
+ async for message in ctx.message.channel.history(limit=amount, oldest_first=False):
attachments = [attachment.url for attachment in message.attachments if message.attachments]
try:
if attachments:
realatt = attachments[0]
f.write(f"({message.created_at}) {message.author}: {message.content} ({realatt})\n")
- print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped message")
+ print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped {count} out of {total} message(s)")
else:
f.write(f"({message.created_at}) {message.author}: {message.content}\n")
- print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped message")
+ print(f"{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Scraped {count} out of {total} message(s)")
except Exception as e:
print(f"{Fore.WHITE}[ {Fore.RED}- {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Cannot scrape message from {Fore.WHITE}{message.author}")
print(f"{Fore.WHITE}[ {Fore.RED}E {Fore.WHITE}] {Fore.LIGHTBLACK_EX} {Fore.WHITE}{e}")
total = total - 1
+ os.system("title [{}/{}] scraping {}".format(count,total,ctx.message.channel))
+ count = count + 1
print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Succesfully scraped {Fore.WHITE}{total} {Fore.LIGHTBLACK_EX}messages!\n\n{Fore.WHITE}")
+ os.system("title [DONE] - awaiting command".format(total))
+ print(f"\n{Fore.WHITE}[ {Fore.GREEN}+ {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Bot is ready!")
+ print(f"{Fore.WHITE}[ {Fore.YELLOW}? {Fore.WHITE}] {Fore.LIGHTBLACK_EX}Write {Fore.YELLOW}{command_prefix}{Fore.CYAN}{cmd}{Fore.WHITE} {Fore.LIGHTBLACK_EX} to log messages\n")
+
+
+
@client.event