-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathbasic.py
45 lines (35 loc) · 1.63 KB
/
basic.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
# This is a bare-minimum command plugin
# example that you can build upon to
# implement your own command plugins.
import RNS
class BasicCommandPlugin(SidebandCommandPlugin):
command_name = "basic_example"
def start(self):
# Do any initialisation work here
RNS.log("Basic command plugin example starting...")
# And finally call start on superclass
super().start()
def stop(self):
# Do any teardown work here
pass
# And finally call stop on superclass
super().stop()
def handle_command(self, arguments, lxm):
response_content = "Hello "+RNS.prettyhexrep(lxm.source_hash)+". "
response_content += "This is a response from the basic command example. It doesn't do much, but here is a list of the arguments you included:\n"
for argument in arguments:
response_content += "\n"+str(argument)
# Let the Sideband core send a reply.
self.get_sideband().send_message(
response_content,
lxm.source_hash,
False, # Don't use propagation by default, try direct first
skip_fields = True, # Don't include any additional fields automatically
no_display = True, # Don't display this message in the message stream
attachment = None, # Don't add any attachment field to this message
image = None, # Don't add any image field to this message
audio = None, # Don't add any audio field to this message
)
# Finally, tell Sideband what class in this
# file is the actual plugin class.
plugin_class = BasicCommandPlugin