mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-22 23:54:20 +01:00
noise: adds docstrings to plugin methods
This commit is contained in:
@@ -119,6 +119,10 @@ def deliver(node_id, payload, amt, payment_hash, max_attempts=5):
|
|||||||
|
|
||||||
@plugin.async_method('sendmsg')
|
@plugin.async_method('sendmsg')
|
||||||
def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
|
def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
|
||||||
|
"""Sends a chat message.
|
||||||
|
|
||||||
|
First paramter is the message payload as a string.
|
||||||
|
"""
|
||||||
timestamp = struct.pack("!Q", int(time.time() * 1000))
|
timestamp = struct.pack("!Q", int(time.time() * 1000))
|
||||||
payload = TlvPayload()
|
payload = TlvPayload()
|
||||||
payload.add_field(TLV_NOISE_MESSAGE, msg.encode('UTF-8'))
|
payload.add_field(TLV_NOISE_MESSAGE, msg.encode('UTF-8'))
|
||||||
@@ -151,6 +155,11 @@ def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
|
|||||||
|
|
||||||
@plugin.async_method('recvmsg')
|
@plugin.async_method('recvmsg')
|
||||||
def recvmsg(plugin, request, last_id=None, **kwargs):
|
def recvmsg(plugin, request, last_id=None, **kwargs):
|
||||||
|
"""Receives a chat message.
|
||||||
|
|
||||||
|
Returns a `concurrent.futures.Future`.
|
||||||
|
Optional parameter `last_id` can be supplied to return an older message.
|
||||||
|
"""
|
||||||
next_id = int(last_id) + 1 if last_id is not None else len(plugin.messages)
|
next_id = int(last_id) + 1 if last_id is not None else len(plugin.messages)
|
||||||
if next_id <= len(plugin.messages):
|
if next_id <= len(plugin.messages):
|
||||||
res = plugin.messages[int(last_id)].to_dict()
|
res = plugin.messages[int(last_id)].to_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user