Giter Site home page Giter Site logo

archon's People

Contributors

jneil1992 avatar timraay avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

archon's Issues

Hey :)

Not really an issue, just commenting to say this is pretty rad :D ๐Ÿ‘

Good luck with the project !

Issue when setting a alert value to Null/None

If you change for example chat_trigger_confirmation to something you cant seem to set it back to Null/None as this is stored in the tables as a string so the confirmation is null or none.

image
image

@timraay is there a way to do this or will it be worth me adding something along the lines of this to the config_menu and instance_config functions

if value.upper() == "NULL" or "NONE": value = None

I have tested this and it appears to work as expected.
image

Add commands for setting map layers

As of Squad V2 two new admin commands were added to set the current or upcoming layer, AdminChangeLayer and AdminSetNextLayer. This works similar to setting the map, but takes a layer as argument instead of a map. A bot command needs to be implemented to execute this command over RCON.

First, register the server command here.

Archon/rcon/commands.py

Lines 107 to 118 in fa83f28

def set_next_map(self, map_name: str):
res = self.exec_command(f"AdminSetNextMap {map_name}")
res = self._res_to_str(res)
return res
def show_current_map(self):
res = self.exec_command(f"ShowCurrentMap")
res = self._res_to_str(res)
return res
def show_next_map(self):
res = self.exec_command(f"ShowNextMap")
res = self._res_to_str(res)
return res

Then, add the bot command and user interface to set the next layer, just like the command for setting the next map. You can get rid of inst.next_map = map_name. Make sure to add the @is_game wrapper as well, to make sure this command only works for Squad servers:

Archon/cogs/moderation.py

Lines 237 to 246 in fa83f28

@commands.command(description="Set the next map", usage="r!set_next_map [map name]", aliases=["next", "next_map", "queue", "queue_map", "view_map"])
@check_perms(moderation=True)
async def set_next_map(self, ctx, *, map_name: str):
inst = self.bot.cache.instance(ctx.author.id, ctx.guild.id)
res = inst.rcon.set_next_map(map_name)
inst.next_map = map_name
embed = base_embed(self.bot.cache.instance(ctx.author.id, ctx.guild.id).id, title="Queued the next map", description=res)
await ctx.send(embed=embed)
ServerLogs(inst.id).add('rcon', f'{ctx.author.name}#{ctx.author.discriminator} queued {map_name}')

Implement a separate cooldown condition for maps and pools

Currently this one can only be set globally. Add a condition named cooldown which takes value as parameter. This condition should overwrite the global cooldown, but when defined multiple times the highest of the conditions should be used. It would be great if this behavior was explained in MAPROTATION.md as well.

This will need a small rework of how cooldown is cached. Rather than setting its cooldown when queued, set it to 0. Then increase it by 1 every time a new match starts.

Disconnected instance not being disconnected - might be cancelling the entire cache update iteration

When an instance can't be connected to for a long time, it should be disconnected until manually reconnected using r!inst reconnect, however that doesn't seem to be working, and an exception is raised. Neither am I seeing any other instances being updated after the error is raised, which could be a severe issue if true.

