Thanks, Caronte3D. It's good to know this API will be used.
I have pretty much finished the GetUpdates code, but in the meantime have added some more procedures:
Telegram_SetChatPhoto() ; uses an image file on the computer
Telegram_SetChatPhotoPBImage()
Telegram_DeleteChatPhoto()
Those ones are very straightforward. The next ones aren't. Each of these requires a user_id integer variable, so you need to obtain someone's user_id number in order to use these. Telegram's API does not provide a way to obtain an arbitrary user's number; you can only obtain it via a message that the person has posted in your group. This will be possible with the GetUpdates functionality.
Telegram_GetChatMembersCount()
Telegram_GetChatMember()
Telegram_BanChatMember()
Telegram_RemoveChatMemberWithoutBanning()
Telegram_UnbanChatMember()
Telegram_SetChatMemberPermissions()
Telegram_SetChatMemberPermission()
Telegram_SetChatMemberPermissionsMap()
The final three functions all contact the same endpoint on Telegram's API, but work in different ways. Telegram_SetChatMemberPermissions() is for revising
all of a member's permissions, so it requires a structure variable with all permission statuses set. By contrast, Telegram_SetChatMemberPermission() is for revising just
one permission, so it requires only a simple byte variable. With Telegram_SetChatMemberPermissionsMap(), you pass a byte map containing whichever permissions you want to set, whether #True or #False, and permissions missing from the map will be unaffected.
To revise just one permission:
Code: Select all
Telegram_SetChatMemberPermission(TelegramBotAPIToken,#TelegramTargetID,"the_user_id",#TG_Permission_SendPolls,#False)
To revise several permissions:
Code: Select all
NewMap cmp.b()
cmp(#TG_Permission_SendMessages)=#True
cmp(#TG_Permission_SendOtherMessages)=#False
cmp(#TG_Permission_ChangeInfo)=#True
Telegram_SetChatMemberPermissionsMap(#TelegramBotAPIToken,#TelegramTargetID,"the_user_id",cmp())
To revise
all permissions:
Code: Select all
perms.TG_ChatPermissionsStructure
perms\can_send_messages = #True
perms\can_send_media_messages = #False
perms\can_send_polls = #False
perms\can_send_other_messages = #True
perms\can_add_web_page_previews = #True
perms\can_change_info = #False
perms\can_invite_users = #False
perms\can_pin_messages = #False
Telegram_SetChatMemberPermissions(#TelegramBotAPIToken,TelegramTargetID,"the_user_id",@perms)
The GetUpdates functionality will be added very soon. I might build into it optional automatic harvesting of member ID numbers, because that is data that most people who use this API
will end up needing.
JACK WEBB: "Coding in C is like sculpting a statue using only sandpaper. You can do it, but the result wouldn't be any better. So why bother? Just use the right tools and get the job done."