From bfa568af62117bc7b55f13926d4c2802081002a6 Mon Sep 17 00:00:00 2001 From: AnInternetTroll Date: Fri, 5 Jun 2020 19:47:19 +0200 Subject: Added blacklist --- .gitignore | 3 ++- .vscode/settings.json | 0 bot.py | 16 +++++++++++++--- cogs/admin.py | 35 +++++++++++++++++++++++++++++++---- cogs/general.py | 0 cogs/help.py | 0 cogs/player.py | 0 cogs/src.py | 0 cogs/trans.py | 0 cogs/utils.py | 40 ++++++++++++++++++++-------------------- custom_commands.json | 38 +++++++++++++++++++++++++++++++++++++- main.py | 0 palette.png | Bin requirements.txt | 16 ++++++++++++++++ 14 files changed, 119 insertions(+), 29 deletions(-) mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .vscode/settings.json mode change 100755 => 100644 bot.py mode change 100755 => 100644 cogs/admin.py mode change 100755 => 100644 cogs/general.py mode change 100755 => 100644 cogs/help.py mode change 100755 => 100644 cogs/player.py mode change 100755 => 100644 cogs/src.py mode change 100755 => 100644 cogs/trans.py mode change 100755 => 100644 cogs/utils.py mode change 100755 => 100644 custom_commands.json mode change 100755 => 100644 main.py mode change 100755 => 100644 palette.png create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index 384c5f5..e63e2cc --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ discord.log api_keys.json .vscode/ leaderboard.png -downloads/ \ No newline at end of file +downloads/ +blacklist.json \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100755 new mode 100644 diff --git a/bot.py b/bot.py old mode 100755 new mode 100644 index 62645f3..2721110 --- a/bot.py +++ b/bot.py @@ -49,21 +49,31 @@ class BedrockBot(commands.Bot): game = discord.Game("Mining away") await self.change_presence(activity=game) + with open('blacklist.json', 'r') as f: + try: + self.blacklist = json.load(f) + except json.decoder.JSONDecodeError: + self.blacklist = [] + self.logger.warning(f'Online: {self.user} (ID: {self.user.id})') async def on_message(self, message): if message.author.bot: return + if message.author.id in self.blacklist: + return await self.process_commands(message) try: command = message.content.split()[0] except IndexError: pass - - if command in self.custom_commands: - await message.channel.send(self.custom_commands[command]) + try: + if command in self.custom_commands: + await message.channel.send(self.custom_commands[command]) + return + except: return def run(self): diff --git a/cogs/admin.py b/cogs/admin.py old mode 100755 new mode 100644 index 917a8de..3cb7ff8 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -38,7 +38,7 @@ class Admin(commands.Cog): async def setcommand(self, ctx, command, *, message): self.bot.custom_commands[ctx.prefix + command] = message with open('custom_commands.json', 'w') as f: - json.dump(self.bot.custom_commands, f) + json.dump(self.bot.custom_commands, f, indent=4) await ctx.send(f"Set message for command {command}") @@ -47,7 +47,7 @@ class Admin(commands.Cog): async def removecommand(self, ctx, command): del self.bot.custom_commands[ctx.prefix + command] with open('custom_commands.json', 'w') as f: - json.dump(self.bot.custom_commands, f) + json.dump(self.bot.custom_commands, f, indent=4) await ctx.send(f"Removed command {command}") @@ -99,7 +99,7 @@ class Admin(commands.Cog): await ctx.send(f'The extension {ext} doesn\'t have an entry point (try adding the setup function)') except commands.ExtensionFailed: await ctx.send(f'Some unknown error happened while trying to reload extension {ext} (check logs)') - self.bot.logger.exception(f'Failed to reload extension {ext}:') + self.bot.logger.exception(f'Failed to unload extension {ext}:') """ @commands.command() @@ -122,7 +122,7 @@ class Admin(commands.Cog): @commands.check(is_mod) @commands.command() - async def mute(self, ctx, members: commands.Greedy[discord.Member], + async def mute(self, ctx, members: commands.Greedy[discord.Member]=False, mute_minutes: int = 0, *, reason: str = "absolutely no reason"): """Mass mute members with an optional mute_minutes parameter to time it""" @@ -130,6 +130,8 @@ class Admin(commands.Cog): if not members: await ctx.send("You need to name someone to mute") return + elif type(members)=="str": + members = self.bot.get_user(int(user)) #muted_role = discord.utils.find(ctx.guild.roles, name="Muted") muted_role = ctx.guild.get_role(707707894694412371) @@ -149,6 +151,12 @@ class Admin(commands.Cog): @commands.check(is_mod) @commands.command() async def unmute(self, ctx, members: commands.Greedy[discord.Member]): + if not members: + await ctx.send("You need to name someone to unmute") + return + elif type(members)=="str": + members = self.bot.get_user(int(user)) + muted_role = ctx.guild.get_role(707707894694412371) for i in members: await i.remove_roles(muted_role) @@ -162,6 +170,25 @@ class Admin(commands.Cog): file = discord.File("discord.log") await ctx.send(file=file) + @commands.command(aliases=['ban'], hidden=True) + @commands.check(is_mod) + async def blacklist(self, ctx, members: commands.Greedy[discord.Member]=None): + if not members: + await ctx.send("You need to name someone to blacklist") + return + elif type(members)=="str": + members = self.bot.get_user(int(user)) + + with open('blacklist.json', 'w') as f: + for i in members: + if i.id in self.bot.blacklist: + self.bot.blacklist.remove(i.id) + json.dump(self.bot.blacklist, f, indent=4) + await ctx.send(f"{i} has been un-blacklisted.") + else: + self.bot.blacklist.append(i.id) + json.dump(self.bot.blacklist, f, indent=4) + await ctx.send(f"{i} has been blacklisted.") def setup(bot): diff --git a/cogs/general.py b/cogs/general.py old mode 100755 new mode 100644 diff --git a/cogs/help.py b/cogs/help.py old mode 100755 new mode 100644 diff --git a/cogs/player.py b/cogs/player.py old mode 100755 new mode 100644 diff --git a/cogs/src.py b/cogs/src.py old mode 100755 new mode 100644 diff --git a/cogs/trans.py b/cogs/trans.py old mode 100755 new mode 100644 diff --git a/cogs/utils.py b/cogs/utils.py old mode 100755 new mode 100644 index 3e199da..e9943ee --- a/cogs/utils.py +++ b/cogs/utils.py @@ -18,11 +18,11 @@ from PIL import Image from PIL import ImageFilter def set_viewport_size(driver, width, height): - window_size = driver.execute_script(""" - return [window.outerWidth - window.innerWidth + arguments[0], - window.outerHeight - window.innerHeight + arguments[1]]; - """, width, height) - driver.set_window_size(*window_size) + window_size = driver.execute_script(""" + return [window.outerWidth - window.innerWidth + arguments[0], + window.outerHeight - window.innerHeight + arguments[1]]; + """, width, height) + driver.set_window_size(*window_size) async def reportStuff(self, ctx, message): channel = self.bot.get_channel(715549209998262322) @@ -54,9 +54,9 @@ class Utils(commands.Cog): # Don't ask rigged_findseed = { - 280428276810383370: 12, # Thomas's User ID - 199070670221475842: -1, # Kai's User ID - 615658069132836865: -12 # They didn't use a real name. Sad! + 280428276810383370: 12, # Thomas's User ID + 199070670221475842: -1, # Kai's User ID + 615658069132836865: -12 # They didn't use a real name. Sad! } if ctx.author.id in rigged_findseed: @@ -252,18 +252,18 @@ class Utils(commands.Cog): @commands.command() async def someone(self, ctx): - blacklist = [536071288859656193] - if ctx.channel.id != 589110766578434078: - if ctx.author.id == 395872198323077121: - await ctx.send("grape is a bitch") - elif ctx.author.id == 521153476714299402: - await ctx.send("ZMG is smooth brain") - elif ctx.author.id == 199070670221475842: - await ctx.send("fuck you @kaii#0408") - elif ctx.author.id in blacklist: - await ctx.send("not even bothering with a message for you. You're just an edgy sheep") - else: - await ctx.send(choice(ctx.guild.members).mention) + blacklist = [536071288859656193] + if ctx.channel.id != 589110766578434078: + if ctx.author.id == 395872198323077121: + await ctx.send("grape is a bitch") + elif ctx.author.id == 521153476714299402: + await ctx.send("ZMG is smooth brain") + elif ctx.author.id == 199070670221475842: + await ctx.send(f"fuck you {ctx.message.author.mention}") + elif ctx.author.id in blacklist: + await ctx.send("not even bothering with a message for you. You're just an edgy sheep") + else: + await ctx.send(choice(ctx.guild.members).mention) @commands.command() async def roll(self, ctx, pool): diff --git a/custom_commands.json b/custom_commands.json old mode 100755 new mode 100644 index 7664008..c87825f --- a/custom_commands.json +++ b/custom_commands.json @@ -1 +1,37 @@ -{"/src": "https://www.speedrun.com/mcbe", "/launcher": "https://github.com/MCMrARM/mc-w10-version-launcher/releases/tag/0.1.0", "/locate": "head north", "/boards": "https://www.speedrun.com/mcbe", "/leaderboards": "https://www.speedrun.com/mcbe", "/ban": "shut up", "/ssg": "https://www.speedrun.com/mcbe#Any_Glitchless", "/hoes": "stop asking for this shit", "/Make": "Troll Supermod", "/Don't": "Buy The Sun Newspaper", "/Troll": "is Super at his job", "/troll": "The greatest mod this game has", "/welcome": "Welcome! <:Cake:619552132298964993>", "/pending": "this annoys me", "!murray": "the irishest of the Irish", "!HereWeGo": "10 in a Row!", "!GlasgowRangers": "You Let Your Club Die!", "!hwg": "10 iar", "!When-you-walk-through-a-storm": "hold your head up high", "!At-the-end-of-a-Storm": "there's a golden sky and the sweet silver song of the lark", "!Walk-On": "Walk On with hope in your hearts and You'll Never Walk Alone", "!Walk-On-through-the-Wind": "Walk On through the rain", "!For-your-dreams": "be tossed and blown", "!When-you-walk": "through a storm hold your head up high and don't be afraid of the dark\nAt the end of a Storm there's a golden sky and the sweet silver song of the lark\nWalk on through the wind\nWalk on through the rain, for your dreams be tossed and blown\nWalk On, Walk On with hope in your hearts and You'll Never Walk Alone, **YOU'LL NEVER WALK ALONE**\nWalk On, Walk On with hope in your hearts and You'll Never Walk Alone, **YOU'LL NEVER WALK ALONE**", "!Scotland'sNo1": "Celtic", "/swipe": "not an alt", "!blacklist": "Done! That felt good", "/blacklist": "Done! That felt good", "!sr.c": "https://www.speedrun.com/mcbe", "!h": "<@!199070670221475842> no swearing in this christian discord server", "!lenny": "( \u0361\u00b0 \u035c\u0296 \u0361\u00b0)", "!uwu": "uwu"} \ No newline at end of file +{ + "!sr.c": "https://www.speedrun.com/mcbe", + "/Troll": "is Super at his job", + "/src": "https://www.speedrun.com/mcbe", + "!Walk-On-through-the-Wind": "Walk On through the rain", + "!When-you-walk": "through a storm hold your head up high and don't be afraid of the dark\nAt the end of a Storm there's a golden sky and the sweet silver song of the lark\nWalk on through the wind\nWalk on through the rain, for your dreams be tossed and blown\nWalk On, Walk On with hope in your hearts and You'll Never Walk Alone, **YOU'LL NEVER WALK ALONE**\nWalk On, Walk On with hope in your hearts and You'll Never Walk Alone, **YOU'LL NEVER WALK ALONE**", + "/troll": "The greatest mod this game has", + "/hoes": "stop asking for this shit", + "!At-the-end-of-a-Storm": "there's a golden sky and the sweet silver song of the lark", + "!Scotland'sNo1": "Celtic", + "/launcher": "https://github.com/MCMrARM/mc-w10-version-launcher/releases/tag/0.1.0", + "/blacklist": "Done! That felt good", + "!Walk-On": "Walk On with hope in your hearts and You'll Never Walk Alone", + "/welcome": "Welcome! <:Cake:619552132298964993>", + "/leaderboards": "https://www.speedrun.com/mcbe", + "@testy": "test", + "!uwu": "uwu", + "/Don't": "Buy The Sun Newspaper", + "!For-your-dreams": "be tossed and blown", + "/swipe": "not an alt", + "!HereWeGo": "10 in a Row!", + "/Make": "Troll Supermod", + "!h": "<@!199070670221475842> no swearing in this christian discord server", + "/boards": "https://www.speedrun.com/mcbe", + "/ban": "shut up", + "/pending": "this annoys me", + "/locate": "head north", + "/ssg": "https://www.speedrun.com/mcbe#Any_Glitchless", + "!When-you-walk-through-a-storm": "hold your head up high", + "!lenny": "( \u0361\u00b0 \u035c\u0296 \u0361\u00b0)", + "!hwg": "10 iar", + "!GlasgowRangers": "You Let Your Club Die!", + "!murray": "the irishest of the Irish", + "!e\ud83c\udd71\ufe0fic": "HEY GUYS ITS SHIGAME45", + "!testy": "test", + "!toxicitypass": "```TOXICITY PASS\n\nTHE HOLDER OF THIS PASS HAS PERMISSION FROM THE HEAVENS ABOVE TO DO AND SAY WHATEVER THE HELL THEY WANT\nTHEY ARE ALLOWED TO BE AS TOXIC AS THEY WILL WITHOUT REPERCUSSIONS\n\nPASS OWNER: Duck W aka Weexy aka Indy Kambeitz```" +} \ No newline at end of file diff --git a/main.py b/main.py old mode 100755 new mode 100644 diff --git a/palette.png b/palette.png old mode 100755 new mode 100644 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..34add31 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,16 @@ +asyncio==3.4.3 +discord.py>=1.3.3 +colorama==0.4.3 +GitPython==2.1.15 +google-api-core==1.17.0 +google-auth==1.14.1 +google-cloud-core==1.3.0 +google-cloud-translate==2.0.1 +googleapis-common-protos==1.51.0 +pathlib2==2.3.5 +PyNaCl==1.3.0 +python-dateutil==2.8.1 +requests==2.22.0 +selenium==3.141.0 +six==1.12.0 +subprocess32==3.5.4 -- cgit v1.2.3