-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
89 lines (66 loc) · 2.06 KB
/
bot.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Import for integration with BotCity Maestro SDK
from botcity.maestro import *
# Disable errors if we are not connected to Maestro
BotMaestroSDK.RAISE_NOT_CONNECTED = False
def main():
maestro = BotMaestroSDK.from_sys_args()
# informações em Amb. de desenvolvedor
maestro.login(
server="...",
login="...",
key="..."
)
# ID de uma tarefa em aguardo
execution = maestro.get_execution("...")
execution.task_id = "..."
print(f"Tarefa: {execution.task_id}")
enviar_item_unico(maestro)
enviar_itens(maestro)
puxa_um_item(maestro, execution)
puxa_todos_itens(maestro, execution)
def enviar_item_unico(maestro):
datapool = maestro.get_datapool(label="...") # datapool label
novo_item = DataPoolEntry(
values={
"nome": "item unico",
"status": "status unico"
}
)
datapool.create_entry(novo_item)
def enviar_itens(maestro):
datapool = maestro.get_datapool(label="...") # datapool label
for item in range(5):
novo_item = DataPoolEntry(
values={
"nome": f"item {item}",
"status": f"status {item}"
}
)
datapool.create_entry(novo_item)
def puxa_um_item(maestro, execution):
datapool = maestro.get_datapool(label="...") # datapool label
item = datapool.next(task_id=execution.task_id)
if item is None:
print("não há itens")
return
# Processando item...
print(f"""Item resgatado:
{item['nome']}
{item['status']}
""")
item.report_done()
def puxa_todos_itens(maestro, execution):
datapool = maestro.get_datapool(label="...") # datapool label
while datapool.has_next():
item = datapool.next(task_id=execution.task_id)
if item is None:
print("não há itens")
break
# Processando item...
print(f"""Item resgatado:
{item['nome']}
{item['status']}
""")
item.report_done()
if __name__ == '__main__':
main()