yacscript 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
@@ -0,0 +1,250 @@
1
+ Metadata-Version: 2.4
2
+ Name: yacscript
3
+ Version: 0.3.0
4
+ Summary: yet another chatroom script.
5
+ Author: Valine0x
6
+ Author-email: Valine0x <me@valine0x.icu>
7
+ License-File: COPYING
8
+ Requires-Dist: bbcode>=1.1.0
9
+ Requires-Dist: captcha>=0.7.1
10
+ Requires-Dist: click>=8.2.1
11
+ Requires-Dist: flask>=3.1.1
12
+ Requires-Dist: flask-socketio>=5.5.1
13
+ Requires-Dist: gevent>=25.5.1
14
+ Requires-Dist: webargs>=8.7.0
15
+ Requires-Python: >=3.13
16
+ Description-Content-Type: text/markdown
17
+
18
+ # YACS
19
+ Yet Another Chatroom Script
20
+
21
+ Inspired by [LE-CHAT-PHP](https://github.com/DanWin/le-chat-php)
22
+
23
+ ![Splash Screen](docs/the-yacs.jpeg)
24
+
25
+ ## Featuring
26
+
27
+ - Multiple channels.
28
+ - Admins.
29
+ - Files and embedded images/videos.
30
+ - BBCode.
31
+ - CAPTCHA.
32
+ - Vanilla HTML & CSS & JS.
33
+ - No Cookies, it's bad for your teeth.
34
+
35
+ ## Try It Out Right Now!
36
+
37
+ Join [The YACS Demo Server](https://chat.valine0x.icu) right now with passphrase **`the-yacs`** to see YACS in action!
38
+
39
+ ## Deployment
40
+
41
+ ### 1. Deploy with venv (Recommended)
42
+
43
+ Create a venv with python version 3.13 or greater.
44
+
45
+ ```bash
46
+ $ python -m venv .venv
47
+
48
+ # Activate venv in bash
49
+ $ source .venv/bin/activate
50
+
51
+ # Activate venv in pwsh
52
+ > . .venv/Scripts/Activate.ps1"
53
+ ```
54
+
55
+
56
+ Then, install the package inside venv.
57
+
58
+ ```bash
59
+ $(venv) pip install yacscript
60
+ ```
61
+
62
+ Create a configuration file and edit it to your liking.
63
+
64
+ For reference, see the <a href="#configuration">configuration section</a>.
65
+
66
+ ```bash
67
+ $(venv) vi ./config.toml
68
+ ```
69
+
70
+ Finally, you run the server within the venv
71
+
72
+ In addition to that, you might want to deploy the program as a daemon. Here's an example of a possible simple unit file for systemd.
73
+
74
+ Assuming you have installed the venv as `/path/to/.venv`, for example `/opt/yacs/.venv`, making `/path/to/` means `/opt/yacs/` for the setup.
75
+
76
+ ```ini
77
+ [Unit]
78
+ Description=YACS Service
79
+ After=network.target
80
+
81
+ [Service]
82
+ Type=simple
83
+ WorkingDirectory=/path/to
84
+ Environment="PATH=/path/to/.venv/bin"
85
+ ExecStart=/path/to/.venv/bin/yacs-run --config /path/to/config.toml
86
+
87
+ [Install]
88
+ WantedBy=multi-user.target
89
+ ```
90
+
91
+ ### 2. Deploy from source (with uv)
92
+
93
+ Deploying from source gives you access to the latest features but may be unstable
94
+
95
+ To deploy from source, first you need to install uv.
96
+
97
+ ```bash
98
+ # Install with pip.
99
+ $ pip install uv
100
+
101
+ # Install on macOS and Linux.
102
+ $ curl -LsSf https://astral.sh/uv/install.sh | sh
103
+
104
+ # Install on Windows.
105
+ $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
106
+ ```
107
+
108
+ Then, clone the repo.
109
+
110
+ ```bash
111
+ $ git clone https://github.com/valine-dev/yacs.git
112
+ $ cd yacs
113
+ ```
114
+
115
+ Create a config file, and edit it to your liking.
116
+
117
+ For reference, see the <a href="#configuration">configuration section</a>.
118
+
119
+ ```bash
120
+ $ vi ./config.toml
121
+ ```
122
+
123
+ Finally, run the server, dependencies and venv will be installed along the way.
124
+
125
+ ```bash
126
+ $ uv run yacs-run --config config.toml
127
+ ```
128
+
129
+ Additionally, it's also possible to make a daemon service out of deployment from source.
130
+
131
+ An example unit file is shown as below.
132
+
133
+ ```ini
134
+ [Unit]
135
+ Description=YACS Service
136
+ After=network.target
137
+
138
+ [Service]
139
+ Type=simple
140
+ WorkingDirectory=/path/to/yacs
141
+ Environment="PATH=/path/to/yacs/.venv/bin"
142
+ ExecStart=/path/to/uv run yacs-run --config /path/to/config.toml
143
+
144
+ [Install]
145
+ WantedBy=multi-user.target
146
+ ```
147
+
148
+ ## User Manual
149
+
150
+ Consult <a href="docs/manual.md">User Manual</a> for guidance.
151
+
152
+ ## Configuration
153
+
154
+ The program comes with a built in config, so you might want to only write fields that you need to deviates from default.
155
+
156
+ All possible fields are shown below.
157
+
158
+ ```toml
159
+ [flask]
160
+ # here you can configure built-in config values defined by flask
161
+ DEBUG = false # DO NOT SET TO `true` WHEN EXPOSING TO PUBLIC!
162
+
163
+ [app]
164
+ # The app itself will only exposed through plain HTTP and it's strongly discorage to do so directly to public web. Use a reverse proxy with TLS in front of the app.
165
+ ip = "0.0.0.0"
166
+ port = 8080
167
+
168
+ admin_phrase = "CHANGE_ME_ADMIN"
169
+ # set user_phrase to empty will expose chatroom to the public
170
+ user_phrase = "CHANGE_ME"
171
+
172
+ log_level = "INFO"
173
+ timeout = 5000 # in milisecond, use for heartbeat
174
+
175
+ # Set to true only when the app is behind a reverse proxy!
176
+ # Make sure X-Forwarded-For and X-Forwarded-Host are properly set!
177
+ proxy_fix = false
178
+
179
+
180
+ [custom]
181
+ title = "The YACS"
182
+ motd = "Hello!\nRule No.1"
183
+
184
+ # These are the emotes that will rendered to the webpage
185
+ emoticons = [
186
+ "( ゚∀。)",
187
+ "Insert Anything",
188
+ "⭐"
189
+ ]
190
+
191
+
192
+ [res]
193
+ path = "./resource" # Relative to project's root
194
+ size_max = 1024 # In Megabytes
195
+
196
+
197
+ [captcha]
198
+ length = 4
199
+ max_cache = 60
200
+ expire = 120 # Expire time in seconds
201
+
202
+ [captcha.options]
203
+ # you don't want to have all of them turn on, it'll be confusing
204
+ numbers = false
205
+ lowercase = true
206
+ uppercase = false
207
+
208
+ [db]
209
+ path = "./yacs.db"
210
+ ```
211
+
212
+ And, an example config could look like this.
213
+
214
+ ```toml
215
+ [flask]
216
+ DEBUG = false
217
+
218
+ [app]
219
+ admin_phrase = "this-is-admin"
220
+ user_phrase = "hello"
221
+
222
+ [custom]
223
+ title = "My YACS Server"
224
+ motd = "Hello!\nRule No.1!"
225
+ ```
226
+
227
+
228
+ ## Customization
229
+
230
+ Yes, you can rewrite templates in `./app/templates/` and static assets in `./app/static/` to customize ya site. It's written in jinja2 template syntax.
231
+
232
+ ## Acknowledgement
233
+ YACS will not be possible without following existing projects.
234
+
235
+ - [98.css](https://github.com/jdan/98.css)
236
+ - [flask](https://github.com/pallets/flask/)
237
+ - [bbcode](https://github.com/dcwatson/bbcode)
238
+ - [webargs](https://github.com/marshmallow-code/webargs)
239
+ - [captcha](https://github.com/lepture/captcha)
240
+ - [flask-socketio](https://github.com/miguelgrinberg/flask-socketio)
241
+
242
+
243
+ ## Loicense
244
+ Oi mate! Got a loicense for that project Govna? Yes, and it is the best one.
245
+
246
+ YACS is licensed under WTFPL with NO WARRANTY.
247
+
248
+ <a href="http://www.wtfpl.net/"><img
249
+ src="http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-4.png"
250
+ width="80" height="15" alt="WTFPL" /></a>
@@ -0,0 +1,233 @@
1
+ # YACS
2
+ Yet Another Chatroom Script
3
+
4
+ Inspired by [LE-CHAT-PHP](https://github.com/DanWin/le-chat-php)
5
+
6
+ ![Splash Screen](docs/the-yacs.jpeg)
7
+
8
+ ## Featuring
9
+
10
+ - Multiple channels.
11
+ - Admins.
12
+ - Files and embedded images/videos.
13
+ - BBCode.
14
+ - CAPTCHA.
15
+ - Vanilla HTML & CSS & JS.
16
+ - No Cookies, it's bad for your teeth.
17
+
18
+ ## Try It Out Right Now!
19
+
20
+ Join [The YACS Demo Server](https://chat.valine0x.icu) right now with passphrase **`the-yacs`** to see YACS in action!
21
+
22
+ ## Deployment
23
+
24
+ ### 1. Deploy with venv (Recommended)
25
+
26
+ Create a venv with python version 3.13 or greater.
27
+
28
+ ```bash
29
+ $ python -m venv .venv
30
+
31
+ # Activate venv in bash
32
+ $ source .venv/bin/activate
33
+
34
+ # Activate venv in pwsh
35
+ > . .venv/Scripts/Activate.ps1"
36
+ ```
37
+
38
+
39
+ Then, install the package inside venv.
40
+
41
+ ```bash
42
+ $(venv) pip install yacscript
43
+ ```
44
+
45
+ Create a configuration file and edit it to your liking.
46
+
47
+ For reference, see the <a href="#configuration">configuration section</a>.
48
+
49
+ ```bash
50
+ $(venv) vi ./config.toml
51
+ ```
52
+
53
+ Finally, you run the server within the venv
54
+
55
+ In addition to that, you might want to deploy the program as a daemon. Here's an example of a possible simple unit file for systemd.
56
+
57
+ Assuming you have installed the venv as `/path/to/.venv`, for example `/opt/yacs/.venv`, making `/path/to/` means `/opt/yacs/` for the setup.
58
+
59
+ ```ini
60
+ [Unit]
61
+ Description=YACS Service
62
+ After=network.target
63
+
64
+ [Service]
65
+ Type=simple
66
+ WorkingDirectory=/path/to
67
+ Environment="PATH=/path/to/.venv/bin"
68
+ ExecStart=/path/to/.venv/bin/yacs-run --config /path/to/config.toml
69
+
70
+ [Install]
71
+ WantedBy=multi-user.target
72
+ ```
73
+
74
+ ### 2. Deploy from source (with uv)
75
+
76
+ Deploying from source gives you access to the latest features but may be unstable
77
+
78
+ To deploy from source, first you need to install uv.
79
+
80
+ ```bash
81
+ # Install with pip.
82
+ $ pip install uv
83
+
84
+ # Install on macOS and Linux.
85
+ $ curl -LsSf https://astral.sh/uv/install.sh | sh
86
+
87
+ # Install on Windows.
88
+ $ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
89
+ ```
90
+
91
+ Then, clone the repo.
92
+
93
+ ```bash
94
+ $ git clone https://github.com/valine-dev/yacs.git
95
+ $ cd yacs
96
+ ```
97
+
98
+ Create a config file, and edit it to your liking.
99
+
100
+ For reference, see the <a href="#configuration">configuration section</a>.
101
+
102
+ ```bash
103
+ $ vi ./config.toml
104
+ ```
105
+
106
+ Finally, run the server, dependencies and venv will be installed along the way.
107
+
108
+ ```bash
109
+ $ uv run yacs-run --config config.toml
110
+ ```
111
+
112
+ Additionally, it's also possible to make a daemon service out of deployment from source.
113
+
114
+ An example unit file is shown as below.
115
+
116
+ ```ini
117
+ [Unit]
118
+ Description=YACS Service
119
+ After=network.target
120
+
121
+ [Service]
122
+ Type=simple
123
+ WorkingDirectory=/path/to/yacs
124
+ Environment="PATH=/path/to/yacs/.venv/bin"
125
+ ExecStart=/path/to/uv run yacs-run --config /path/to/config.toml
126
+
127
+ [Install]
128
+ WantedBy=multi-user.target
129
+ ```
130
+
131
+ ## User Manual
132
+
133
+ Consult <a href="docs/manual.md">User Manual</a> for guidance.
134
+
135
+ ## Configuration
136
+
137
+ The program comes with a built in config, so you might want to only write fields that you need to deviates from default.
138
+
139
+ All possible fields are shown below.
140
+
141
+ ```toml
142
+ [flask]
143
+ # here you can configure built-in config values defined by flask
144
+ DEBUG = false # DO NOT SET TO `true` WHEN EXPOSING TO PUBLIC!
145
+
146
+ [app]
147
+ # The app itself will only exposed through plain HTTP and it's strongly discorage to do so directly to public web. Use a reverse proxy with TLS in front of the app.
148
+ ip = "0.0.0.0"
149
+ port = 8080
150
+
151
+ admin_phrase = "CHANGE_ME_ADMIN"
152
+ # set user_phrase to empty will expose chatroom to the public
153
+ user_phrase = "CHANGE_ME"
154
+
155
+ log_level = "INFO"
156
+ timeout = 5000 # in milisecond, use for heartbeat
157
+
158
+ # Set to true only when the app is behind a reverse proxy!
159
+ # Make sure X-Forwarded-For and X-Forwarded-Host are properly set!
160
+ proxy_fix = false
161
+
162
+
163
+ [custom]
164
+ title = "The YACS"
165
+ motd = "Hello!\nRule No.1"
166
+
167
+ # These are the emotes that will rendered to the webpage
168
+ emoticons = [
169
+ "( ゚∀。)",
170
+ "Insert Anything",
171
+ "⭐"
172
+ ]
173
+
174
+
175
+ [res]
176
+ path = "./resource" # Relative to project's root
177
+ size_max = 1024 # In Megabytes
178
+
179
+
180
+ [captcha]
181
+ length = 4
182
+ max_cache = 60
183
+ expire = 120 # Expire time in seconds
184
+
185
+ [captcha.options]
186
+ # you don't want to have all of them turn on, it'll be confusing
187
+ numbers = false
188
+ lowercase = true
189
+ uppercase = false
190
+
191
+ [db]
192
+ path = "./yacs.db"
193
+ ```
194
+
195
+ And, an example config could look like this.
196
+
197
+ ```toml
198
+ [flask]
199
+ DEBUG = false
200
+
201
+ [app]
202
+ admin_phrase = "this-is-admin"
203
+ user_phrase = "hello"
204
+
205
+ [custom]
206
+ title = "My YACS Server"
207
+ motd = "Hello!\nRule No.1!"
208
+ ```
209
+
210
+
211
+ ## Customization
212
+
213
+ Yes, you can rewrite templates in `./app/templates/` and static assets in `./app/static/` to customize ya site. It's written in jinja2 template syntax.
214
+
215
+ ## Acknowledgement
216
+ YACS will not be possible without following existing projects.
217
+
218
+ - [98.css](https://github.com/jdan/98.css)
219
+ - [flask](https://github.com/pallets/flask/)
220
+ - [bbcode](https://github.com/dcwatson/bbcode)
221
+ - [webargs](https://github.com/marshmallow-code/webargs)
222
+ - [captcha](https://github.com/lepture/captcha)
223
+ - [flask-socketio](https://github.com/miguelgrinberg/flask-socketio)
224
+
225
+
226
+ ## Loicense
227
+ Oi mate! Got a loicense for that project Govna? Yes, and it is the best one.
228
+
229
+ YACS is licensed under WTFPL with NO WARRANTY.
230
+
231
+ <a href="http://www.wtfpl.net/"><img
232
+ src="http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-4.png"
233
+ width="80" height="15" alt="WTFPL" /></a>
@@ -0,0 +1,24 @@
1
+ from .app import app, socketio, initialization
2
+ from os.path import isfile
3
+ import click
4
+
5
+ @click.command
6
+ @click.option('-c', '--config', default=None, help='Path to the config file.')
7
+ def main(config):
8
+ '''Entry point for YACS.'''
9
+ if config is not None:
10
+ if not isfile(config):
11
+ click.echo('Config file does not exist!', err=True)
12
+ return 0
13
+ result = initialization(config)
14
+ if result != 'ok':
15
+ click.echo(f'Initialization failed while parsing config file: {result}')
16
+ return 0
17
+ app.logger.info(f'YACS is now running on http://{app.config["app"]["ip"]}:{app.config["app"]["port"]}{' with DEBUG MODE ON' if app.config['DEBUG'] else ''}.')
18
+ app.logger.info(f'You have set the guest passphrase to "{app.config['app']['user_phrase']}" , and the admin passphrase to "{app.config['app']['admin_phrase']}"')
19
+ socketio.run(
20
+ app,
21
+ host=app.config["app"]["ip"],
22
+ port=app.config["app"]["port"],
23
+ debug=app.config["DEBUG"],
24
+ )