-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecipes_and_equip.py
33 lines (31 loc) · 1017 Bytes
/
recipes_and_equip.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
import psycopg2
import config
import time
import datetime
import pytz
from help_func import sep_by_3 as sep3
def send_resources(txt: str):
resources = [[], []]
if "Ресурсы:\n" in txt:
left = txt.find("Ресурсы:\n") + len("Ресурсы:\n")
lenght = len(txt)
txt = txt[left:lenght]
left = 0
lenght = len(txt)
right = 0
while right != lenght:
right = txt.find("\n", left)
if right == -1:
right = lenght
res = txt[left:right]
name = res[: res.find("(")]
if "🗝" not in name:
count = res[res.find("(") + 1 : res.find(")")]
else:
extra_left = res.find("(", res.find("(") + 1)
count = res[extra_left + 1 : res.find(")", extra_left)]
resources[0].append(name)
resources[1].append(int(count))
if right + 1 < lenght:
left = right + 1
return resources