1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-25 06:37:29 +00:00

Merge branch 'dev'

This commit is contained in:
Myned 2017-10-16 14:07:18 -04:00
commit 3f683db19c
6 changed files with 38 additions and 31 deletions

View file

@ -437,8 +437,7 @@ class MsG:
raise exc.GoTo raise exc.GoTo
elif reaction.emoji == '' and reaction.message.content == paginator.content and (user is ctx.author or user.id == u.config['owner_id']): elif reaction.emoji == '' and reaction.message.content == paginator.content and (user is ctx.author or user.id == u.config['owner_id']):
raise exc.Right raise exc.Right
else: return False
return False
def on_message(msg): def on_message(msg):
with suppress(ValueError): with suppress(ValueError):
@ -611,8 +610,7 @@ class MsG:
raise exc.GoTo raise exc.GoTo
elif reaction.emoji == '' and reaction.message.content == paginator.content and (user is ctx.author or user.id == u.config['owner_id']): elif reaction.emoji == '' and reaction.message.content == paginator.content and (user is ctx.author or user.id == u.config['owner_id']):
raise exc.Right raise exc.Right
else: return False
return False
def on_message(msg): def on_message(msg):
with suppress(ValueError): with suppress(ValueError):

View file

@ -59,17 +59,20 @@ class Bot:
async def invite(self, ctx): async def invite(self, ctx):
await ctx.send('🔗 https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(u.config['client_id'], u.config['permissions']), delete_after=10) await ctx.send('🔗 https://discordapp.com/oauth2/authorize?&client_id={}&scope=bot&permissions={}'.format(u.config['client_id'], u.config['permissions']), delete_after=10)
@commands.command(aliases=['presence', 'game'], hidden=True) @commands.command(name=',status', aliases=[',presence', ',game'], hidden=True)
@commands.is_owner() @commands.is_owner()
@checks.del_ctx() @checks.del_ctx()
async def status(self, ctx, game): async def status(self, ctx, *, game=None):
try: if game is not None:
if game is not None: await self.bot.change_presence(game=d.Game(name=game))
await self.bot.change_presence(game=d.Game(name=game)) u.config['playing'] = game
else: u.dump(u.config, 'config.json', json=True)
raise exc.NotFound else:
except exc.NotFound: await self.bot.change_presence(game=None)
await ctx.send('❌ **No game given.**', delete_after=10) u.config['playing'] = 'None'
u.dump(u.config, 'config.json', json=True)
await ctx.message.add_reaction('')
class Tools: class Tools:

View file

@ -82,7 +82,7 @@ class Utils:
print('Service built.') print('Service built.')
@commands.command(aliases=['up', 'u', 'vid', 'v']) @commands.command(aliases=['up', 'u', 'vid', 'v'])
@checks.is_listed() @commands.has_permissions(administrator=True)
async def upload(self, ctx): async def upload(self, ctx):
global youtube global youtube
attachments = ctx.message.attachments attachments = ctx.message.attachments

View file

@ -11,7 +11,6 @@ from discord.ext.commands import errors as errext
from utils import utils as u from utils import utils as u
owner_id = u.config['owner_id'] owner_id = u.config['owner_id']
listed_ids = u.config['listed_ids']
def is_owner(): def is_owner():
@ -32,12 +31,6 @@ def is_mod():
return commands.check(predicate) return commands.check(predicate)
def is_listed():
def predicate(ctx):
return ctx.message.author.id in listed_ids
return commands.check(predicate)
def owner(ctx): def owner(ctx):
return ctx.message.author.id == owner_id return ctx.message.author.id == owner_id

View file

@ -34,6 +34,11 @@ async def on_ready():
# bot.loop.create_task(u.clear(booru.temp_urls, 30*60)) # bot.loop.create_task(u.clear(booru.temp_urls, 30*60))
if u.config['playing'] is not 'None':
await bot.change_presence(game=d.Game(name=u.config['playing']))
else:
await bot.change_presence(game=None)
if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel): if isinstance(bot.get_channel(u.config['startup_channel']), d.TextChannel):
await bot.get_channel(u.config['startup_channel']).send('**Started** ☀️ .') await bot.get_channel(u.config['startup_channel']).send('**Started** ☀️ .')
print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name)) print('\n\\ \\ \\ \\ \\ \\ \\ \\ \\\nC O N N E C T E D : {}\n/ / / / / / / / /\n'.format(bot.user.name))

View file

@ -1,5 +1,5 @@
import asyncio import asyncio
import json import json as jsn
import os import os
import pickle as pkl import pickle as pkl
import subprocess import subprocess
@ -19,12 +19,12 @@ print('\nPID : {}\n'.format(os.getpid()))
try: try:
with open('config.json') as infile: with open('config.json') as infile:
config = json.load(infile) config = jsn.load(infile)
print('config.json loaded.') print('config.json loaded.')
except FileNotFoundError: except FileNotFoundError:
with open('config.json', 'w') as outfile: with open('config.json', 'w') as outfile:
json.dump({'client_id': 0, 'listed_ids': [0], 'owner_id': 0, 'permissions': 126016, 'prefix': ',', jsn.dump({'client_id': 0, 'owner_id': 0, 'permissions': 126016, 'playing': 'a game', 'prefix': ',',
'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True) 'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True)
raise FileNotFoundError( raise FileNotFoundError(
'Config file not found: config.json created with abstract values. Restart run.py with correct values.') 'Config file not found: config.json created with abstract values. Restart run.py with correct values.')
@ -42,14 +42,22 @@ def setdefault(filename, default=None):
return pkl.load(iofile) return pkl.load(iofile)
def load(filename): def load(filename, *, json=False):
with open(filename, 'rb') as infile: if not json:
return pkl.load(infile) with open(filename, 'rb') as infile:
return pkl.load(infile)
else:
with open(filename) as infile:
return jsn.load(infile)
def dump(obj, filename): def dump(obj, filename, *, json=False):
with open(filename, 'wb') as outfile: if not json:
pkl.dump(obj, outfile) with open(filename, 'wb') as outfile:
pkl.dump(obj, outfile)
else:
with open(filename, 'w') as outfile:
jsn.dump(obj, outfile, indent=4, sort_keys=True)
settings = setdefault('settings.pkl', {'del_ctx': []}) settings = setdefault('settings.pkl', {'del_ctx': []})