forked from the-emerald/sac-rmv-calculator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsacrmv.py
56 lines (42 loc) · 1.67 KB
/
sacrmv.py
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
import discord
import shlex
from modules.botModule import BotModule
class SACRMV(BotModule):
name = 'sacrmv'
description = 'Calculation of SAC and RMV given dive times.'
help_text = 'Calculates SAC (Surface Air Consumption) and RMV (Respiratory Mean Volume) given dive times. \n' \
'`!air [start_pressure BAR] [end_pressure BAR] [bottom_time MINUTE] [average_depth METRE] ' \
'[tank_service_pressure BAR] [tank_capacity LITRE]`'
trigger_string = 'air'
module_version = '1.0.0'
@staticmethod
def is_number(li):
for i in li:
try:
int(i)
except ValueError:
return False
return True
async def parse_command(self, message, client):
msg = shlex.split(message.content)
if len(msg) != 7:
send_message = "[!] Missing arguments."
await client.send_message(message.channel, send_message)
return 0
if not self.is_number(msg[1:]):
send_message = "[!] Invalid arguments."
await client.send_message(message.channel, send_message)
return 0
start_bar = int(msg[1])
end_bar = int(msg[2])
bar = start_bar-end_bar
bottom_time = int(msg[3])
msw = int(msg[4])
pressure = (msw*0.099376) + 1
sac = bar/bottom_time/pressure
service_pressure = int(msg[5])
tank_capacity = int(msg[6])
rmv = (tank_capacity/service_pressure)*sac
send_message = "SAC: " + str(sac) + " bar/min" + "\n" \
"RMV: " + str(rmv) + " litres/min"
await client.send_message(message.channel, send_message)