mirror of
https://github.com/markqvist/Sideband.git
synced 2024-10-01 03:15:37 -04:00
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
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 # Dot't display this message in the message stream
|
|
)
|
|
|
|
# Finally, tell Sideband what class in this
|
|
# file is the actual plugin class.
|
|
plugin_class = BasicCommandPlugin |