timraay / archon Goto Github PK
View Code? Open in Web Editor NEWA Discord bot to view and moderate your Squad, Post Scriptum and Beyond The Wire servers through Discord with simple, yet powerful commands.
License: MIT License
A Discord bot to view and moderate your Squad, Post Scriptum and Beyond The Wire servers through Discord with simple, yet powerful commands.
License: MIT License
Not really an issue, just commenting to say this is pretty rad :D ๐
Good luck with the project !
Lines 263 to 264 in 6738775
Currently, Skip Map for PS/BTW when a map/layer is passed will set the next map and not change the current (My bad from when I made changes for squad).
will submit PR shortly
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.
@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
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.
Lines 107 to 118 in fa83f28
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:
Lines 237 to 246 in fa83f28
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.
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
Has it crashed or is this planned?
I love how the bot is set up and works. The problem is it just doesn't seem to want to log anything.
In cogs/logs.py
Line 93 in d4abbec
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
(
Line 166 in d4abbec
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
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
.
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.
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
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'.
As the title says. Have a dynamic bot prefix that automatically selects the instance when a number is inserted into the prefix.
When an alert is sent out, display the team and squad from the player that sent it in the embed, if applicable.
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)
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.
Add a wrapper for the AdminSetServerPassword
command to /rcon/commands.py
with name set_password(password)
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.
Keeps telling me the given team ID is out of range. It might be present in more than just this command.
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.
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).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.