async def on_message(self, msg): tag = "common" if str(msg.channel.type) == 'private' and msg.author != self.bot.user: print(time_info.UTC_8() + str(msg.author) + '說:' + msg.content) ''' 下面那兩行是當有人密機器人訊息 機器人就會轉寄訊息給owner 怕給太多人困擾預設關閉 要使用的把註解"#"拔掉 ''' #own = self.bot.get_user(int(jdata['owner'])) #await own.send(time_info.UTC_8_CH() + '\n' + str(msg.author) + '說:' + msg.content+'\n') fp = open('./log/' + 'Private.log', 'a', encoding='utf8') fp.write(time_info.UTC_8() + str(msg.author) + '說:' + msg.content + '\n') fp.close() else: if str(msg.channel.type) == 'text' and msg.author != self.bot.user: print(time_info.UTC_8_CH() + str(msg.author) + '說:' + msg.content) a = str(msg.guild) b = str(msg.channel) fp = open('./log/' + a + '-' + b + '.log', 'a', encoding='utf8') fp.write(time_info.UTC_8() + str(msg.author) + '說:' + msg.content + '\n') fp.close() pass
async def turn_off_bot(ctx): if ctx.message.author.id == jdata['owner']: print(f"-----------------------------------------\n{time_info.UTC_8()}\n機器人已關閉" + "\n-----------------------------------------") await ctx.send(time_info.UTC_8() + '\n機器人已關閉') #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< await bot.close() else: await ctx.send(InsufficientPermissions())
async def load(ctx, extension:str ='Null'): if ctx.author.id == jdata['owner']: if extension == 'Null': await ctx.send(NullMod()) else: try: bot.load_extension(F'cmds.{extension}') await ctx.send(f'\n已加載:{extension}') print('\n---------------------------------\n' + time_info.UTC_8() + f'\n已加載 {extension}\n---------------------------------\n') except Exception as e: await ctx.send(f"組件加載失敗\n```cs\n{e}```") logger.error(f'load error: {str(e)}') else: await ctx.send(InsufficientPermissions())