Module telegram-bot-lua.helpers
helper methods for common telegram bot operations.
Functions
| api.get_chat_member_permissions(chat_id, user_id) | get the permissions of a chat member as a normalised table. |
| api.has_user_left(chat_id, user_id) | check if a user has left a chat. |
| api.is_user_group_admin(chat_id, user_id) | check if a user is an administrator or creator in a chat. |
| api.is_user_group_creator(chat_id, user_id) | check if a user is the creator of a chat. |
| api.is_user_kicked(chat_id, user_id) | check if a user has been kicked (banned) from a chat. |
| api.is_user_restricted(chat_id, user_id) | check if a user is restricted in a chat. |
Functions
- api.get_chat_member_permissions(chat_id, user_id)
-
get the permissions of a chat member as a normalised table.
returns a table with boolean values for each permission, defaulting to false.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
-
table|boolean permissions table, or false on failure
- api.has_user_left(chat_id, user_id)
-
check if a user has left a chat.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
- boolean true if the user has left
- string|number the HTTP status or the user's actual status
- api.is_user_group_admin(chat_id, user_id)
-
check if a user is an administrator or creator in a chat.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
- boolean true if the user is an admin or creator
- string|number the HTTP status or the user's actual status
- api.is_user_group_creator(chat_id, user_id)
-
check if a user is the creator of a chat.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
- boolean true if the user is the creator
- string|number the HTTP status or the user's actual status
- api.is_user_kicked(chat_id, user_id)
-
check if a user has been kicked (banned) from a chat.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
- boolean true if the user is kicked
- string|number the HTTP status or the user's actual status
- api.is_user_restricted(chat_id, user_id)
-
check if a user is restricted in a chat.
Parameters:
- chat_id number|string unique identifier for the target chat
- user_id number unique identifier of the target user
Returns:
- boolean true if the user is restricted
- string|number the HTTP status or the user's actual status