Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Telethon IDs uniqueness

There are 3 types in telethon:

  1. User: can a real user or a bot
  2. Chat: telegram group
  3. Channel: a telegram channel or a super group

All of three types have an ID attribute. Can i store them inside one column in database and make that column unique? Or there can be duplicate ids between these three types?

like image 667
Offofue Avatar asked Sep 15 '25 19:09

Offofue


2 Answers

Yea you can do that. ID is a unique identifier in Telegram.

A simple way to check that is to take a look at sendMessage in Bot APIs. You can see that target chat is just recognized by its ID and it doesn't need any extra information about the type of that target chat.

like image 123
tashakori Avatar answered Sep 18 '25 08:09

tashakori


users and normal chats(normal groups not supper group) have positive id. and channels (include supper groups and broadcast channels) have negative id (for example: -1001050484879). in some methods, telethon return channel id as positive number (for example 1050484879, remove -100 from first of id) you must add -100 at first of ids of channel then save them.

like image 23
ahmadsl Avatar answered Sep 18 '25 10:09

ahmadsl