[10/29 14:42:07][INFO] Inst 0: Updating...
[10/29 14:42:07][INFO] Sending RCON command to 116.202.50.240:21114: ShowCurrentMap
[10/29 14:42:07][WARNING] 116.202.50.240:21114 raised OSError or RconEmptyHeaderError, creating new socket...
[10/29 14:42:07][ERROR] Inst 0: Failed to connect for 5 minutes, disconnecting...
[10/29 14:42:07][ERROR] Inst 0: Unhandled exception whilst updating: ConnectionLost: Lost connection to RCON: Invalid port
Traceback (most recent call last):
  File "/home/archon/Archon/rcon/connection.py", line 141, in exec_command
    self._send_pkt(cmd_pkt)
  File "/home/archon/Archon/rcon/connection.py", line 165, in _send_pkt
    self._sock.sendall(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/archon/Archon/rcon/connection.py", line 101, in _connect_sock
    self._sock = socket.create_connection(address=(self.server, self.port), timeout=10)
  File "/usr/lib/python3.8/socket.py", line 808, in create_connection
    raise err
  File "/usr/lib/python3.8/socket.py", line 796, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/archon/Archon/rcon/cache.py", line 187, in update
    self._parse_maps()
  File "/home/archon/Archon/rcon/cache.py", line 280, in _parse_maps
    current_map = self.rcon.show_current_map()
  File "/home/archon/Archon/rcon/commands.py", line 117, in show_current_map
    res = self.exec_command(f"ShowCurrentMap")
  File "/home/archon/Archon/rcon/connection.py", line 145, in exec_command
    self._connect_sock()
  File "/home/archon/Archon/rcon/connection.py", line 105, in _connect_sock
    raise RconAuthError("Invalid port")
rcon.connection.RconAuthError: Invalid port

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/archon/Archon/cogs/logs.py", line 230, in check_server
    await self._query(inst)
  File "/home/archon/Archon/cogs/logs.py", line 94, in _query
    inst.update()
  File "/home/archon/Archon/rcon/cache.py", line 200, in update
    raise ConnectionLost("Lost connection to RCON: " + str(e))
rcon.cache.ConnectionLost: Lost connection to RCON: Invalid port

Not logging anything

I love how the bot is set up and works. The problem is it just doesn't seem to want to log anything.

Avoidable timeout on chat retrieval

image

In cogs/logs.py

inst.rcon.exec_command("a")
, cf lines in screenshot above:

If there has been no new messages since the last execution of _query (more precisely of inst.rcon.exec_command("a")), then self._sock.recv(HEADER_SIZE) in _recv_pkt (

def _recv_pkt(self, skip_empty_headers=True):
) will hang and cause a timeout.

While this is not critical, it is avoidable (timeouts last ~10s, making the whole execution hang). All that is needed is to check if the socket has new content before executing _recv_pkt (or earlier) via:

import select

r, _, _ = select.select([self._sock], [], [], 0)
if len(r) == 0: return  # the socket doesn't have new content

Create a list of Post Scriptum maps and layers

As of Archon v1.2, Post Scriptum is now (officially) supported. The same update also adds a smart map rotation module, but to make sure all given maps are valid a list of all maps and layers is needed. I was able to compile one for both Squad and Beyond The Wire, but since I don't own Post Scriptum and the Wiki is incomplete I am unable to create one for Post Scriptum.

It would be amazing if someone could compile this list for me. Launch the game, open the console and give every possible parameter for AdminChangeMap.

Cache the creator of a squad

This is currently not possible with any tool that I know of and would be a nice addition to punish creators of squads with offensive names without accidentally punishing someone who just got transferred leadership because the previous SL left.

Whenever a squad is created, the player that is listed first is usually the SL (unless he left before the cache got updated, which can't be accounted for sadly). Then, display that info in the r!squad command.

Unable to connect to the server: Unknown host

The bot is not recognizing servers anymore can we possibly get an update/look into this thanks very much.

Archon
BOT
โ€” Today at 16:02
Trying to establish a connection...
Unable to connect to the server: Unknown host

Often chat messages are not caught by the RCON

Possible caused by the end of multipacket response being attached with the chat message (and the chat message having the wrong packet type). This was observed on Squad version b-17.0.13.23847.

e.g. packet body: b'\x00\x00\x00\x01\x00\x00\x00[ChatAll] this is example chat\x00\x00'.

some error can't run bot.py

Python 3.8.18

PS C:\PostScriptum Bot\Archon> python.exe .\bot.py
Traceback (most recent call last):
  File ".\bot.py", line 151, in <module>
    logging.basicConfig(format='[%(asctime)s][%(levelname)s] %(message)s', datefmt='%m/%d %H:%M:%S', filename=logname, filemode='w+', level=logging.INFO)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1988, in basicConfig
    h = FileHandler(filename, mode)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1147, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\logging\__init__.py", line 1176, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)

BTW and PS servers won't have their maps cached

Since in Squad V2 the commands to show current and next map have been changed, the way the bot handles this was adjusted. This has completely replaced the old system that BTW and PS servers still use though. Re-add the old method, and pick one of the two depending on the instance's configured game.

trailing comma in chat_trigger_words results in all chats being triggered

This is probably a rare corner case, but today it was noticed that all chats were sending an alert to configured chat trigger channell. Due to a comma being left at the end of the chat_trigger_words.

This is something you may or may not think its necessary to have logic in place for however was a quick easy fix. @timraay will raise a pull request and a) let you decide if this is even something that needs logic added for b) if I have done it in the most efficient way.

Chat to channel stops working after a while

Noticed that when you have chat stream to a channel it stops updating after a while, If you then run a command such as r!logs r!chat it seem to update with a bunch of messages then work for a little while then stops again.

Make map cooldowns ignore layers

Currently the map rotation module should be avoided because the risk of queueing the same map (but with a different) after another. Maps should be stripped of their layer and version, as well as additional prefixes they may have (looking at you, CAF).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.