yacscript 0.3.0__tar.gz → 0.3.1__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.
- {yacscript-0.3.0 → yacscript-0.3.1}/PKG-INFO +3 -3
- {yacscript-0.3.0 → yacscript-0.3.1}/README.md +2 -2
- {yacscript-0.3.0 → yacscript-0.3.1}/app/__init__.py +13 -2
- {yacscript-0.3.0 → yacscript-0.3.1}/app/app.py +18 -6
- {yacscript-0.3.0 → yacscript-0.3.1}/app/definitions.py +2 -2
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/room.js +5 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/pyproject.toml +1 -1
- {yacscript-0.3.0 → yacscript-0.3.1}/COPYING +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/db.py +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/admin.js +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/file.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/icon.png +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/join.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/leave.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/msg.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/send.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/style.css +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/tile.gif +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/tile.jpg +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/static/welcome.mp3 +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/templates/index.jinja +0 -0
- {yacscript-0.3.0 → yacscript-0.3.1}/app/templates/room.jinja +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: yacscript
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.1
|
|
4
4
|
Summary: yet another chatroom script.
|
|
5
5
|
Author: Valine0x
|
|
6
6
|
Author-email: Valine0x <me@valine0x.icu>
|
|
@@ -56,7 +56,7 @@ $ source .venv/bin/activate
|
|
|
56
56
|
Then, install the package inside venv.
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
|
-
$(venv) pip install yacscript
|
|
59
|
+
$(.venv) pip install yacscript
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Create a configuration file and edit it to your liking.
|
|
@@ -64,7 +64,7 @@ Create a configuration file and edit it to your liking.
|
|
|
64
64
|
For reference, see the <a href="#configuration">configuration section</a>.
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
$(venv) vi ./config.toml
|
|
67
|
+
$(.venv) vi ./config.toml
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
Finally, you run the server within the venv
|
|
@@ -39,7 +39,7 @@ $ source .venv/bin/activate
|
|
|
39
39
|
Then, install the package inside venv.
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
$(venv) pip install yacscript
|
|
42
|
+
$(.venv) pip install yacscript
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Create a configuration file and edit it to your liking.
|
|
@@ -47,7 +47,7 @@ Create a configuration file and edit it to your liking.
|
|
|
47
47
|
For reference, see the <a href="#configuration">configuration section</a>.
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
$(venv) vi ./config.toml
|
|
50
|
+
$(.venv) vi ./config.toml
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
Finally, you run the server within the venv
|
|
@@ -2,7 +2,7 @@ from .app import app, socketio, initialization
|
|
|
2
2
|
from os.path import isfile
|
|
3
3
|
import click
|
|
4
4
|
|
|
5
|
-
@click.command
|
|
5
|
+
@click.command()
|
|
6
6
|
@click.option('-c', '--config', default=None, help='Path to the config file.')
|
|
7
7
|
def main(config):
|
|
8
8
|
'''Entry point for YACS.'''
|
|
@@ -15,7 +15,18 @@ def main(config):
|
|
|
15
15
|
click.echo(f'Initialization failed while parsing config file: {result}')
|
|
16
16
|
return 0
|
|
17
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
|
-
|
|
18
|
+
user_phrase = app.config['app']['user_phrase']
|
|
19
|
+
admin_phrase = app.config['app']['admin_phrase']
|
|
20
|
+
|
|
21
|
+
if user_phrase == '' and admin_phrase == 'admin':
|
|
22
|
+
app.logger.warning(f'You have not set the passphrases or set exactly as default values, this is not safe!')
|
|
23
|
+
app.logger.warning(f'There\'s no passphrase for user and "{admin_phrase}" for admin.')
|
|
24
|
+
if user_phrase == admin_phrase:
|
|
25
|
+
app.logger.critical('user_phrase and admin_phrase shouldn\'t be exactly same!')
|
|
26
|
+
return 0
|
|
27
|
+
if admin_phrase == '':
|
|
28
|
+
app.logger.critical('admin_phrase shouldn\'t be empty!')
|
|
29
|
+
return 0
|
|
19
30
|
socketio.run(
|
|
20
31
|
app,
|
|
21
32
|
host=app.config["app"]["ip"],
|
|
@@ -36,11 +36,18 @@ online = dict()
|
|
|
36
36
|
|
|
37
37
|
# --- HELPER FUNCTIONS ---
|
|
38
38
|
|
|
39
|
+
def deep_update(dst: dict, src: dict) -> None:
|
|
40
|
+
for k, v in src.items():
|
|
41
|
+
if isinstance(v, dict) and isinstance(dst.get(k), dict):
|
|
42
|
+
deep_update(dst[k], v)
|
|
43
|
+
else:
|
|
44
|
+
dst[k] = v
|
|
45
|
+
|
|
39
46
|
def initialization(config=None):
|
|
40
47
|
app.config.update(CONFIG_DEFAULT)
|
|
41
48
|
if config is not None:
|
|
42
49
|
if path.isfile(path.abspath(config)):
|
|
43
|
-
with open(path.abspath(
|
|
50
|
+
with open(path.abspath(config), 'rb') as file:
|
|
44
51
|
try:
|
|
45
52
|
conf = tomllib.load(file)
|
|
46
53
|
except tomllib.TOMLDecodeError as e:
|
|
@@ -48,15 +55,15 @@ def initialization(config=None):
|
|
|
48
55
|
# read built-in values
|
|
49
56
|
top = conf.get('flask', None)
|
|
50
57
|
if top:
|
|
51
|
-
app.config.update(conf
|
|
52
|
-
|
|
53
|
-
app.config.update(conf)
|
|
58
|
+
app.config.update(conf.pop('flask'))
|
|
59
|
+
deep_update(app.config, conf)
|
|
54
60
|
if app.config['app']['proxy_fix']:
|
|
55
61
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_host=1)
|
|
56
62
|
if not path.isdir(app.config['res']['path']):
|
|
57
63
|
mkdir(app.config['res']['path'])
|
|
58
64
|
|
|
59
65
|
# Making global variables
|
|
66
|
+
# TODO: consider changing them to vars inside app
|
|
60
67
|
global logger
|
|
61
68
|
global conn
|
|
62
69
|
global SIZE_MAX_BYTE
|
|
@@ -111,6 +118,11 @@ def clean_user(name):
|
|
|
111
118
|
item['sid'],
|
|
112
119
|
item['namespace']
|
|
113
120
|
)
|
|
121
|
+
emit(
|
|
122
|
+
'kicked',
|
|
123
|
+
to=item['sid'],
|
|
124
|
+
namespace=item['namespace']
|
|
125
|
+
)
|
|
114
126
|
disconnect(
|
|
115
127
|
item['sid'],
|
|
116
128
|
item['namespace']
|
|
@@ -688,11 +700,11 @@ def heartbeat_handler(json):
|
|
|
688
700
|
online[json['nick']]['last_heartbeat'] = time_milisecond()
|
|
689
701
|
|
|
690
702
|
|
|
691
|
-
def
|
|
703
|
+
def cleanup():
|
|
692
704
|
try:
|
|
693
705
|
conn.close()
|
|
694
706
|
except:
|
|
695
707
|
pass
|
|
696
708
|
|
|
697
709
|
|
|
698
|
-
atexit.register(
|
|
710
|
+
atexit.register(cleanup)
|
|
@@ -50,6 +50,11 @@ socket.on("joining", async (e) => {
|
|
|
50
50
|
document.getElementById("fellows_list").innerHTML += `<li id="fellow-${e["target"]}">${e["target"]}</li>`
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
+
socket.on("kicked", async () => {
|
|
54
|
+
window.alert("You're kicked out :(")
|
|
55
|
+
window.location.replace("/");
|
|
56
|
+
})
|
|
57
|
+
|
|
53
58
|
async function refresh_channels() {
|
|
54
59
|
var clist = document.getElementById("channel_list");
|
|
55
60
|
clist.innerHTML = "";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|