Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from cw #18

Merged
merged 46 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b575fec
Changes from vanilla (#92)
stonedDiscord Jun 21, 2023
076ab94
Add an admin command /multiclients <ipid>:
Crystalwarrior Jul 1, 2023
fd6b685
Merge branch 'master' of https://github.com/Crystalwarrior/KFO-Server
Crystalwarrior Jul 1, 2023
e110435
Update commands.md
Crystalwarrior Jul 3, 2023
4f3a602
fix area's max_msg_delay not being saved on hub save
Crystalwarrior Jul 21, 2023
87740f9
Merge branch 'master' of https://github.com/Crystalwarrior/KFO-Server
Crystalwarrior Jul 21, 2023
974dc53
Set default max msg delay to the same amount as min msg delay so user…
Crystalwarrior Aug 17, 2023
719ab8f
Discontinue max_msg_delay cuz it makes no sense to have variable dela…
Crystalwarrior Aug 17, 2023
f6036c8
Rename min_msg_delay to just msg_delay and use it raw, discontinuing …
Crystalwarrior Aug 17, 2023
b68cc77
Fix a major exploit allowing relative paths to be used for nefarious …
Crystalwarrior Sep 15, 2023
5b4d335
make derelative more robust (thx @chrezm!)
Crystalwarrior Sep 15, 2023
0a3c022
left an \ in there oops
Crystalwarrior Sep 15, 2023
1f4f284
Presenting the Emote Queue: Mid-Text Emote Swapping (#94)
Satoru-1816 Oct 7, 2023
2980721
Readme stuff (#95)
OmniTroid Nov 1, 2023
9c7dded
Handle the missing cases (#96)
SymphonyVR Nov 3, 2023
d095de3
Mid-text emotes - remove induced pause
Crystalwarrior Nov 3, 2023
7af6efc
Add advertising for secure websocket (#97)
OmniTroid Nov 3, 2023
cbe2fe2
Initial AOG 1.0 RC1 release (#100)
SymphonyVR Nov 5, 2023
cd108e1
Revert "Add advertising for secure websocket (#97)"
Crystalwarrior Nov 5, 2023
cf29ad8
AOG RC1 hotfix (#102)
SymphonyVR Nov 6, 2023
6c8e1ae
Refactored masterserverclient.py (#101)
SymphonyVR Nov 6, 2023
d39a0ac
Fix demos relying on narrator mode while changing pos being broken
Crystalwarrior Nov 7, 2023
c525707
Merge branch 'master' of https://github.com/Crystalwarrior/KFO-Server
Crystalwarrior Nov 7, 2023
a16a005
Log the demo MS packets into last_ic_message
Crystalwarrior Nov 7, 2023
38de4a2
save last_ic_message only *after* the command is sent
Crystalwarrior Nov 7, 2023
7967ed2
Fix music channel packet not validating properly
Crystalwarrior Nov 8, 2023
5810aac
Fix narration for demos in a proper way
Crystalwarrior Nov 8, 2023
3e0e90b
Fix modcall ping not working with role ID properly
Crystalwarrior Nov 11, 2023
afe5062
Refactor logging 2 (#103)
OmniTroid Nov 12, 2023
57692bf
Remove all .idea-related files (#104)
OmniTroid Nov 12, 2023
9e10452
add .vscode to gitignore again
Crystalwarrior Nov 12, 2023
412212c
Remove copyright notices in files (#105)
OmniTroid Nov 13, 2023
77819b0
Rewrite readme (#106)
OmniTroid Nov 14, 2023
9a3f602
Advertise secure websockets again (#107)
OmniTroid Nov 16, 2023
e5c700d
Use back for unix-start (#109)
OmniTroid Nov 20, 2023
f386864
Add the ability to use the DL Manager functionality outside of AOG (#…
SymphonyVR Nov 25, 2023
8d1c7b6
= to repeat sentence during the testimony (#113)
EstatoDeviato Nov 26, 2023
f651115
/pm now works if target is in a different hub (#112)
EstatoDeviato Nov 27, 2023
683e52d
Add the command /gethubs (#114)
EstatoDeviato Dec 2, 2023
63a6a96
add dl.vgmdownloads.com to the url.txt config sample (khinsider moved…
Crystalwarrior Feb 29, 2024
2477f85
Merge branch 'master' of https://github.com/Crystalwarrior/KFO-Server
Crystalwarrior Feb 29, 2024
a04fa28
Fix only showname being displayed with cid skipped on notecard, rolla…
Crystalwarrior Mar 1, 2024
829ee7f
Add a Rock Paper Scissors command (#116)
Crystalwarrior Mar 1, 2024
ba0e2bd
Don't show duplicate rps choices as 'available'
Crystalwarrior Mar 1, 2024
0a21dbd
Fix area.area_manager.hub reference (area_manager *is* the hub)
Crystalwarrior Mar 4, 2024
c03a340
Merge branch 'master' into master
stonedDiscord Mar 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,8 @@ coverage.xml
.hypothesis/
.pytest_cache/

### PyCharm
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# JetBrains stuff
.idea/

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

### VSCode
.vscode/

#why?
os
subprocess
sys
# VSCode
.vscode/
7 changes: 0 additions & 7 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/tsuserver3.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: python
python:
- "3.7"
- "3.11"
stages:
- execute

Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-alpine
FROM python:3.11-alpine

RUN apk --no-cache add git

Expand All @@ -10,7 +10,6 @@ RUN pip install -r requirements.txt

COPY server/ server/
COPY migrations/ migrations/
COPY characters/ characters/
COPY storage/ storage/

CMD python ./start_server.py

130 changes: 47 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,118 +3,82 @@

KFO-Server is the official Python-based server for Attorney Online, forked from tsuserver3.

## Commands
## Server setup

Documentation: ["Commands"](https://github.com/Crystalwarrior/KFO-Server/blob/master/docs/commands.md). You may also use the /help documentation on the server.

## Easy setup instructions

The server will not work out of the box. **You must follow these instructions.**
In order to set up the server, you must follow these instructions. This assumes you are familiar with using a terminal.

### Install Python

* Install the [latest version of Python](https://www.python.org/downloads/). **Python 2 will not work**, as KFO-Server depends on async/await, which can only be found on Python 3.7 and newer.
- If you run Windows, make sure to check the "Add Python to PATH" and install pip checkboxes in the installer
- If you run anything other than Windows, you should read "Advanced setup instructions" below.

### Download KFO-Server

We recommend [Git](https://git-scm.com/downloads/guis) - it makes it very easy to update tsuserver. But we are power users and therefore inherently biased. You can instead download the latest zip of KFO-Server with [this link](https://github.com/Crystalwarrior/KFO-Server/archive/refs/heads/master.zip). Extract it and put it wherever you want.
* Install the [latest version of Python](https://www.python.org/downloads/). You will need Python 3.11 or newer.
* If you run Windows, make sure to check the "Add Python to PATH" and install pip checkboxes in the installer
* If you run anything other than Windows, you should read "Advanced setup instructions" below.

### Install dependencies
### Download server software

* Open Command Prompt or your terminal, and change to the directory where you downloaded KFO-Server to. You can do this in two ways:
- Go up one folder above the KFO-Server folder, Shift + right click the KFO-Server folder, and click `Open command window here`. This is the easiest method.
- Copy the path of the KFO-Server folder, open the terminal, and type in `cd "[paste here]"`, excluding the brackes, but including the quotation marks if the path contains spaces.
* To install PyYAML and dependencies, type in the following:
```bash
python -m pip install --user -r requirements.txt
```
If you are using Windows and have both Python 2 and 3 installed, you may do the following:
```batch
py -3 -m pip install --user -r requirements.txt
```
This operation should not require administrator privileges, unless you decide to remove the `--user` option.

### Configure tsuserver
We recommend [Git](https://git-scm.com/downloads/guis) for downloading the server software.
This makes it easier to update the server later. In order to use Git, just clone the respository.

* **Rename `config_sample` to `config`**.
* Edit the values in the `.yaml` files to your liking. If you downloaded tsuserver from a zip and try to edit it from Notepad, the line breaks will be missing. That's because Notepad is stupid. Use [Notepad++](https://notepad-plus-plus.org/) instead like the pro you are.
* Be sure to check your YAML file for syntax errors. Use this website: http://www.yamllint.com/
- *Use spaces only; do not use tabs.* That's another reason we recommend anything that isn't Notepad.
* You don't need to copy characters into the `characters` folder *unless* you specifically chose to disable iniswapping in an area (in `areas.yaml`). In this case, all tsuserver needs to know is the `char.ini` of each character. It doesn't need sprites.
* Don't forget to forward ports on your router. You will need to forward both the regular port and the webAO port.
If you don't want to use Git, you can download the latest zip of KFO-Server [here](https://github.com/Crystalwarrior/KFO-Server/archive/refs/heads/master.zip). Extract it and put it wherever you want.

### Run

* Run by either double-clicking `start_server.py` or typing in `py -3 start_server.py` if you use both Python 2 and 3. It is normal to not see any output once you start the server.
- To stop the server, press Ctrl+C multiple times.

## Advanced setup instructions
### Install dependencies

For servers that are intended to run for an extended period of time, Linux is recommended. Linux distros have a significantly more consistent and sane environment compared to Windows and macOS. These days, Microsoft is trying to cater the operating system it happened to prepackage with Candy Crush to power users by sticking a successful kernel inside its failed Win32 kernel, so you can try [that abomination](https://docs.microsoft.com/en-us/windows/wsl/install-win10) ([or its successor](https://docs.microsoft.com/en-us/windows/wsl/wsl2-install)) if you want. Or you can just use [a darn virtual machine](https://www.virtualbox.org/) instead.
In order to install dependencies, you will need to open a terminal.

I will just assume from now on that you have managed to produce an object that runs Linux.
On Windows, you can do this by pressing Win+R, typing in `cmd`, and pressing Enter.
On Linux, you can do this by pressing Ctrl+Alt+T.

### Using Docker
You should then navigate to the folder where the server is located.

The easiest way to set up and start tsuserver is with the Dockerfile. You just [install Docker](https://get.docker.com/) and [install Docker Compose](https://docs.docker.com/compose/install/).
Take note that depending on your operating system, the command for python may be python3 or python.
You should also verify the version by running `python --version` or `python3 --version`.

Once you have everything configured, do `sudo docker-compose up`. It will build the image and start tsuserver up for you. If you accidentally restart the server, the container will automatically start back up. If you're not understanding why it's starting, try starting it up manually:
First, we need to create the virtual environment. This can be done by running the following command:

```sh
sudo docker run -it -d -v `pwd`/storage:/app/storage -v `pwd`/logs:/app/logs -v `pwd`/config:/app/config -p 27018:27018 -p 27017:27017 --restart=unless-stopped tsuserver
```bash
python -m venv venv
```

Here is a breakdown of the command:
* `-it` puts an *interactive* *terminal* so that the output of the command line can be reaped later with `docker logs`. Without these options, the output is closed and printing things to the log will then break Python.
* `-d` starts the container in the background (`detached`).
* `-v SOURCE:TARGET` mounts the SOURCE directory on the host filesystem into the container's virtual filesystem at the TARGET location, so that we can modify server files without having to rebuild the entire image. However, SOURCE can't be a relative path, so we make an absolute path with `pwd`.
* `-p SOURCE:TARGET` exposes port SOURCE inside the container as port TARGET in the whole machine. This way, a port can be connected to by anyone, not just the machine which Docker is being run in.
* `--restart=unless-stopped` sets the restart policy to always restart, even after reboot, unless the container is explicitly stopped with `docker stop`.
* `tsuserver` is the name of the image to start a container from.

Docker is a nifty tool, although I admit that setting it up and understanding how to use it can be tedious.
Then, we need to activate the virtual environment.
If you're on a unix system (bash or similar), you can run the following command:

### Alternative: Using `venv`

`venv` is a tool built into Python to create a virtual Python environment to install packages in. It reduces the risk of mixing up Python versions and package versions. Sometimes, it's even necessary if `pip` installs require sudo privileges. (`sudo pip install` is highly frowned upon as it regularly causes conflicts with the system's own package manager. Don't do it, use `venv` instead!)

Suppose you installed tsuserver in `/home/me/tsuserver` (protip: this path is the same as `~me/tsuserver`).
```bash
./venv/bin/pip install -r requirements.txt
```

You can create a venv with the following command:
If you're on Windows (cmd), you may have to do this instead:

```sh
python3 -m venv /home/me/tsuserver/.venv
```batch
venv\Scripts\pip install -r requirements.txt
```

Then activate the venv:
### Configure tsuserver

```sh
source /home/me/tsuserver/.venv/bin/activate
```
* Copy `config_sample` to `config`
* Edit the values in the `.yaml` files to your liking.
* Be sure to check your YAML file for syntax errors. Use this website: <http://www.yamllint.com/>
* *Use spaces only; do not use tabs.*
* You don't need to copy characters into the `characters` folder *unless* you specifically chose to disable iniswapping in an area (in `areas.yaml`). In this case, all tsuserver needs to know is the `char.ini` of each character. It doesn't need sprites.

Install requirements:
### Run

```sh
cd /home/me/tsuserver
pip install -r requirements.txt
```
You can run the server using one of the helper scripts `start-unix.sh` or `start-windows.bat`.
They run the server using the local environment.

Start the server:
To stop the server, press Ctrl+C in the terminal.

```sh
python start_server.py
```
## Using Docker

You can also use docker to run KFO-server. First you need to install [Docker](https://get.docker.com/) and [Docker Compose](https://docs.docker.com/compose/install/).

You will always need to activate the venv before starting the server.
Once you have everything configured, do `docker-compose up`. It will build the image and start tsuserver up for you. If you accidentally restart the server, the container will automatically start back up. If you're not understanding why it's starting, try starting it up manually:

Refer to ["Creating Virtual Environments"](https://docs.python.org/3/library/venv.html#creating-virtual-environments) in the Python documentation for more information.
## Pro Tips

To keep the server running even after closing the terminal:
* Use a multiplexer, such as screen or tmux. These programs let you have multiple terminals open in a single window, and detach/reattach with them freely. They are extremely convenient.
* Create a systemd service. Not for the faint of heart.
* Use Docker instead.
* To keep the server running even if your login shell is closed, use a multiplexer, such as screen or tmux.
* For more info about available command, see [Commands](https://github.com/Crystalwarrior/KFO-Server/blob/master/docs/commands.md). You may also use the /help command on the server.
* For more info about Python virtual environments, refer to ["Creating Virtual Environments"](https://docs.python.org/3/library/venv.html#creating-virtual-environments)
* In order to join your server, it has to be accessible to the public internet. You might need to forward the ports in config.yaml to make this work.
* If you can't portforward, you may want to check out [ngrok](https://ngrok.com/). It's a service that allows you to expose your local server to the internet. It's free, but you can also pay for a subscription to get more features.

## License

Expand Down
9 changes: 8 additions & 1 deletion config_sample/command_aliases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fp: firstperson
fps: firstperson
ga: getarea
gas: getareas
gh: gethubs
hmovedelay: hub_move_delay
hmusiclist: hub_musiclist
hub_clear: clear_hub
Expand Down Expand Up @@ -100,4 +101,10 @@ swap_testimony: testimony_swap
swaptestimony: testimony_swap
unlistenpos: unlisten_pos
unmuteooc: ooc_unmute
aga: autogetarea
aga: autogetarea
gl: getlink
gls: getlinks
seturl: set_url
surl: set_url
get_link: getlink
get_links: getlinks
9 changes: 9 additions & 0 deletions config_sample/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ motd: Welcome to my server!
# and must also be forwarded.
use_websockets: true
websocket_port: 50001

# Whether or not the server is open to secure websocket connections
# Do note that this requires special setup on the server side (terminating SSL)
use_securewebsockets: false
secure_websocket_port: 50002

# WebAO Asset URL for hosting files. Leave blank to use vanilla
asset_url:

Expand Down Expand Up @@ -88,6 +94,9 @@ ooc_floodguard:
interval_length: 5
mute_length: 30

# Enables to use the command /gethubs
can_gethubs: true

# How many subscripts zalgo is stripped by; 3 is recommended as not to hurt special language diacritics
zalgo_tolerance: 3

Expand Down
5 changes: 5 additions & 0 deletions config_sample/server_links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# You can declare any kind of links here
Content: https://crystalwarrior.github.io/KFO-website/downloads.html
Vanilla: https://ao-dl.b-cdn.net/vanilla_full_2023.6_4.zip
Discord: http://discord.gg/6jk3bWS
webpage: https://aceattorneyonline.com/
2 changes: 2 additions & 0 deletions config_sample/url.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ https://attorneyoffline.de/
https://vgmsite.com/
https://fi.zophar.net/
https://litter.catbox.moe/
https://dl.vgmdownloads.com/

5 changes: 4 additions & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@
* **load\_hub** `<name>`
- Load Hub data from the server's `storage/hubs/<name>.yaml` file.
- If blank and you're a mod, it will reload the server's `config/areas.yaml`.
* **overlay\_hub** `<name>`
- Overlay Hub data from the server's `storage/hubs/<name>.yaml` file on top of the current hub, only applying properties defined in that yaml.
- If blank and you're a mod, it will overlay the server's `config/areas.yaml`.
* **list\_hubs**
- Show all the available hubs for loading in the `storage/hubs/` folder.
* **clear\_hub**
Expand Down Expand Up @@ -534,4 +537,4 @@
- Once everyone has testified, last one to testify or the CM has to say a single word - `end`.
- Afterwards, next time the CM uses "Cross-Examination" button, the testimony title will be replayed, and the defense can use `>` to progress a statement, `<` to precede a statement, `>5` to go to specific statement 5.
- You can use `**msg` to amend the current statement.
- You can use `++msg` to add a new statement after the current one.
- You can use `++msg` to add a new statement after the current one.
32 changes: 25 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
oyaml
websockets
arrow
timeparse-plus
geoip2
discord
pystun3
aiohttp==3.9.0
aiosignal==1.3.1
arrow==1.3.0
async-timeout==4.0.3
attrs==23.1.0
certifi==2023.7.22
charset-normalizer==3.3.2
discord==2.3.2
discord.py==2.3.2
frozenlist==1.4.0
geoip2==4.7.0
idna==3.4
maxminddb==2.5.1
multidict==6.0.4
oyaml==1.0
pystun3==1.0.0
python-dateutil==2.8.2
PyYAML==6.0.1
requests==2.31.0
six==1.16.0
timeparse-plus==1.2.0
types-python-dateutil==2.8.19.14
urllib3==2.1.0
websockets==12.0
yarl==1.9.2
Loading
Loading