diff --git a/README.md b/README.md index f711c79..3b58f6b 100644 --- a/README.md +++ b/README.md @@ -6,5 +6,21 @@ python3 -m venv venv . venv/bin/activate pip install -e . -keyserver-bot --help +keyserver-bot --email keyserver@example.org --password s3cr3t ``` + +## Usage + +If you send an email address to the bot, +it will try to query WKD, +and if that fails keys.openpgp.org, +for a public OpenPGP key belonging to the email address. + +Then it will send you a VCard file +which contains the public key, +so you can initiate an encrypted chat to it. + +With the "/generate-invite" command, +you can also generate an invite link for the bot +so you can publish it. + diff --git a/src/keyserver_bot/hooks.py b/src/keyserver_bot/hooks.py index 37accfe..0e31b40 100644 --- a/src/keyserver_bot/hooks.py +++ b/src/keyserver_bot/hooks.py @@ -20,22 +20,22 @@ HELP_MSG = ( def command(event): snapshot = event.message_snapshot + if snapshot.text == "/generate-invite": + return snapshot.chat.send_text(snapshot.account.get_qr_code()) email = snapshot.text try: validate_email(email, check_deliverability=False) except EmailNotValidError: - snapshot.chat.send_text(HELP_MSG) - return + return snapshot.chat.send_text(HELP_MSG) public_key = request_key_by_email(email) if not public_key: - snapshot.chat.send_text("Sorry, I could not find a key for this user.") - return + return snapshot.chat.send_text("Sorry, I could not find a key for this user.") vcard = construct_vcard(email, public_key) vcard_path = f"/tmp/{email}.vcf" save_vcard(vcard_path, vcard) - snapshot.chat.send_file(vcard_path) + return snapshot.chat.send_file(vcard_path) def request_key_by_email(email) -> str: @@ -64,7 +64,6 @@ def delete_data(msg): def main(): - # TODO: print invite link run_bot_cli(hooks)