#!/usr/bin/env python3
"""
Post a message from Alexander's npub in the Timmy Time NIP-29 group.
"""
import json
import asyncio
from nostr_sdk import (
    Keys, Client, NostrSigner, Filter, Kind, 
    EventBuilder, Tag, RelayUrl
)

RELAY_URL = "wss://alexanderwhitestone.com/relay"
GROUP_ID = "timmy-time"
ALEXANDER_NSEC = """<insert Alexander's nsec here>"""

async def main():
    keys = Keys.parse(ALEXANDER_NSEC)
    signer = NostrSigner.keys(keys)
    client = Client(signer)
    await client.add_relay(RelayUrl.parse(RELAY_URL))
    await client.connect()
    
    tags = [Tag.parse(["h", GROUP_ID])]
    builder = EventBuilder(Kind(9), "Alexander Whitestone has joined Timmy Time. Sovereignty and service always.").tags(tags)
    result = await client.send_event_builder(builder)
    print(f"Alexander's message posted with event ID: {result.id.to_hex()}")
    await client.disconnect()

if __name__ == "__main__":
    asyncio.run(main())
