mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
Fix example
This commit is contained in:
@@ -13,6 +13,9 @@ async def main () :
|
|||||||
|
|
||||||
await mc.ensure_contacts()
|
await mc.ensure_contacts()
|
||||||
contact = mc.get_contact_by_name(DEST)
|
contact = mc.get_contact_by_name(DEST)
|
||||||
|
if not contact:
|
||||||
|
print(f"Contact {DEST} not found")
|
||||||
|
return
|
||||||
await mc.commands.send_msg(bytes.fromhex(contact["public_key"])[0:6], MSG)
|
await mc.commands.send_msg(bytes.fromhex(contact["public_key"])[0:6], MSG)
|
||||||
print ("Message sent ... awaiting")
|
print ("Message sent ... awaiting")
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import asyncio
|
|||||||
import functools
|
import functools
|
||||||
import warnings
|
import warnings
|
||||||
import logging
|
import logging
|
||||||
from typing import Optional
|
from typing import Optional, Dict, Any
|
||||||
|
|
||||||
from .events import EventDispatcher, EventType
|
from .events import EventDispatcher, EventType
|
||||||
from .reader import MessageReader
|
from .reader import MessageReader
|
||||||
@@ -195,7 +195,7 @@ class MeshCore:
|
|||||||
"""Set the default timeout for commands"""
|
"""Set the default timeout for commands"""
|
||||||
self.commands.default_timeout = value
|
self.commands.default_timeout = value
|
||||||
|
|
||||||
def get_contact_by_name(self, name):
|
def get_contact_by_name(self, name) -> Optional[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Find a contact by its name (adv_name field)
|
Find a contact by its name (adv_name field)
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ class MeshCore:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_contact_by_key_prefix(self, prefix):
|
def get_contact_by_key_prefix(self, prefix) -> Optional[Dict[str, Any]]:
|
||||||
"""
|
"""
|
||||||
Find a contact by its public key prefix
|
Find a contact by its public key prefix
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user