-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·85 lines (62 loc) · 1.61 KB
/
cli.py
File metadata and controls
executable file
·85 lines (62 loc) · 1.61 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
80
81
82
83
84
85
#!/usr/bin/env python3
from datetime import datetime
from meshbot.meshwrapper import Node, Nodelist, Message
from meshbot.chatbot import Chatbot
# Create a bot
bot = Chatbot()
# Import desired modules and register them with the bot
for module in [
"about",
"radio_commands",
"weather",
"message_box",
"ollama_llm",
]:
exec(f"from meshbot.{module} import register as register_{module}")
exec(f"register_{module}(bot)")
def output(response: str) -> bool:
print(response)
return True
print(bot)
# Create fake domain model
fromNode = Node()
fromNode.num = 1
fromNode.id = "!00000001"
fromNode.shortName = "USER"
fromNode.longName = "User"
fromNode.snr = 5.0
fromNode.rssi = -80
fromNode.hopsAway = 0
fromNode.send = output
fromNode.lastHeard = datetime.timestamp(datetime.now())
fromNode.position = [49.911, 9.210]
toNode = Node()
toNode.num = 2
toNode.id = "!00000002"
toNode.is_self = lambda: True
toNode.shortName = "MBOT"
toNode.longName = "Meshbot"
toNode.snr = 6.0
toNode.rssi = -75
toNode.hopsAway = 0
toNode.lastHeard = datetime.timestamp(datetime.now())
toNode.position = [42.428, -4.512]
nodelist = Nodelist()
nodelist.add(fromNode)
nodelist.add(toNode)
# Take input from the user and run it through the bot
while True:
try:
message = Message()
message.text = input(">>> ")
message.type = "TEXT_MESSAGE_APP"
message.reply = output
message.fromNode = fromNode
message.toNode = toNode
message.nodelist = nodelist
bot.handle(message)
except KeyboardInterrupt:
break
except EOFError:
break
print()