Skip to content

Commit

Permalink
some update
Browse files Browse the repository at this point in the history
  • Loading branch information
apmapmapm committed Nov 17, 2023
1 parent 42bd638 commit b185b97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mastermelon/anti_mindus_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def vkick_anti_bot(message,bot,autoban_counts):
ban_command = message.content.split("\n")[2] # ban by ip
ban_command= ban_command.split('-1 "')[1][:-1]
await autoban_message.channel.send(f"☠️{autoban_counts[0]} this is the send command to servers: "+ban_command+"\nsending command")
await console_commands.sendcommandtoserver(autoban_message,-1,ban_command)
await console_commands.sendcommandtoserver(autoban_message,-1,ban_command,False)

async def plugin_anti_bot(message,bot,autoban_counts):

Expand All @@ -36,4 +36,4 @@ async def plugin_anti_bot(message,bot,autoban_counts):
subnet_ip = ".".join(strr)
sendcmd = f"subnet-ban add {subnet_ip}"
await message.channel.send(f"☠️☠️{autoban_counts[1]}🤖🤖 autoban activated sending this command to servers: {sendcmd}")
await console_commands.sendcommandtoserver(autoban_message,-1,sendcmd)
await console_commands.sendcommandtoserver(autoban_message,-1,sendcmd,False)
13 changes: 7 additions & 6 deletions mastermelon/console_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def readserver(ctx: commands.Context, serverid: int):
else:
pass

async def sendcommandtoserver(ctx: commands.Context, serverid: int, consolecommand: str):
async def sendcommandtoserver(ctx: commands.Context, serverid: int, consolecommand: str, display: bool = True):
# this sends command to server with "enter" at the end
# will print the output after the command is ran
# also, no js is allowed, unless by alex......
Expand All @@ -88,21 +88,22 @@ async def sendcommandtoserver(ctx: commands.Context, serverid: int, consolecomma
try:
if serverid==-1: # this sends to all
for serverid in range(len( servers )):
await send_command_to_1_server(ctx, serverid, consolecommand, servers)
await send_command_to_1_server(ctx, serverid, consolecommand, servers, display)
else: # just sends to 1
await send_command_to_1_server(ctx, serverid, consolecommand, servers)
await send_command_to_1_server(ctx, serverid, consolecommand, servers, display)
except Exception as e:
strr=traceback.format_exc()
await ctx.channel.send("error occurred 82:" + str(e)+"tb:"+strr)
else:
pass

async def send_command_to_1_server(ctx, serverid, consolecommand, servers):
async def send_command_to_1_server(ctx, serverid, consolecommand, servers, display = True):
i,host,screen,port,loc = servers[serverid]
await ctx.channel.send(f"sending {consolecommand} to `{i}` `{host}{port}` with screen `{screen}`, waiting 2 seconds")
send_consolecommand(host, f'screen -S {screen} -p 0 -X stuff "{consolecommand}^M"')
await asyncio.sleep(1)
await showconsole(ctx, i, host, screen, port)
if display:
await asyncio.sleep(1)
await showconsole(ctx, i, host, screen, port)

async def showconsole(ctx, i, host, screen, port):
await ctx.channel.send(f"reading console on `{i}` `{host}{port}` with screen `{screen}`", delete_after=3)
Expand Down

0 comments on commit b185b97

Please sign in to comment.