aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--copypasta/fuckyou.txt1
-rw-r--r--copypasta/spaghetti.txt1
-rwxr-xr-xlaunch.sh5
-rw-r--r--modules/dump.py14
-rw-r--r--modules/link.py39
-rw-r--r--requirements.txt3
6 files changed, 57 insertions, 6 deletions
diff --git a/copypasta/fuckyou.txt b/copypasta/fuckyou.txt
new file mode 100644
index 0000000..8b7f0b5
--- /dev/null
+++ b/copypasta/fuckyou.txt
@@ -0,0 +1 @@
+https://youtu.be/5RdzWUxWVvY
diff --git a/copypasta/spaghetti.txt b/copypasta/spaghetti.txt
new file mode 100644
index 0000000..1abb1c6
--- /dev/null
+++ b/copypasta/spaghetti.txt
@@ -0,0 +1 @@
+https://youtu.be/SW-BU6keEUw
diff --git a/launch.sh b/launch.sh
index dd26e56..23a0a74 100755
--- a/launch.sh
+++ b/launch.sh
@@ -1,8 +1,5 @@
#!/usr/bin/env bash
scriptdir=$(dirname $(readlink -f $0))
cd ${scriptdir}
-while true
-do
- `pwd`/venv/bin/python main.py &>$HOME/logs/discordbot
-done
+screen -dmS notaselfbot ${scriptdir}/venv/bin/python main.py
diff --git a/modules/dump.py b/modules/dump.py
index 05d10a9..183dba3 100644
--- a/modules/dump.py
+++ b/modules/dump.py
@@ -1,3 +1,4 @@
+import inspect
import re
from asyncio import sleep
from functools import wraps
@@ -5,7 +6,8 @@ from typing import List
from discord import User, Embed, Profile, Guild, Member, Permissions, Message, Role, Emoji, TextChannel
from discord.ext.commands import Bot, command, Context as CommandContext, Context
-
+from discord.ext.commands import Paginator
+from datetime import datetime
async def _context_react(self: Context, emoji):
await self.message.add_reaction(emoji)
@@ -39,6 +41,14 @@ class DumpCog(object):
self.bot = bot
@command()
+ async def show_off(self, ctx: CommandContext, name: str):
+ paginator = Paginator(prefix="```py")
+ for line in inspect.getsource(self.bot.get_command(name).callback).split('\n'):
+ paginator.add_line(line.replace("`", "`\u200B"))
+ for page in paginator.pages:
+ await ctx.send(page)
+
+ @command()
async def raw(self, ctx: CommandContext, message: Message):
content: str = message.content
escaped = content.replace('```', '``\u200B`')
@@ -67,7 +77,7 @@ class DumpCog(object):
role: Role = roles[0] if len(roles) > 0 else None
embed = Embed(title=f"ID: {snowflake}")
- embed.add_field(name="When", value=str(when))
+ embed.add_field(name="When", value=str(when) + ' / ' + str(datetime.fromtimestamp(when)))
embed.add_field(name="Worker", value=str(worker))
embed.add_field(name="Process", value=str(process))
embed.add_field(name="Increment", value=str(increment))
diff --git a/modules/link.py b/modules/link.py
new file mode 100644
index 0000000..68f56e1
--- /dev/null
+++ b/modules/link.py
@@ -0,0 +1,39 @@
+from aiohttp import ClientSession, ClientResponse
+from bs4 import BeautifulSoup
+from discord import Embed
+from discord.ext.commands import Bot, command, Context
+
+
+class Link(object):
+ def __init__(self, bot: Bot):
+ self.bot = bot
+
+ @command(aliases=['unshorten'])
+ async def retrace(self, ctx: Context, *, link: str):
+ found = set()
+ history = []
+ async with ClientSession() as sess:
+ while link not in found:
+ async with sess.get(link, allow_redirects=False) as res:
+ res: ClientResponse
+ found.add(res.url)
+ if res.status // 100 == 3:
+ history.append(('header', res.url))
+ link = res.headers['Location']
+ continue
+ soup = BeautifulSoup((await res.text()), 'html5lib')
+ el = soup.find('meta', attrs={'http-equiv': 'refresh'})
+ if el:
+ history.append(('meta', res.url))
+ link = el['content'].split('=')[1]
+ continue
+ break
+ text = '\n'.join([f'{re[0]} - {re[1]}' for re in history] + [f'Final - {link}'])
+ await ctx.send(
+ embed=Embed(
+ description=text
+ ))
+
+
+def setup(bot: Bot):
+ bot.add_cog(Link(bot))
diff --git a/requirements.txt b/requirements.txt
index 46f2ecc..752e17d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,5 +1,8 @@
+aiohttp
https://github.com/Rapptz/discord.py/archive/rewrite.zip
https://github.com/aaugustin/websockets/archive/master.zip
https://github.com/romangraef/configlib/archive/master.zip
cached-property
PyGithub
+bs4
+html5lib