Exemplo n.º 1
0
class logger():
    def __init__(self, bot):
        self.bot = bot


    async def on_message(self, message):
        if message.author == self.bot.user:
            return
        if not os.path.exists(log_path):
            os.makedirs(log_path)
        if not os.path.exists(log_path + directory + message.server.name):
            os.makedirs(log_path + message.server.name)
        channel_path = log_path + message.server.name
        if not os.path.exists(channel_path):
            os.makedirs(channel_path)
        try:
            channel = channel_path + directory + message.channel.name
            log = open(channel + ".txt", "a+")
            log.write(str(message.id) + " " + str(message.timestamp) + "  " + str(message.author) + ":" + message.content + "\n")
            log.close()
        except:
            pass


    if config.read('discord-debug'):
        logger = logging.getLogger('discord')
        logger.setLevel(logging.DEBUG)
        handler = logging.FileHandler(filename='discord.log', encoding='utf-8', mode='w')
        handler.setFormatter(logging.Formatter('%(asctime)s:%(levelname)s:%(name)s: %(message)s'))
        logger.addHandler(handler)
Exemplo n.º 2
0
 async def game(self, ctx, *state):
     await self.bot.send_typing(ctx.message.channel)
     state = ' '.join(state)
     game = discord.Game(name=state)
     if ctx.message.author.id == config.read('owner-id'):
         if state == '':
             await self.bot.change_presence(game=None)
             embed = discord.Embed(
                 title="Game status",
                 description="Kisak's game has been set to ``None``")
             await self.bot.say(embed=embed)
         else:
             await self.bot.change_presence(game=game)
             embed = discord.Embed(
                 title="Game status",
                 description="Kisak's game status has been set to ``" +
                 game.name + "``",
                 color=0x008000)
             await self.bot.say(embed=embed)
     else:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(
             title="Command Error",
             description=
             "This command may only be executed by the bot owner",
             color=0x990000)
         await self.bot.say(embed=embed)
Exemplo n.º 3
0
 async def load(self, ctx, cog):
     if ctx.message.author.id == config.read('owner-id'):
         await self.bot.send_typing(ctx.message.channel)
         self.bot.unload_extension(cog)
         embed = discord.Embed(title="Cog-loaded",
                               description="``" + cog +
                               "`` has been loaded",
                               color=0x008000)
         await self.bot.say(embed=embed)
     else:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(
             title="Command Error",
             description=
             "This command may only be executed by the bot owner",
             color=0x990000)
         await self.bot.say(embed=embed)
Exemplo n.º 4
0
 async def shutdown(self, ctx):
     if ctx.message.author.id == config.read('owner-id'):
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(title="Shutting-down...",
                               description="I am shutting-down!",
                               color=embed_color)
         await self.bot.say(embed=embed)
         self.bot.logout()
         exit(1)
     else:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(
             title="Command Error",
             description=
             "This command may only be executed by the bot owner",
             color=embed_color)
         await self.bot.say(embed=embed)
Exemplo n.º 5
0
 async def restart(self, ctx):
     if ctx.message.author.id == config.read('owner-id'):
         try:
             await self.bot.send_typing(ctx.message.channel)
             embed = discord.Embed(title="Restarting...",
                                   description="I am restarting!",
                                   color=embed_color)
             await self.bot.say(embed=embed)
             self.bot.logout()
             print(colored("Kisak-Bot has restarted", 'red'))
             python = sys.executable
             os.execl(python, python, *sys.argv)
         except:
             pass
     else:
         await self.bot.send_typing(ctx.message.channel)
         embed = discord.Embed(
             title="Command Error",
             description=
             "This command may only be executed by the bot owner",
             color=embed_color)
         await self.bot.say(embed=embed)
Exemplo n.º 6
0
from cogs import config
import discord
from discord.ext import commands
from termcolor import colored

token = config.read('token')
cogs = ['cogs.mod',
        'cogs.misc',
        'cogs.logger',
        'cogs.owner',
        'cogs.rep',
        'cogs.account',
        'cogs.verification',
        'cogs.auto_mod'
        ]

bot = commands.Bot(command_prefix=config.read('command-prefix'))

@bot.event
async def on_ready():
    print(colored("Kiask-Bot has successfully started", 'green'))
    config.initialize()
    for cog in cogs:
            bot.load_extension(cog)
    await bot.change_presence(game=discord.Game(name='moderating valve repositories'))

bot.run(token, bot=False)
Exemplo n.º 7
0
class virus():
    def __init__(self, bot):
        self.bot = bot

    virt.apikey = config.read('virust-api-key')