Commit 1241cb0
committed
fix: resolve unmarked channel/chat IDs passed as positive integers
Telethon's get_entity(int) maps positive integers to PeerUser. When
callers pass a bare channel ID like 1676885811 (without the -100 prefix),
Telethon looks for a user with that ID and fails with ValueError.
The existing fallback (get_dialogs cache warming) doesn't help because
Telethon still interprets the positive int as PeerUser on retry.
Add _marked_id_candidates() that generates -100X (PeerChannel) and -X
(PeerChat) variants from a positive int. Both resolve_entity() and
resolve_input_entity() now try these variants as a last resort before
raising, so unmarked IDs from any source (LLMs, cached values, manual
input) resolve correctly.1 parent a050889 commit 1241cb0
1 file changed
Lines changed: 58 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
344 | 364 | | |
345 | | - | |
| 365 | + | |
346 | 366 | | |
347 | 367 | | |
348 | 368 | | |
349 | 369 | | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
350 | 373 | | |
351 | 374 | | |
352 | 375 | | |
353 | 376 | | |
354 | 377 | | |
355 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
356 | 393 | | |
357 | 394 | | |
358 | 395 | | |
359 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
360 | 400 | | |
361 | 401 | | |
362 | 402 | | |
363 | 403 | | |
364 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
365 | 419 | | |
366 | 420 | | |
367 | 421 | | |
| |||
0 commit comments