-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbob.py
More file actions
32 lines (20 loc) · 718 Bytes
/
bob.py
File metadata and controls
32 lines (20 loc) · 718 Bytes
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
from uagents import Agent, Context, Model
class Message(Model):
message: str
ALICE_ADDRESS = "put_alice_address_here"
BOB_SEED = "put_your_seed_phrase_here"
print(f"Your agent's address is: {Agent(seed=BOB_SEED).address}")
bob = Agent(
name="bob",
seed=BOB_SEED,
mailbox=True
)
@bob.on_interval(period=2.0)
async def send_message(ctx: Context):
ctx.logger.info("Sending message to alice")
await ctx.send(ALICE_ADDRESS, Message(message="Hello there alice"))
@bob.on_message(model=Message, replies=set())
async def message_handler(ctx: Context, sender: str, msg: Message):
ctx.logger.info(f"Received message from {sender}: {msg.message}")
if __name__ == "__main__":
bob.run()