2017-12-02 14:24:55 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import discord
|
|
|
|
|
|
|
|
from .common import Cog
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class Rsudo(Cog):
|
|
|
|
def __init__(self, bot):
|
|
|
|
super().__init__(bot)
|
2017-12-02 15:53:47 +00:00
|
|
|
self.command_channel = None
|
2017-12-02 14:24:55 +00:00
|
|
|
|
|
|
|
async def create_request(self, message):
|
2017-12-02 15:53:47 +00:00
|
|
|
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
|
|
|
|
|
2017-12-02 14:24:55 +00:00
|
|
|
# parse it, follows format command,uid
|
|
|
|
uid = message.split(',')[-1]
|
|
|
|
command = ','.join(message.split(',')[:-1])
|
|
|
|
|
|
|
|
log.info(f'[rsudo] {uid!r} {command!r}')
|
|
|
|
e = discord.Embed(title=f'rsudo from uid {uid}')
|
|
|
|
e.add_field(name='command', value=f'`{command}`')
|
2017-12-02 15:53:47 +00:00
|
|
|
m = await self.command_channel.send(embed=e)
|
|
|
|
|
|
|
|
await m.add_reaction('\N{WHITE HEAVY CHECK MARK}')
|
|
|
|
await m.add_reaction('\N{CROSS MARK}')
|
2017-12-02 14:24:55 +00:00
|
|
|
|
2017-12-02 15:54:14 +00:00
|
|
|
# wait for the check reaction and
|
|
|
|
# execute the command
|
|
|
|
|
|
|
|
# TODO: this
|
|
|
|
|
2017-12-02 14:24:55 +00:00
|
|
|
|
|
|
|
def setup(bot):
|
|
|
|
bot.add_cog(Rsudo(bot))
|