Troubleshooting¶
Start with pgpcbot whoami: it shows whether the token works, the bot’s mode, whether it is
paused, the webhook and the queue. Then look for your symptom below.
The bot does not start¶
Message |
Cause |
Fix |
|---|---|---|
|
the token is not set |
set |
|
a pasted token with a missing or extra character |
copy it again; it is shown once in the console, so you may need a new one |
|
the token was revoked or replaced |
make a new token in the console |
|
polling and a webhook can’t run together |
|
|
a second copy is running with the same database |
stop the other one |
|
a handler, error handler or middleware of the wrong kind; the message names it |
|
|
wrong or missing key passphrase |
check |
|
no CA certificates in the system or container |
install |
|
|
use |
The bot runs but gets nothing¶
In a group: with privacy mode on (the default) the bot only gets commands, replies to its messages and mentions.
pgpcbot whoamishowsprivacy mode on. The owner can turn it off.In an encrypted group: the bot needs a published key, or the phones can’t seal messages to it.
Two copies are polling: the log says “another process is probably polling this bot”. Stop the other copy (check other machines and containers too).
The bot is paused:
whoamisaysstatus: paused. The owner resumes it in the app.A webhook is set and failing:
pgpcbot webhook infoshows the last error.A handler does not match: an earlier handler took the update. The first match wins, so put specific handlers before general ones. Turn on
DEBUGlogs forpgpcbot.bot: it logs “no handler took it” for updates that matched nothing.
Sending fails¶
Error |
Cause |
Fix |
|---|---|---|
|
the chat is encrypted, the bot has no key loaded |
pass |
|
nobody in the chat published a key |
the chat cannot get encrypted messages |
|
|
intended: the bot refuses to talk in clear |
|
|
check the new key with the person, then |
|
the chat became readable while the bot sent an encrypted message |
send again: the next message follows the new mode |
|
the person blocked the bot |
stop writing to them |
|
no right to write (a restricted bot, a channel where the bot is not an admin) |
ask an admin |
|
the bot is not in that chat, or the ID is wrong |
check the ID; a person must start a private chat first |
|
too fast |
see Rate limits |
|
the request breaks a server rule; nothing was sent |
|
Encrypted messages¶
Symptom |
Cause |
Fix |
|---|---|---|
|
the bot runs with a key that is not the published one |
|
|
messages sealed to the old key |
add the old key to |
|
phones seal attachments only to the members’ key list |
turn the bot’s privacy mode off, or skip attachments |
|
checks are off, or the chat’s keys could not be fetched |
|
|
signed by a key that is not the one the server lists for the sender |
check with the person |
|
|
check the new key with the person, |
|
someone sent a compressed file; phones never do |
nothing to fix on the bot’s side: the file is refused on purpose |
a warning “key … advertises SEIPDv2” |
the bot key was not made by |
make a new key with |
Polling and webhooks¶
Updates arrive twice. Delivery is “at least once”. The library drops repeats it can see, but after a crash at the wrong moment a handler can run again. Make important actions idempotent.
The webhook gets
401s in its log. Something without the secret calls your URL, or the secret in your app differs from the one the server has. Withurl=the app registers its secret at every start; otherwise runpgpcbot webhook set URL --secret-env VARagain.The webhook queue does not move.
pgpcbot webhook infoshows the last error and the next try. The server sends one update at a time and waits for a2xx: fix the error and the queue moves on its own.A handler is slow and everything waits. Updates of one chat run in order; other chats are not blocked. With a webhook and
MemoryStorage, the whole bot runs one update at a time: useSQLiteStorage.
Windows¶
Ctrl+C stops the bot cleanly. Ctrl+Break works too.
If you run a bot inside Jupyter,
bot.run()can’t start its own loop: useawait bot.start_polling()in a cell.
Still stuck?¶
Turn on debug logs for the library only:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("pgpcbot").setLevel(logging.DEBUG)
The logs never contain the token, the key or message text, so you can share them when you ask for help. Check them anyway before posting them in public.