the basics of rsudo
This commit is contained in:
parent
d725403509
commit
49c4aa4e7b
4 changed files with 23 additions and 9 deletions
|
@ -8,7 +8,8 @@ log = logging.getLogger(__name__)
|
|||
|
||||
exts = [
|
||||
'basic',
|
||||
'admin'
|
||||
'admin',
|
||||
'rsudo'
|
||||
]
|
||||
|
||||
|
||||
|
@ -45,12 +46,13 @@ def schedule_bot(loop, config, db):
|
|||
)
|
||||
|
||||
bot.db = db
|
||||
bot.config = config
|
||||
|
||||
try:
|
||||
for ext in exts:
|
||||
bot.load_extension(f'bot.ext.{ext}')
|
||||
log.info('loaded %s', ext)
|
||||
|
||||
loop.create_task(bot.start(config.bot_token))
|
||||
return bot
|
||||
except:
|
||||
log.exception('failed to load %s', ext)
|
||||
|
|
|
@ -10,20 +10,28 @@ log = logging.getLogger(__name__)
|
|||
class Rsudo(Cog):
|
||||
def __init__(self, bot):
|
||||
super().__init__(bot)
|
||||
self.command_channel = None
|
||||
|
||||
async def create_request(self, message):
|
||||
if not self.command_channel:
|
||||
self.command_channel = self.bot.get_channel(
|
||||
self.bot.config.command_channel)
|
||||
|
||||
if not self.command_channel:
|
||||
log.warning('command channel not found')
|
||||
return
|
||||
|
||||
# parse it, follows format command,uid
|
||||
uid = message.split(',')[-1]
|
||||
command = ','.join(message.split(',')[:-1])
|
||||
|
||||
log.info(f'[rsudo] {uid!r} {command!r}')
|
||||
|
||||
if not self.command_channel:
|
||||
return
|
||||
|
||||
e = discord.Embed(title=f'rsudo from uid {uid}')
|
||||
e.add_field(name='command', value=f'`{command}`')
|
||||
await self.command_channel.send(embed=e)
|
||||
m = await self.command_channel.send(embed=e)
|
||||
|
||||
await m.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
||||
await m.add_reaction('\N{CROSS MARK}')
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue