ptbtest.chatgenerator module¶
This module provides a class to generate telegram chats
- class ptbtest.chatgenerator.ChatGenerator¶
Bases:
PtbGeneratorChat generator class. Placeholder for random names and mainly used via it’s get_chat() method.
- get_channel_chat(id: Optional[int] = None, title: Optional[str] = None, username: Optional[str] = None) Chat¶
The convenient method for generating channel chats. If any of the arguments are omitted the values will be chosen randomly.
- Parameters
id (Optional[int]) – ID of the returned chat.
title (Optional[str]) – Title for the group/supergroup/channel.
username (Optional[str]) – Username for the private/supergroup/channel.
- Returns
A telegram.Chat object with ‘channel’ ChatType.
- Return type
- get_chat(id: Optional[int] = None, type: Optional[Union[ChatType, str]] = None, title: Optional[str] = None, username: Optional[str] = None, user: Optional[User] = None, is_forum: bool = False, *, all_members_are_administrators: bool = False) Chat¶
Returns a telegram.Chat object with the optionally given type or username If any of the arguments are omitted the names will be chosen randomly and the username will be generated as first_name + last_name.
When called without arguments will return a telegram.Chat object for a private chat with a randomly generated user.
- Parameters
id (Optional[int]) – ID of the returned chat.
type (Optional[Union[ChatType, str]]) – Type of the chat can be either telegram.constants.ChatType or the string literal (“private”, “group”, “supergroup”, “channel”).
title (Optional[str]) – Title for the group/supergroup/channel.
username (Optional[str]) – Username for the private/supergroup/channel.
user (Optional[telegram.User]) – If given, a private chat for the supplied user will be generated.
is_forum (bool) – True, if the supergroup chat is a forum (has topics enabled). Default is False.
all_members_are_administrators (Optional[bool]) – Sets this flag for a group.
- Returns
A telegram.Chat object.
- Return type
- get_group_chat(id: Optional[int] = None, title: Optional[str] = None, username: Optional[str] = None, is_forum: bool = False, is_supergroup: bool = False, *, all_members_are_administrators: bool = False) Chat¶
The convenient method for generating [super]group chats. If any of the arguments are omitted the values will be chosen randomly.
- Parameters
id (Optional[int]) – ID of the returned chat.
title (Optional[str]) – Title for the group/supergroup/channel.
username (Optional[str]) – Username for the private/supergroup/channel.
is_forum (bool) – True, if the supergroup chat is a forum (has topics enabled). Default is False.
is_supergroup (bool) – True, if the chat must be supergroup. Default is False.
all_members_are_administrators (Optional[bool]) – Sets this flag for a group.
- Returns
A telegram.Chat object.
- Return type
- get_private_chat(id: Optional[int] = None, user: Optional[User] = None, username: Optional[str] = None, first_name: Optional[str] = None, last_name: Optional[str] = None) Chat¶
The convenient method for generating private chats. If any of the arguments are omitted the values will be chosen randomly.
- Parameters
id (Optional[int]) – ID of the returned chat.
user (Optional[telegram.User]) – If given, a private chat for the supplied user will be generated.
username (Optional[str]) – A username for the user.
first_name (Optional[str]) – The first name for the user.
last_name (Optional[str]) – The last name for the user.
- Returns
A telegram.Chat object with the ‘private’ ChatType.
- Return type