Exemplo n.º 1
0
 async def logs_listen(self, ctx):
     """Listen and parse new logs"""
     if not (config.arc_enabled() and config.gw2el_enabled()):          
         await self.bot.say("You must give a valid gw2 arc dps path and gw2el path")
         return
     self.autologger.start(self.bot, ctx.message.channel)
     await self.bot.say("Listening started")
     return
Exemplo n.º 2
0
 async def logs_stop(self, ctx):
     """Stop automatic logging"""
     if config.diff_id(ctx.message.author.id):
         await self.bot.say('Only the bot owner can use this command')
         return      
     if not (config.arc_enabled() and config.gw2el_enabled()):          
         await self.bot.say("You must give a valid gw2 arc dps path and gw2el path")
         return
     self.autologger.stop()
     await self.bot.say("Logs listening stopped")
     pass
Exemplo n.º 3
0
 async def logs_clean(self, ctx):
     """Clean new faled logs"""
     if config.diff_id(ctx.message.author.id):
         await self.bot.say('Only the bot owner can use this command')
         return       
     if not (config.arc_enabled() and config.gw2el_enabled()):          
         await self.bot.say("You must give a valid gw2 arc dps path and gw2el path")
         return
     self.autologger.clean()
     await self.bot.say("Logs cleaned")
     return
Exemplo n.º 4
0
 async def logs_regroup(self, ctx):
     """Regroup new successful logs"""
     if config.diff_id(ctx.message.author.id):
         await self.bot.say('Only the bot owner can use this command')
         return       
     if not (config.arc_enabled() and config.gw2el_enabled()):          
         await self.bot.say("You must give a valid gw2 arc dps path and gw2el path")
         return
     self.autologger.regroup()
     await self.bot.say("Logs regrouped")
     return
Exemplo n.º 5
0
 async def _listen(self, bot: commands.Bot, channel: discord.Channel):
     exe_path = None
     init_time = time.time()
     ## get gw2 el executable
     if config.gw2el_enabled():
         testpath = config.el_path + '\\GuildWars2EliteInsights.exe'
         os.path.isfile(testpath)
         exe_path = testpath
     while True:
         await asyncio.sleep(15)
         directories = get_immediate_subdirectories(config.arc_path)
         for name in directories:
             ## init dictionary
             if self.__evtcs.get(name, None) is None:
                 self.__evtcs[name] = {}
             if self.__htmls.get(name, None) is None:
                 self.__htmls[name] = {}
             if self.__fevtcs.get(name, None) is None:
                 self.__fevtcs[name] = {}
             if self.__fhtmls.get(name, None) is None:
                 self.__fhtmls[name] = {}
             ## get files in directory
             log_path = os.path.join(config.arc_path, name)
             log_list = os.listdir(log_path)
             for log in log_list:
                 path_to_log = os.path.join(log_path, log)
                 ctime = os.path.getctime(path_to_log)
                 ## file is arc dps log
                 if (log.endswith(".evtc") or
                         log.endswith(".evtc.zip")) and ctime > init_time:
                     ##print(log)
                     log_id = log.split('.')[0]
                     if self.__evtcs[name].get(
                             log_id,
                             None) is None and self.__fevtcs[name].get(
                                 log_id, None) is None:
                         self.__evtcs[name][log_id] = log
                         self.__fevtcs[name][log_id] = log
                         if not exe_path is None:
                             subprocess.run([exe_path, path_to_log])
                 ## file is gw2el log
                 if log.endswith(".html") and ctime > init_time:
                     ##print(log)
                     log_id = log.split('_')[0]
                     if self.__htmls[name].get(
                             log_id,
                             None) is None and self.__fhtmls[name].get(
                                 log_id, None) is None:
                         if "kill" in log:
                             await bot.send_message(channel,
                                                    "Success for " + name)
                             self.__fevtcs[name].pop(log_id)
                             self.__htmls[name][log_id] = log
                             ## send the log to gw2 raidar
                             self.send_log(
                                 os.path.join(log_path,
                                              self.__evtcs[name][log_id]))
                         else:
                             self.__evtcs[name].pop(log_id)
                             self.__fhtmls[name][log_id] = log
                             await bot.send_message(channel,
                                                    "Failure for " + name)
                         ## send the log to the channel
                         await bot.send_file(channel, path_to_log)
     return
Exemplo n.º 6
0
def setup(bot):
    if not (config.arc_enabled() and config.gw2el_enabled()):          
        print("You must give a valid gw2 arc dps path and gw2el path")
        return   
    bot.add_cog(LogsCog(bot))