Skip to content

Commit 4b0ff28

Browse files
committed
CHANGES:
- Cron: added "broadcast"
1 parent 0e9f0b9 commit 4b0ff28

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

services/cron/README.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ DEFAULT:
102102
```
103103
104104
e) popup
105-
Send a popup
105+
Send a popup to a running server.
106106
```yaml
107-
DEFAULT:
107+
DCS.server_release:
108108
actions:
109109
- cron: '55 3 * * 1' # Send a message to everyone at Mo, 03:55h
110110
action:
@@ -114,7 +114,20 @@ DEFAULT:
114114
timeout: 20
115115
```
116116
117-
f) purge_channel
117+
f) broadcast
118+
Send a popup to all running servers.
119+
```yaml
120+
DEFAULT:
121+
actions:
122+
- cron: '55 3 * * 1' # Send a message to everyone at Mo, 03:55h
123+
action:
124+
type: broadcast
125+
params:
126+
message: Server will shut down in 5 mins!
127+
timeout: 20
128+
```
129+
130+
g) purge_channel
118131
Delete messages from a Discord channel.
119132
```yaml
120133
DEFAULT:
@@ -130,7 +143,7 @@ DEFAULT:
130143
ignore: 119922883377446655 # ignore this user id AND message id (either the bot's or persistent messages in the channel); can be either an ID or a list of IDs
131144
```
132145
133-
g) dcs_update
146+
h) dcs_update
134147
Run a DCS update at a specific time.
135148
```yaml
136149
DEFAULT:

services/cron/actions/default.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@ async def cmd(node: Node, cmd: str):
8080

8181

8282
async def popup(node: Node, server: Server, message: str, to: Optional[str] = 'all', timeout: Optional[int] = 10):
83-
await server.sendPopupMessage(Coalition(to), message, timeout)
83+
if server.status == Status.RUNNING:
84+
await server.sendPopupMessage(Coalition(to), message, timeout)
85+
86+
87+
async def broadcast(node: Node, message: str, to: Optional[str] = 'all', timeout: Optional[int] = 10):
88+
bus = ServiceRegistry.get(ServiceBus)
89+
for server in [x for x in bus.servers.values() if x.status == Status.RUNNING]:
90+
await server.sendPopupMessage(Coalition(to), message, timeout)
8491

8592

8693
async def purge_channel(node: Node, channel: Union[int, list[int]], older_than: int = None,

0 commit comments

Comments
 (0)