Esempio n. 1
0
 def send_rcon_command(self,
                       command,
                       raise_errors=False,
                       num_retries=3,
                       timeout=3.0):
     return util.send_rcon_command(self.ip_string, self.port,
                                   self.rcon_password, command,
                                   raise_errors, num_retries, timeout)
Esempio n. 2
0
    def send_rcon_command(self,
                          command,
                          raise_errors=False,
                          num_retries=3,
                          timeout=3.0):
        ip_addr = socket.gethostbyname(self.ip_string)

        return util.send_rcon_command(ip_addr, self.port, self.rcon_password,
                                      command, raise_errors, num_retries,
                                      timeout)
Esempio n. 3
0
 def send_rcon_command(self,
                       command,
                       raise_errors=False,
                       num_retries=3,
                       timeout=3.0):
     encRcon = util.decrypt(dbKey, self.rcon_password)
     if encRcon is None:
         encRcon = self.rcon_password
     return util.send_rcon_command(self.ip_string, self.port, encRcon,
                                   command, raise_errors, num_retries,
                                   timeout)
Esempio n. 4
0
async def live(ctx):
    """send rcon command 'get5_status' to server and get response"""
    isLive = False
    servers = SERVERS.split('--')

    for i in range(len(servers)):
        server = servers[i].split(':')
        resp = send_rcon_command(server[0], int(server[1]), server[2],
                                 'get5_status')
        if resp is None:
            embed = discord.Embed(title=f'Server **{server[3]}** is down!')
            await ctx.send(embed=embed)
        else:
            try:
                resp = json.loads(resp)
            except JSONDecodeError:
                pass
            else:
                if resp['gamestate']:
                    isLive = True
                    msg = f'**Match ID :** {resp["matchid"]}\n' \
                          f'**Match state :** {resp["gamestate_string"]}\n' \
                          f'**Map :** {resp["maps"]["map0"]}\n' \
                          f'**Score :**'

                    embed = discord.Embed(title=server[3], description=msg)
                    embed.add_field(
                        name=f'{resp["team1"]["name"]}',
                        value=f'{resp["team1"]["current_map_score"]}')
                    embed.add_field(
                        name=f'{resp["team2"]["name"]}',
                        value=f'{resp["team2"]["current_map_score"]}')
                    await ctx.send(embed=embed)

    if not isLive:
        embed = discord.Embed(title='No live matches for now')
        await ctx.send(embed=embed)
Esempio n. 5
0
async def rcon(ctx, *args):
    """send rcon command to csgo server and get response in message"""
    _server = ''
    title = ''
    if len(args) < 2:
        msg = '**Invalid usage:** !rcon <server number> <command1> <command2> ...'
    else:
        try:
            server = SERVERS.split('--')[int(args[0]) - 1].split(':')
            _server = server[3]
        except (IndexError, TypeError, ValueError):
            msg = 'Invalid usage <server number> <command>'
            title = None
        else:
            msg = send_rcon_command(
                server[0], int(server[1]), server[2],
                ' '.join(args[i] for i in range(1, len(args))))
            title = f'Command sent to server {_server}'
            if msg is None:
                msg = f'Server **{server[3]}** is down!'
                title = None

    embed = discord.Embed(title=title, description=msg)
    await ctx.send(embed=embed)
Esempio n. 6
0
 def send_rcon_command(self, command, raise_errors=False, num_retries=3, timeout=3.0):
     return util.send_rcon_command(
         self.ip_string, self.port, self.rcon_password,
                                   command, raise_errors, num_retries, timeout)