Skip to content

Commit

Permalink
added debug and invites
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementJ18 committed Jul 31, 2017
1 parent c715b76 commit be07598
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
39 changes: 37 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import traceback
import re
from simpleeval import simple_eval
import inspect


#prefix command
Expand Down Expand Up @@ -514,8 +515,40 @@ async def test(cont, arg0):
@is_necro()
async def invites(cont):
for server in bot.servers:
invite = await bot.create_invite(server)
await bot.say("Server: " + server.name + " - " + invite.url)
try:
invite = await bot.create_invite(server)
await bot.say("Server: " + server.name + " - " + invite.url)
except:
await bot.say("I don't have the necessary permissions on " + server.name)

@bot.command(pass_context=True)
@is_necro()
async def debug(cont, *, arg0 : str):
"""Evaluates code."""
code = arg0.strip('` ')
python = '```py\n{}\n```'
result = None

env = {
'bot': bot,
'cont': cont,
'message': cont.message,
'server': cont.message.server,
'channel': cont.message.channel,
'author': cont.message.author
}

env.update(globals())

try:
result = eval(code, env)
if inspect.isawaitable(result):
result = await result
except Exception as e:
await bot.say(python.format(type(e).__name__ + ': ' + str(e)))
return

await bot.say(python.format(result))

# *****************************************************************************************************************
# Regular Commands
Expand Down Expand Up @@ -728,6 +761,8 @@ async def on_message(message):

logit(message)
await bot.process_commands(message)
elif message.content.startswith(tuple(prefixes)) and message.channel.is_private:
await bot.send_message(message.channel, "Sorry, due to the way the bot works you cannot use commands in DMs")

bot.loop.create_task(hourly_save())
token = open("data/token.txt", "r").read()
Expand Down
8 changes: 7 additions & 1 deletion data/logfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,4 +559,10 @@ Mon Jul 31 09:32:44 2017: Necro#6714 used n!ping
Mon Jul 31 09:33:11 2017: Necro#6714 used n!serverinfo
Mon Jul 31 09:33:22 2017: Necro#6714 used n!avatar <@!241942232867799040>
Mon Jul 31 09:34:00 2017: Necro#6714 used n!automod add <@339330190742126595>
Mon Jul 31 09:58:37 2017: Necro#6714 used n!invites
Mon Jul 31 09:58:37 2017: Necro#6714 used n!invites
Mon Jul 31 10:13:19 2017: Necro#6714 used n!debug print("hello world")
Mon Jul 31 10:14:04 2017: Necro#6714 used n!off
Mon Jul 31 10:14:13 2017: Necro#6714 used n!debug print("hello world")
Mon Jul 31 10:14:37 2017: Necro#6714 used n!debug bot.send_message(cont.message.channel, "hello world")
Mon Jul 31 10:15:12 2017: Necro#6714 used n!debug bot.send_message(channel, "hello world")
Mon Jul 31 10:15:39 2017: Necro#6714 used n!off
2 changes: 1 addition & 1 deletion data/userdata.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
241942232867799040,65897,22,The Bot Smith,2167,"{'311630847969198082': 7, '236997924427530241': 7, '288255618341666827': 7}","test warning1, testwarning2,muted #1"
241942232867799040,65897,22,The Bot Smith,2190,"{'311630847969198082': 7, '236997924427530241': 7, '288255618341666827': 7}","test warning1, testwarning2,muted #1"
317619283377258497,698562,32, ,4667,"{'311630847969198082': 2, '236997924427530241': 0, '288255618341666827': 0}",test warning 1 by Necro#6714 on server The Land of Shadow
227589245731209217,2000,32, ,0,"{'311630847969198082': 0, '236997924427530241': 0, '288255618341666827': 0}",
220502526393450497,2000,32, ,4,"{'311630847969198082': 0, '236997924427530241': 0, '288255618341666827': 0}",
Expand Down

0 comments on commit be07598

Please sign in to comment.