generate invite link for the bot
This commit is contained in:
parent
47c4052ce0
commit
6a45a8dbce
18
README.md
18
README.md
|
|
@ -6,5 +6,21 @@
|
||||||
python3 -m venv venv
|
python3 -m venv venv
|
||||||
. venv/bin/activate
|
. venv/bin/activate
|
||||||
pip install -e .
|
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.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,22 +20,22 @@ HELP_MSG = (
|
||||||
def command(event):
|
def command(event):
|
||||||
snapshot = event.message_snapshot
|
snapshot = event.message_snapshot
|
||||||
|
|
||||||
|
if snapshot.text == "/generate-invite":
|
||||||
|
return snapshot.chat.send_text(snapshot.account.get_qr_code())
|
||||||
email = snapshot.text
|
email = snapshot.text
|
||||||
try:
|
try:
|
||||||
validate_email(email, check_deliverability=False)
|
validate_email(email, check_deliverability=False)
|
||||||
except EmailNotValidError:
|
except EmailNotValidError:
|
||||||
snapshot.chat.send_text(HELP_MSG)
|
return snapshot.chat.send_text(HELP_MSG)
|
||||||
return
|
|
||||||
|
|
||||||
public_key = request_key_by_email(email)
|
public_key = request_key_by_email(email)
|
||||||
if not public_key:
|
if not public_key:
|
||||||
snapshot.chat.send_text("Sorry, I could not find a key for this user.")
|
return snapshot.chat.send_text("Sorry, I could not find a key for this user.")
|
||||||
return
|
|
||||||
|
|
||||||
vcard = construct_vcard(email, public_key)
|
vcard = construct_vcard(email, public_key)
|
||||||
vcard_path = f"/tmp/{email}.vcf"
|
vcard_path = f"/tmp/{email}.vcf"
|
||||||
save_vcard(vcard_path, vcard)
|
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:
|
def request_key_by_email(email) -> str:
|
||||||
|
|
@ -64,7 +64,6 @@ def delete_data(msg):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# TODO: print invite link
|
|
||||||
run_bot_cli(hooks)
|
run_bot_cli(hooks)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue