38 lines
1,013 B
Python
38 lines
1,013 B
Python
import logging
|
|
|
|
import discord
|
|
|
|
from .common import Cog
|
|
|
|
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}')
|
|
e = discord.Embed(title=f'rsudo from uid {uid}')
|
|
e.add_field(name='command', value=f'`{command}`')
|
|
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):
|
|
bot.add_cog(Rsudo(bot))
|