Skip to content

Commit

Permalink
Update to Alpha 1.1.0
Browse files Browse the repository at this point in the history
Added first command accessible to every user, fixed illegal character bug, modified the help and developer commands, and changed the web page for uptimerobot
  • Loading branch information
wbourne0 committed Sep 24, 2019
1 parent 7af0468 commit 5fd17b9
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 54 deletions.
8 changes: 6 additions & 2 deletions cmdDict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import commands.data_tweaking
import commands.Help
import commands.moderation_tools
import commands.fun

cmdDict = {
'muteduration': commands.data_tweaking.set_duration,
'offenseduration': commands.data_tweaking.offense_time,
Expand Down Expand Up @@ -28,5 +30,7 @@
'removewarn': commands.moderation_tools.remove_warn,
'modmail': commands.data_tweaking.mail_channel,
'muterole': commands.data_tweaking.mute_role,
'exec': commands.data_tweaking.Execute
}
'exec': commands.data_tweaking.Execute,
'execute': commands.data_tweaking.Execute,
'roll': commands.fun.roll
}
51 changes: 37 additions & 14 deletions commands/data_tweaking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import discord
import io
import sys
import traceback
from at import argTest
from rw import read, write
from checkTrust import checkTrust
Expand Down Expand Up @@ -58,22 +60,43 @@ def execute(_code, loc):
return globs['__ex']()


async def Execute(args, msg):
async def Execute(args, msg, client):
author = msg.author
if author.id == 527937324865290260 or author.id == 487258918465306634:
f = io.StringIO()
with redirect_stdout(f):
command = msg.content.split(None, 1)[1]
await execute(command, locals())
out = f.getvalue()
if out == '':
out = 'No output.'
await msg.channel.send(
embed=discord.Embed(
title='Unsafe Eval',
description=out
)
)

try:
f = io.StringIO()
with redirect_stdout(f):
command = msg.content.split(None, 1)[1]

await execute(command, locals())
out = f.getvalue()
error = False
except Exception:

traceback_message = traceback.format_exc()
out = sys.exc_info()
done_oof = True
if out != '':
if not done_oof:
await msg.channel.send(
embed=discord.Embed(
title='Unsafe Eval',
description=out
)
)
else:

e_type, e_msg = str(out[0])[8:][:-2], traceback_message
await msg.channel.send(
embed=discord.Embed(
title=f"**{e_type}**",
description=f'```py\n{e_msg}\n```',
color=0xff0000
).set_footer(text='Uh oh, you made an oopsie!')
)
else:
await msg.channel.send('Task completed')


async def trust_role(args, msg):
Expand Down
35 changes: 35 additions & 0 deletions commands/fun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import discord
import asyncio
from random import randint
help_message = '''
**`roll: <amount>d<sides>`** Gets the combined total of <amount> dice with <sides> sides.
'''


async def roll(args, msg):
channel = msg.channel
if len(args) > 1:
temp_msg = await msg.channel.send("Invalid ammount of arguments!")
asyncio.sleep(2)
await temp_msg.delete()
else:
data = args[0].split('d')
ammount = int(data[0])
dice_type = int(data[1])
value = 0
for a in range(ammount):
value += randint(1, dice_type)

embed = discord.Embed(
title='**Results**',
description=f'You rolled `{str(value)}`!',
color=0xfffb00
)
embed.set_footer(
text='Should I add a re-role option? '
'Email [email protected] to reply.'
)
await channel.send(embed=embed)
4 changes: 3 additions & 1 deletion keep_alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

@app.route('/')
def home():
return '<h1>Im in</h1><p> Yay! edwin is making me a website! 🦊</p>'
return '''<a href="https://discordbots.org/bot/610205862090244106" >
<img src="https://discordbots.org/api/widget/610205862090244106.svg" alt="AllSeeingBot" />
</a>'''


def run():
Expand Down
73 changes: 37 additions & 36 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
import os
import asyncio
import keep_alive
import sys
import ast
from dm_message import mod_mail
from rw import read, write
from cmdDict import cmdDict
from content_check import banned_content_check
from content_check import banned_content_check, ignoredChars
from phrase_spam import is_repeating
from encryption_tools import decode
import commands.moderation_tools
from checkTrust import checkTrust
from cryptography.fernet import Fernet
from emojiCheck import count as emoji_count
from commands.moderation_tools import findDate
from role_find import get_muted_role
Expand Down Expand Up @@ -72,37 +68,41 @@ async def on_member_join(member):

guild = member.guild
log_dict = await read('al')
action_log_id = log_dict[guild.id]
log_channel = discord.utils.get(guild.text_channels, id=action_log_id)
username = member.display_name
perma_list = await read('permaMute')
if guild.id in perma_list:
guild_perma_list = perma_list[guild.id]
if member.id in guild_perma_list:
muted_role = await get_muted_role(guild)
await member.add_roles(
muted_role,
reason='User was permanately muted.'
'Role automatically given when they joined.'
)
if guild.id in log_dict:
action_log_id = log_dict[guild.id]
log_channel = discord.utils.get(guild.text_channels, id=action_log_id)
username = member.display_name
perma_list = await read('permaMute')
if guild.id in perma_list:
guild_perma_list = perma_list[guild.id]
if member.id in guild_perma_list:
muted_role = await get_muted_role(guild)
await member.add_roles(
muted_role,
reason='User was permanately muted.'
'Role automatically given when they joined.'
)

await log_channel.send(
f'`{username}` was given the mute role because they were'
'muted permanately when they left the server.'
)
await log_channel.send(
f'`{username}` was given the mute role because they were'
'muted permanately when they left the server.'
)

guild_mute_list = (await read('muteList'))[guild.id]
if member.id in guild_mute_list:
muted_role = await get_muted_role(guild)
await member.add_roles(
muted_role,
reason='User\'s mute time is not up yet. They were muted again so they'
'can\'t evade mute.'
)
await log_channel.send(
f'`{username}` was given the mute role because they were'
'muted muted before they left the server, and their duration is not up.'
)
mute_list = await read('muteList')
if guild.id in mute_list:
guild_mute_list = mute_list[guild.id]

if member.id in guild_mute_list:
muted_role = await get_muted_role(guild)
await member.add_roles(
muted_role,
reason='User\'s mute time is not up yet. They were muted again so they'
'can\'t evade mute.'
)
await log_channel.send(
f'`{username}` was given the mute role because they were'
'muted muted before they left the server, and their duration is not up.'
)


@client.event
Expand All @@ -119,7 +119,7 @@ async def log(text, guild, title='Edit'):
description=text,
color=0x345beb
)

log_channel = discord.utils.get(guild.text_channels, id=action_log_id)
try:
await log_channel.send(embed=log_embed)
Expand Down Expand Up @@ -549,7 +549,8 @@ async def on_message(message):
try:
print(repr(content))

content = content.replace("'", '')
for character in ignoredChars:
content = content.replace(character, '')
yesAnnotherThing = str(repr(content).encode('ascii'))

if content not in (yesAnnotherThing).replace('\\n', '\n'):
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ flask
asyncio
motor
emoji
cryptography
cryptography
dnspython==1.16.0

0 comments on commit 5fd17b9

Please sign in to comment.