-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Description
Summary
Telegram messages are rejected by allow_from even when the configured value is the correct user ID (as a string), if the sender has a Telegram username.
Environment
- Project: picoclaw
- Command:
picoclaw gateway(also reproducible with--debug) - Config uses
allow_fromas documented
Config
{
"channels": {
"telegram": {
"enabled": true,
"token": "REDACTED",
"allow_from": ["123456789"]
}
}
}Steps to reproduce
- Enable Telegram channel with a valid bot token.
- Set
allow_fromto a numeric Telegram user ID string (e.g."123456789"). - Start gateway.
- Send a message to the bot from that Telegram account.
Actual behavior
- The bot does not process/reply to the message.
- With
--debug, logs show the message is rejected by allowlist.
Expected behavior
- A numeric user ID string in
allow_fromshould allow that user’s messages, as shown in docs/examples.
Suspected cause
Telegram sender ID is constructed as "<id>|<username>" when username exists, but allowlist matching is strict string equality.
So "123456789" does not match "123456789|myusername".
Workarounds
- Set
allow_fromto"<id>|<username>", or - Leave
allow_fromempty (allow all users).
Suggested fix
Match Telegram allowlist primarily against pure user.ID (string), and optionally keep backward compatibility for "<id>|<username>" entries.
Code references
-
Telegram sender ID is built as
id|username:
picoclaw/pkg/channels/telegram.go
Lines 164 to 167 in 13fcbe6
senderID := fmt.Sprintf("%d", user.ID) if user.Username != "" { senderID = fmt.Sprintf("%d|%s", user.ID, user.Username) } -
Allowlist check is strict string equality:
Lines 45 to 52 in 13fcbe6
func (c *BaseChannel) IsAllowed(senderID string) bool { if len(c.allowList) == 0 { return true } for _, allowed := range c.allowList { if senderID == allowed { return true
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels