forked from TheCommsChannel/TC2-BBS-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
79 lines (59 loc) · 2.6 KB
/
server.py
File metadata and controls
79 lines (59 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python3
"""
TC²-BBS Server for Meshtastic by TheCommsChannel (TC²)
Date: 07/14/2024
Version: 0.1.6
Description:
The system allows for mail message handling, bulletin boards, and a channel
directory. It uses a configuration file for setup details and an SQLite3
database for data storage. Mail messages and bulletins are synced with
other BBS servers listed in the config.ini file.
"""
import logging
import time
from config_init import initialize_config, get_interface, init_cli_parser, merge_config
from db_operations import initialize_database
from js8call_integration import JS8CallClient
from message_processing import on_receive
from pubsub import pub
from cli_interface import Interface
# General logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
def display_banner():
banner = """
████████╗ ██████╗██████╗ ██████╗ ██████╗ ███████╗
╚══██╔══╝██╔════╝╚════██╗ ██╔══██╗██╔══██╗██╔════╝
██║ ██║ █████╔╝█████╗██████╔╝██████╔╝███████╗
██║ ██║ ██╔═══╝ ╚════╝██╔══██╗██╔══██╗╚════██║
██║ ╚██████╗███████╗ ██████╔╝██████╔╝███████║
╚═╝ ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝
Meshtastic Version
"""
print(banner)
def main():
display_banner()
args = init_cli_parser()
config_file = None
if args.config is not None:
config_file = args.config
system_config = initialize_config(config_file)
merge_config(system_config, args)
interface = get_interface(system_config)
interface.bbs_nodes = system_config["bbs_nodes"]
interface.allowed_nodes = system_config["allowed_nodes"]
logging.info(f"BBS is running on {system_config['interface_type']} interface...")
initialize_database()
def receive_packet(packet, interface):
on_receive(packet, interface)
pub.subscribe(receive_packet, system_config["mqtt_topic"])
try:
Interface().cmdloop()
except KeyboardInterrupt:
logging.info("Shutting down the server...")
interface.close()
if __name__ == "__main__":
main()