Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
🚑 removed buggy notif duplication detection, will add again in the fu…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
appu1232 committed Apr 12, 2017
1 parent 4dc7abb commit 88dc473
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 50 deletions.
58 changes: 28 additions & 30 deletions appuselfbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,12 @@ async def on_ready():
with open('settings/notify.json', 'r') as n:
notif = json.load(n)
if notif['type'] == 'dm':
if not os.path.isfile('notifs.txt'):
with open('notifs.txt', 'w') as f:
f.write('.')
try:
bot.subpro = subprocess.Popen(['python3', 'cogs/utils/notify.py'])
except (SyntaxError, FileNotFoundError):
bot.subpro = subprocess.Popen(['python', 'cogs/utils/notify.py'])
except:
pass
try:
bot.subpro = subprocess.Popen(['python3', 'cogs/utils/notify.py'])
except (SyntaxError, FileNotFoundError):
bot.subpro = subprocess.Popen(['python', 'cogs/utils/notify.py'])
except:
pass


@bot.command(pass_context=True, aliases=['reboot'])
Expand Down Expand Up @@ -225,28 +222,29 @@ async def on_message(message):

# If the message was sent by me
if message.author.id == bot.user.id:
if message.channel.id not in bot.self_log:
bot.self_log[message.channel.id] = collections.deque(maxlen=100)
bot.self_log[message.channel.id].append(message)
bot.icount += 1
if message.content.startswith(config['customcmd_prefix'][0]):
response = custom(message.content.lower().strip())
if response is None:
pass
else:
if response[0] == 'embed' and embed_perms(message):
try:
await bot.send_message(message.channel, content=None, embed=discord.Embed(colour=0x27007A).set_image(url=response[1]))
except:
await bot.send_message(message.channel, response[1])
if hasattr(bot, 'self_log'):
if message.channel.id not in bot.self_log:
bot.self_log[message.channel.id] = collections.deque(maxlen=100)
bot.self_log[message.channel.id].append(message)
bot.icount += 1
if message.content.startswith(config['customcmd_prefix'][0]):
response = custom(message.content.lower().strip())
if response is None:
pass
else:
await bot.send_message(message.channel, response[1])
await bot.delete_message(message)
else:
response = quickcmds(message.content.lower().strip())
if response:
await bot.delete_message(message)
await bot.send_message(message.channel, response)
if response[0] == 'embed' and embed_perms(message):
try:
await bot.send_message(message.channel, content=None, embed=discord.Embed(colour=0x27007A).set_image(url=response[1]))
except:
await bot.send_message(message.channel, response[1])
else:
await bot.send_message(message.channel, response[1])
await bot.delete_message(message)
else:
response = quickcmds(message.content.lower().strip())
if response:
await bot.delete_message(message)
await bot.send_message(message.channel, response)

notified = message.mentions
if notified:
Expand Down
21 changes: 6 additions & 15 deletions cogs/keywordlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,6 @@ async def notify(self, ctx):
# Set notifications to ping
@notify.command(pass_context=True)
async def ping(self, ctx):
if os.path.isfile('notifs.txt'):
os.remove('notifs.txt')
with open('settings/log.json', 'r+') as log:
location = json.load(log)['log_location']
if location == '':
Expand All @@ -461,8 +459,6 @@ async def ping(self, ctx):
# Set notifications to msg
@notify.command(aliases=['message'], pass_context=True)
async def msg(self, ctx):
if os.path.isfile('notifs.txt'):
os.remove('notifs.txt')
with open('settings/log.json') as l:
location = json.load(l)['log_location']
if location == '':
Expand Down Expand Up @@ -504,21 +500,16 @@ async def dm(self, ctx):
await self.bot.send_message(ctx.message.channel, bot_prefix + 'Set notification type to ``direct messages``. The proxy bot will direct message you.')
if self.bot.subpro:
self.bot.subpro.kill()
if not os.path.isfile('notifs.txt'):
with open('notifs.txt', 'w') as f:
f.write('.')
try:
self.bot.subpro = subprocess.Popen(['python3', 'cogs/utils/notify.py'])
except (SyntaxError, FileNotFoundError):
self.bot.subpro = subprocess.Popen(['python', 'cogs/utils/notify.py'])
except:
pass
try:
self.bot.subpro = subprocess.Popen(['python3', 'cogs/utils/notify.py'])
except (SyntaxError, FileNotFoundError):
self.bot.subpro = subprocess.Popen(['python', 'cogs/utils/notify.py'])
except:
pass

# Set notifications to ping
@notify.command(aliases=['none'], pass_context=True)
async def off(self, ctx):
if os.path.isfile('notifs.txt'):
os.remove('notifs.txt')
with open('settings/notify.json', 'r+') as n:
notify = json.load(n)
notify['type'] = 'off'
Expand Down
6 changes: 1 addition & 5 deletions cogs/utils/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,4 @@ async def on_message(message):
async def on_ready():
pass


if not os.path.isfile('notifs.txt'):
with open('notifs.txt', 'w') as f:
f.write('.')
bot.run(notif["bot_token"])
bot.run(notif["bot_token"])

0 comments on commit 88dc473

Please sign in to comment.