Added allmsgs command to noise to print all msgs

This commit is contained in:
Clay Shoaf
2022-04-22 10:46:01 -04:00
committed by mergify[bot]
parent 4f2e9b7684
commit 8f740bf4d4
2 changed files with 23 additions and 4 deletions

View File

@@ -21,12 +21,18 @@ lightning-cli sendmsg 02a5deaa47804c518bb4a1c6f04a85b92b796516bd32c4114a51b00d73
You can read the last message received using the following command:
#+BEGIN_SRC bash
lightning-cli recvmsg last_id
lightning-cli recvmsg msg_id
#+END_SRC
The ~last_id~ indicates the last message we read, so we can retrieve each message
individually. If you'd just like to wait for the next message then do not
specify any ~last_id~.
The ~msg_id~ indicates the id number of each message received in chronological
order, so we can retrieve each message individually. If you'd just like to wait
for the next message then do not specify any ~msg_id~.
You can output all messages received using the following command:
#+BEGIN_SRC bash
lightning-cli allmsgs
#+END_SRC
* Todo

View File

@@ -166,6 +166,19 @@ def sendmsg(node_id, msg, plugin, request, pay=None, **kwargs):
request.set_result(res)
@plugin.async_method('allmsgs')
def allmsgs(plugin, request, **kwargs):
"""
Prints all messages that have been received
"""
msg_list = {}
for i in range(len(plugin.messages)):
res = plugin.messages[int(i)].to_dict()
res['total_messages'] = len(plugin.messages)
msg_list["message"+str(i)] = res
request.set_result(msg_list)
@plugin.async_method('recvmsg')
def recvmsg(plugin, request, msg_id=None, **kwargs):
"""Receives a chat message.