INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
init func as lazy functon instance
Args:
function_meta (dict): function meta including name, args and kwargs | def __parse(self, function_meta):
""" init func as lazy functon instance
Args:
function_meta (dict): function meta including name, args and kwargs
"""
self._func = get_mapping_function(
function_meta["func_name"],
self.functions_mapping
)
... |
parse lazy data with evaluated variables mapping.
Notice: variables_mapping should not contain any variable or function. | def to_value(self, variables_mapping=None):
""" parse lazy data with evaluated variables mapping.
Notice: variables_mapping should not contain any variable or function.
"""
variables_mapping = variables_mapping or {}
args = parse_lazy_data(self._args, variables_mapping)
... |
parse raw string, replace function and variable with {}
Args:
raw_string(str): string with functions or varialbes
e.g. "ABC${func2($a, $b)}DE$c"
Returns:
string: "ABC{}DE{}"
args: ["${func2($a, $b)}", "$c"] | def __parse(self, raw_string):
""" parse raw string, replace function and variable with {}
Args:
raw_string(str): string with functions or varialbes
e.g. "ABC${func2($a, $b)}DE$c"
Returns:
string: "ABC{}DE{}"
args: ["${func2($a, $b)}", "$c"]
... |
parse lazy data with evaluated variables mapping.
Notice: variables_mapping should not contain any variable or function. | def to_value(self, variables_mapping=None):
""" parse lazy data with evaluated variables mapping.
Notice: variables_mapping should not contain any variable or function.
"""
variables_mapping = variables_mapping or {}
args = []
for arg in self._args:
if is... |
get request and response info from Response() object. | def get_req_resp_record(self, resp_obj):
""" get request and response info from Response() object.
"""
def log_print(req_resp_dict, r_type):
msg = "\n================== {} details ==================\n".format(r_type)
for key, value in req_resp_dict[r_type].items():
... |
Constructs and sends a :py:class:`requests.Request`.
Returns :py:class:`requests.Response` object.
:param method:
method for the new :class:`Request` object.
:param url:
URL for the new :class:`Request` object.
:param name: (optional)
Placeholder, mak... | def request(self, method, url, name=None, **kwargs):
"""
Constructs and sends a :py:class:`requests.Request`.
Returns :py:class:`requests.Response` object.
:param method:
method for the new :class:`Request` object.
:param url:
URL for the new :class:`Requ... |
Send a HTTP request, and catch any exception that might occur due to connection problems.
Safe mode has been removed from requests 1.x. | def _send_request_safe_mode(self, method, url, **kwargs):
"""
Send a HTTP request, and catch any exception that might occur due to connection problems.
Safe mode has been removed from requests 1.x.
"""
try:
msg = "processed request:\n"
msg += "> {method} {... |
convert comparator alias to uniform name | def get_uniform_comparator(comparator):
""" convert comparator alias to uniform name
"""
if comparator in ["eq", "equals", "==", "is"]:
return "equals"
elif comparator in ["lt", "less_than"]:
return "less_than"
elif comparator in ["le", "less_than_or_equals"]:
return "less_th... |
unify validator
Args:
validator (dict): validator maybe in two formats:
format1: this is kept for compatiblity with the previous versions.
{"check": "status_code", "comparator": "eq", "expect": 201}
{"check": "$resp_body_success", "comparator": "eq", "expect": T... | def uniform_validator(validator):
""" unify validator
Args:
validator (dict): validator maybe in two formats:
format1: this is kept for compatiblity with the previous versions.
{"check": "status_code", "comparator": "eq", "expect": 201}
{"check": "$resp_body... |
convert validators list to mapping.
Args:
validators (list): validators in list
Returns:
dict: validators mapping, use (check, comparator) as key.
Examples:
>>> validators = [
{"check": "v1", "expect": 201, "comparator": "eq"},
{"check": {"b": 1}, "... | def _convert_validators_to_mapping(validators):
""" convert validators list to mapping.
Args:
validators (list): validators in list
Returns:
dict: validators mapping, use (check, comparator) as key.
Examples:
>>> validators = [
{"check": "v1", "expect": 201, "c... |
extend raw_validators with override_validators.
override_validators will merge and override raw_validators.
Args:
raw_validators (dict):
override_validators (dict):
Returns:
list: extended validators
Examples:
>>> raw_validators = [{'eq': ['v1', 200]}, {"check": "s... | def extend_validators(raw_validators, override_validators):
""" extend raw_validators with override_validators.
override_validators will merge and override raw_validators.
Args:
raw_validators (dict):
override_validators (dict):
Returns:
list: extended validators
Examp... |
Takes (name, object) tuple, returns True if it is a variable. | def is_variable(tup):
""" Takes (name, object) tuple, returns True if it is a variable.
"""
name, item = tup
if callable(item):
# function or class
return False
if isinstance(item, types.ModuleType):
# imported module
return False
if name.startswith("_"):
... |
validate JSON testcase format | def validate_json_file(file_list):
""" validate JSON testcase format
"""
for json_file in set(file_list):
if not json_file.endswith(".json"):
logger.log_warning("Only JSON file format can be validated, skip: {}".format(json_file))
continue
logger.color_print("Start t... |
generate random string with specified length | def gen_random_string(str_len):
""" generate random string with specified length
"""
return ''.join(
random.choice(string.ascii_letters + string.digits) for _ in range(str_len)) |
get timestamp string, length can only between 0 and 16 | def get_timestamp(str_len=13):
""" get timestamp string, length can only between 0 and 16
"""
if isinstance(str_len, integer_types) and 0 < str_len < 17:
return builtin_str(time.time()).replace(".", "")[:str_len]
raise ParamsError("timestamp length can only between 0 and 16.") |
initialize MultipartEncoder with uploading fields. | def multipart_encoder(**kwargs):
""" initialize MultipartEncoder with uploading fields.
"""
def get_filetype(file_path):
file_type = filetype.guess(file_path)
if file_type:
return file_type.mime
else:
return "text/html"
fields_dict = {}
for key, value... |
parse testcase file and return locustfile path.
if file_path is a Python file, assume it is a locustfile
if file_path is a YAML/JSON file, convert it to locustfile | def parse_locustfile(file_path):
""" parse testcase file and return locustfile path.
if file_path is a Python file, assume it is a locustfile
if file_path is a YAML/JSON file, convert it to locustfile
"""
if not os.path.isfile(file_path):
color_print("file path invalid, exit.", "RED"... |
generate locustfile from template. | def gen_locustfile(testcase_file_path):
""" generate locustfile from template.
"""
locustfile_path = 'locustfile.py'
template_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"templates",
"locustfile_template"
)
with io.open(template_path, encoding='utf-... |
update session with extracted variables mapping.
these variables are valid in the whole running session. | def update_session_variables(self, variables_mapping):
""" update session with extracted variables mapping.
these variables are valid in the whole running session.
"""
variables_mapping = utils.ensure_mapping_format(variables_mapping)
self.session_variables_mapping.update(var... |
evaluate check item in validator.
Args:
check_item: check_item should only be the following 5 formats:
1, variable reference, e.g. $token
2, function reference, e.g. ${is_status_code_200($status_code)}
3, dict or list, maybe containing variable/functi... | def __eval_validator_check(self, check_item, resp_obj):
""" evaluate check item in validator.
Args:
check_item: check_item should only be the following 5 formats:
1, variable reference, e.g. $token
2, function reference, e.g. ${is_status_code_200($status_code... |
make validation with comparators | def validate(self, validators, resp_obj):
""" make validation with comparators
"""
self.validation_results = []
if not validators:
return
logger.log_debug("start to validate.")
validate_pass = True
failures = []
for validator in validators:
... |
get summary from test result
Args:
result (instance): HtmlTestResult() instance
Returns:
dict: summary extracted from result.
{
"success": True,
"stat": {},
"time": {},
"records": []
} | def get_summary(result):
""" get summary from test result
Args:
result (instance): HtmlTestResult() instance
Returns:
dict: summary extracted from result.
{
"success": True,
"stat": {},
"time": {},
"records": []
... |
aggregate new_stat to origin_stat.
Args:
origin_stat (dict): origin stat dict, will be updated with new_stat dict.
new_stat (dict): new stat dict. | def aggregate_stat(origin_stat, new_stat):
""" aggregate new_stat to origin_stat.
Args:
origin_stat (dict): origin stat dict, will be updated with new_stat dict.
new_stat (dict): new stat dict.
"""
for key in new_stat:
if key not in origin_stat:
origin_stat[key] = n... |
stringify summary, in order to dump json file and generate html report. | def stringify_summary(summary):
""" stringify summary, in order to dump json file and generate html report.
"""
for index, suite_summary in enumerate(summary["details"]):
if not suite_summary.get("name"):
suite_summary["name"] = "testcase {}".format(index)
for record in suite_s... |
stringfy HTTP request data
Args:
request_data (dict): HTTP request data in dict.
{
"url": "http://127.0.0.1:5000/api/get-token",
"method": "POST",
"headers": {
"User-Agent": "python-requests/2.20.0",
"Accep... | def __stringify_request(request_data):
""" stringfy HTTP request data
Args:
request_data (dict): HTTP request data in dict.
{
"url": "http://127.0.0.1:5000/api/get-token",
"method": "POST",
"headers": {
"User-Agent": "pyth... |
stringfy HTTP response data
Args:
response_data (dict):
{
"status_code": 404,
"headers": {
"Content-Type": "application/json",
"Content-Length": "30",
"Server": "Werkzeug/0.14.1 Python/3.7.0",
... | def __stringify_response(response_data):
""" stringfy HTTP response data
Args:
response_data (dict):
{
"status_code": 404,
"headers": {
"Content-Type": "application/json",
"Content-Length": "30",
"S... |
expand meta_datas to one level
Args:
meta_datas (dict/list): maybe in nested format
Returns:
list: expanded list in one level
Examples:
>>> meta_datas = [
[
dict1,
dict2
],
dict3
]
... | def __expand_meta_datas(meta_datas, meta_datas_expanded):
""" expand meta_datas to one level
Args:
meta_datas (dict/list): maybe in nested format
Returns:
list: expanded list in one level
Examples:
>>> meta_datas = [
[
dict1,
... |
caculate total response time of all meta_datas | def __get_total_response_time(meta_datas_expanded):
""" caculate total response time of all meta_datas
"""
try:
response_time = 0
for meta_data in meta_datas_expanded:
response_time += meta_data["stat"]["response_time_ms"]
return "{:.2f}".format(response_time)
excep... |
render html report with specified report name and template
Args:
report_template (str): specify html report template path
report_dir (str): specify html report save directory | def render_html_report(summary, report_template=None, report_dir=None):
""" render html report with specified report name and template
Args:
report_template (str): specify html report template path
report_dir (str): specify html report save directory
"""
if not report_template:
... |
extract field from response content with regex.
requests.Response body could be json or html text.
Args:
field (str): regex string that matched r".*\(.*\).*"
Returns:
str: matched content.
Raises:
exceptions.ExtractFailure: If no content matched... | def _extract_field_with_regex(self, field):
""" extract field from response content with regex.
requests.Response body could be json or html text.
Args:
field (str): regex string that matched r".*\(.*\).*"
Returns:
str: matched content.
Raises:
... |
response content could be json or html text.
Args:
field (str): string joined by delimiter.
e.g.
"status_code"
"headers"
"cookies"
"content"
"headers.content-type"
"content.person.name.first_... | def _extract_field_with_delimiter(self, field):
""" response content could be json or html text.
Args:
field (str): string joined by delimiter.
e.g.
"status_code"
"headers"
"cookies"
"content"
"heade... |
extract value from requests.Response. | def extract_field(self, field):
""" extract value from requests.Response.
"""
if not isinstance(field, basestring):
err_msg = u"Invalid extractor! => {}\n".format(field)
logger.log_error(err_msg)
raise exceptions.ParamsError(err_msg)
msg = "extract: {... |
extract value from requests.Response and store in OrderedDict.
Args:
extractors (list):
[
{"resp_status_code": "status_code"},
{"resp_headers_content_type": "headers.content-type"},
{"resp_content": "content"},
... | def extract_response(self, extractors):
""" extract value from requests.Response and store in OrderedDict.
Args:
extractors (list):
[
{"resp_status_code": "status_code"},
{"resp_headers_content_type": "headers.content-type"},
... |
Use this method to request a callback answer from bots.
This is the equivalent of clicking an inline button containing callback data.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Sav... | def request_callback_answer(
self,
chat_id: Union[int, str],
message_id: int,
callback_data: bytes
):
"""Use this method to request a callback answer from bots.
This is the equivalent of clicking an inline button containing callback data.
Args:
ch... |
Use this method to promote or demote a user in a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Pass False for all boolean parameters to demote a user.
Args:
chat_id (``int`` | ``str``):
... | def promote_chat_member(
self,
chat_id: Union[int, str],
user_id: Union[int, str],
can_change_info: bool = True,
can_post_messages: bool = False,
can_edit_messages: bool = False,
can_delete_messages: bool = True,
can_restrict_members: bool = True,
... |
Use this method to set a new profile photo.
This method only works for Users.
Bots profile photos must be set using BotFather.
Args:
photo (``str``):
Profile photo to set.
Pass a file path as string to upload a new photo that exists on your local mac... | def set_user_profile_photo(
self,
photo: str
) -> bool:
"""Use this method to set a new profile photo.
This method only works for Users.
Bots profile photos must be set using BotFather.
Args:
photo (``str``):
Profile photo to set.
... |
https://core.telegram.org/mtproto/auth_key
https://core.telegram.org/mtproto/samples-auth_key | def create(self):
"""
https://core.telegram.org/mtproto/auth_key
https://core.telegram.org/mtproto/samples-auth_key
"""
retries_left = self.MAX_RETRIES
# The server may close the connection at any time, causing the auth key creation to fail.
# If that happens, ju... |
Use this method to iterate through a chat history sequentially.
This convenience method does the same as repeatedly calling :meth:`get_history` in a loop, thus saving you from
the hassle of setting up boilerplate code. It is useful for getting the whole chat history with a single call.
Args:
... | def iter_history(
self,
chat_id: Union[int, str],
limit: int = 0,
offset: int = 0,
offset_id: int = 0,
offset_date: int = 0,
reverse: bool = False
) -> Generator["pyrogram.Message", None, None]:
"""Use this method to iterate through a chat history sequ... |
Use this method to send phone contacts.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Tele... | def send_contact(
self,
chat_id: Union[int, str],
phone_number: str,
first_name: str,
last_name: str = None,
vcard: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKey... |
Use this method to edit text messages.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Teleg... | def edit_message_text(
self,
chat_id: Union[int, str],
message_id: int,
text: str,
parse_mode: str = "",
disable_web_page_preview: bool = None,
reply_markup: "pyrogram.InlineKeyboardMarkup" = None
) -> "pyrogram.Message":
"""Use this method to edit tex... |
Use this method to retrieve a chunk of the history of a chat.
You can get up to 100 messages at once.
For a more convenient way of getting a chat history see :meth:`iter_history`.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the ta... | def get_history(
self,
chat_id: Union[int, str],
limit: int = 100,
offset: int = 0,
offset_id: int = 0,
offset_date: int = 0,
reverse: bool = False
):
"""Use this method to retrieve a chunk of the history of a chat.
You can get up to 100 messa... |
Use this decorator to automatically register a function for handling user status updates.
This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`.
Args:
filters (:obj:`Filters <pyrogram.Filters>`):
Pass one or more filters to allow only a subset ... | def on_user_status(
self=None,
filters=None,
group: int = 0
) -> callable:
"""Use this decorator to automatically register a function for handling user status updates.
This does the same thing as :meth:`add_handler` using the :class:`UserStatusHandler`.
Args:
... |
Use this method to get the number of members in a chat.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
On success, an integer is returned.
Raises:
:class:`RPCError <pyrogram.RPCError... | def get_chat_members_count(
self,
chat_id: Union[int, str]
) -> int:
"""Use this method to get the number of members in a chat.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
Returns:
... |
Use this decorator to automatically register a function for handling disconnections.
This does the same thing as :meth:`add_handler` using the :class:`DisconnectHandler`. | def on_disconnect(self=None) -> callable:
"""Use this decorator to automatically register a function for handling disconnections.
This does the same thing as :meth:`add_handler` using the :class:`DisconnectHandler`.
"""
def decorator(func: callable) -> Handler:
handler = pyr... |
Use this method to start the Client after creating it.
Requires no parameters.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
``ConnectionError`` in case you try to start an already started Client. | def start(self):
"""Use this method to start the Client after creating it.
Requires no parameters.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error.
``ConnectionError`` in case you try to start an already started Client.
"""
i... |
Use this method to manually stop the Client.
Requires no parameters.
Raises:
``ConnectionError`` in case you try to stop an already stopped Client. | def stop(self):
"""Use this method to manually stop the Client.
Requires no parameters.
Raises:
``ConnectionError`` in case you try to stop an already stopped Client.
"""
if not self.is_started:
raise ConnectionError("Client is already stopped")
... |
Blocks the program execution until one of the signals are received,
then gently stop the Client by closing the underlying connection.
Args:
stop_signals (``tuple``, *optional*):
Iterable containing signals the signal handler will listen to.
Defaults to (SIGIN... | def idle(self, stop_signals: tuple = (SIGINT, SIGTERM, SIGABRT)):
"""Blocks the program execution until one of the signals are received,
then gently stop the Client by closing the underlying connection.
Args:
stop_signals (``tuple``, *optional*):
Iterable containing ... |
Use this method to register an update handler.
You can register multiple handlers, but at most one handler within a group
will be used for a single update. To handle the same update more than once, register
your handler using a different group id (lower group id == higher priority).
Ar... | def add_handler(self, handler: Handler, group: int = 0):
"""Use this method to register an update handler.
You can register multiple handlers, but at most one handler within a group
will be used for a single update. To handle the same update more than once, register
your handler using a... |
Removes a previously-added update handler.
Make sure to provide the right group that the handler was added in. You can use
the return value of the :meth:`add_handler` method, a tuple of (handler, group), and
pass it directly.
Args:
handler (``Handler``):
The... | def remove_handler(self, handler: Handler, group: int = 0):
"""Removes a previously-added update handler.
Make sure to provide the right group that the handler was added in. You can use
the return value of the :meth:`add_handler` method, a tuple of (handler, group), and
pass it directly... |
Use this method to send Raw Function queries.
This method makes possible to manually call every single Telegram API method in a low-level manner.
Available functions are listed in the :obj:`functions <pyrogram.api.functions>` package and may accept compound
data types from :obj:`types <pyrogram... | def send(self,
data: Object,
retries: int = Session.MAX_RETRIES,
timeout: float = Session.WAIT_TIMEOUT):
"""Use this method to send Raw Function queries.
This method makes possible to manually call every single Telegram API method in a low-level manner.
Av... |
Use this method to get the InputPeer of a known peer_id.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use method), whenever an
InputPeer type is requ... | def resolve_peer(self,
peer_id: Union[int, str]):
"""Use this method to get the InputPeer of a known peer_id.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the ... |
Use this method to upload a file onto Telegram servers, without actually sending the message to anyone.
This is a utility method intended to be used **only** when working with Raw Functions (i.e: a Telegram API
method you wish to use which is not available yet in the Client class as an easy-to-use meth... | def save_file(self,
path: str,
file_id: int = None,
file_part: int = 0,
progress: callable = None,
progress_args: tuple = ()):
"""Use this method to upload a file onto Telegram servers, without actually sending the message... |
Use this method when you need to tell the other party that something is happening on your side.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self"... | def send_chat_action(
self,
chat_id: Union[int, str],
action: Union[ChatAction, str],
progress: int = 0
):
"""Use this method when you need to tell the other party that something is happening on your side.
Args:
chat_id (``int`` | ``str``):
... |
Use this method to send answers to an inline query.
No more than 50 results per query are allowed.
Args:
inline_query_id (``str``):
Unique identifier for the answered query.
results (List of :obj:`InlineQueryResult <pyrogram.InlineQueryResult>`):
... | def answer_inline_query(
self,
inline_query_id: str,
results: List[InlineQueryResult],
cache_time: int = 300,
is_personal: bool = None,
next_offset: str = "",
switch_pm_text: str = "",
switch_pm_parameter: str = ""
):
"""Use this method to send... |
Use this method to send points on the map.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your T... | def send_location(
self,
chat_id: Union[int, str],
latitude: float,
longitude: float,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
... |
Use this method to retract your vote in a poll.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in y... | def retract_vote(
self,
chat_id: Union[int, str],
message_id: id
) -> bool:
"""Use this method to retract your vote in a poll.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For you... |
Use this method to get a list of profile pictures for a user.
Args:
user_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact th... | def get_user_profile_photos(
self,
user_id: Union[int, str],
offset: int = 0,
limit: int = 100
) -> "pyrogram.UserProfilePhotos":
"""Use this method to get a list of profile pictures for a user.
Args:
user_id (``int`` | ``str``):
Unique id... |
Use this method to update your own username.
This method only works for users, not bots. Bot usernames must be changed via Bot Support or by recreating
them from scratch using BotFather. To update a channel or supergroup username you can use
:meth:`update_chat_username`.
Args:
... | def update_username(
self,
username: Union[str, None]
) -> bool:
"""Use this method to update your own username.
This method only works for users, not bots. Bot usernames must be changed via Bot Support or by recreating
them from scratch using BotFather. To update a ... |
Bound method *reply* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_message(
chat_id=message.chat.id,
text="hello",
reply_to_message_id=message.message_id
)
Example:
... | def reply(
self,
text: str,
quote: bool = None,
parse_mode: str = "",
disable_web_page_preview: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup=None
) -> "Message":
"""Bound method *reply* of :obj:`... |
Bound method *reply_animation* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_animation(
chat_id=message.chat.id,
animation=animation
)
Example:
.. code-block:: python
... | def reply_animation(
self,
animation: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
width: int = 0,
height: int = 0,
thumb: str = None,
disable_notification: bool = None,
reply_markup: Union[
... |
Bound method *reply_audio* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_audio(
chat_id=message.chat.id,
audio=audio
)
Example:
.. code-block:: python
messag... | def reply_audio(
self,
audio: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
performer: str = None,
title: str = None,
thumb: str = None,
disable_notification: bool = None,
reply_to_message_id: ... |
Bound method *reply_cached_media* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_cached_media(
chat_id=message.chat.id,
file_id=file_id
)
Example:
.. code-block:: python
... | def reply_cached_media(
self,
file_id: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyro... |
Bound method *reply_game* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_game(
chat_id=message.chat.id,
game_short_name="lumberjack"
)
Example:
.. code-block:: python
... | def reply_game(
self,
game_short_name: str,
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
"pyrogram.ReplyKey... |
Bound method *reply_media_group* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_media_group(
chat_id=message.chat.id,
media=list_of_media
)
Example:
.. code-block:: python
... | def reply_media_group(
self,
media: List[Union["pyrogram.InputMediaPhoto", "pyrogram.InputMediaVideo"]],
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None
) -> "Message":
"""Bound method *reply_media_group* of :obj:`Message <pyrogr... |
Bound method *reply_inline_bot_result* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_inline_bot_result(
chat_id=message.chat.id,
query_id=query_id,
result_id=result_id
)
... | def reply_inline_bot_result(
self,
query_id: int,
result_id: str,
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
hide_via: bool = None
) -> "Message":
"""Bound method *reply_inline_bot_result* of :obj:`Message <... |
Bound method *reply_document* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_document(
chat_id=message.chat.id,
document=document
)
Example:
.. code-block:: python
... | def reply_document(
self,
document: str,
quote: bool = None,
thumb: str = None,
caption: str = "",
parse_mode: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMa... |
Bound method *reply_photo* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_photo(
chat_id=message.chat.id,
photo=photo
)
Example:
.. code-block:: python
messag... | def reply_photo(
self,
photo: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
ttl_seconds: int = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMa... |
Bound method *reply_poll* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_poll(
chat_id=message.chat.id,
question="Is Pyrogram the best?",
options=["Yes", "Yes"]
)
Example:... | def reply_poll(
self,
question: str,
options: List[str],
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
... |
Bound method *reply_sticker* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_sticker(
chat_id=message.chat.id,
sticker=sticker
)
Example:
.. code-block:: python
... | def reply_sticker(
self,
sticker: str,
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
"pyrogram.ReplyKeyboard... |
Bound method *reply_venue* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_venue(
chat_id=message.chat.id,
latitude=41.890251,
longitude=12.492373,
title="Coliseum",
... | def reply_venue(
self,
latitude: float,
longitude: float,
title: str,
address: str,
quote: bool = None,
foursquare_id: str = "",
foursquare_type: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_ma... |
Bound method *reply_video* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_video(
chat_id=message.chat.id,
video=video
)
Example:
.. code-block:: python
messag... | def reply_video(
self,
video: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
width: int = 0,
height: int = 0,
thumb: str = None,
supports_streaming: bool = True,
disable_notification: bool = Non... |
Bound method *reply_video_note* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_video_note(
chat_id=message.chat.id,
video_note=video_note
)
Example:
.. code-block:: python
... | def reply_video_note(
self,
video_note: str,
quote: bool = None,
duration: int = 0,
length: int = 1,
thumb: str = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMar... |
Bound method *reply_voice* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_voice(
chat_id=message.chat.id,
voice=voice
)
Example:
.. code-block:: python
messag... | def reply_voice(
self,
voice: str,
quote: bool = None,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",... |
Bound method *edit* of :obj:`Message <pyrogram.Message>`
Use as a shortcut for:
.. code-block:: python
client.edit_message_text(
chat_id=message.chat.id,
message_id=message.message_id,
text="hello"
)
Example:
... | def edit(
self,
text: str,
parse_mode: str = "",
disable_web_page_preview: bool = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
"pyrogram.ReplyKeyboardRemove",
"pyrogram.ForceReply"
... |
Bound method *edit_caption* of :obj:`Message <pyrogram.Message>`
Use as a shortcut for:
.. code-block:: python
client.edit_message_caption(
chat_id=message.chat.id,
message_id=message.message_id,
caption="hello"
)
Exampl... | def edit_caption(
self,
caption: str,
parse_mode: str = "",
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
"pyrogram.ReplyKeyboardRemove",
"pyrogram.ForceReply"
] = None
) -> "Message":
... |
Bound method *forward* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.forward_messages(
chat_id=chat_id,
from_chat_id=message.chat.id,
message_ids=message.message_id
)
Example:... | def forward(
self,
chat_id: int or str,
disable_notification: bool = None,
as_copy: bool = False,
remove_caption: bool = False
) -> "Message":
"""Bound method *forward* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: pyth... |
Bound method *delete* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.delete_messages(
chat_id=chat_id,
message_ids=message.message_id
)
Example:
.. code-block:: python
... | def delete(self, revoke: bool = True):
"""Bound method *delete* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.delete_messages(
chat_id=chat_id,
message_ids=message.message_id
)
Exampl... |
Bound method *click* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for clicking a button attached to the message instead of.
- Clicking inline buttons:
.. code-block:: python
client.request_callback_answer(
chat_id=message.chat.id,
messag... | def click(self, x: int or str, y: int = None, quote: bool = None):
"""Bound method *click* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for clicking a button attached to the message instead of.
- Clicking inline buttons:
.. code-block:: python
client.request_ca... |
Bound method *pin* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.pin_chat_message(
chat_id=message.chat.id,
message_id=message_id
)
Example:
.. code-block:: python
... | def pin(self, disable_notification: bool = None) -> "Message":
"""Bound method *pin* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.pin_chat_message(
chat_id=message.chat.id,
message_id=message_id
... |
Use this method to get a chunk of the user's dialogs.
You can get up to 100 dialogs at once.
For a more convenient way of getting a user's dialogs see :meth:`iter_dialogs`.
Args:
offset_date (``int``):
The offset date in Unix time taken from the top message of a :ob... | def get_dialogs(
self,
offset_date: int = 0,
limit: int = 100,
pinned_only: bool = False
) -> "pyrogram.Dialogs":
"""Use this method to get a chunk of the user's dialogs.
You can get up to 100 dialogs at once.
For a more convenient way of getting a user's dia... |
Use this method to get information about a user.
You can retrieve up to 200 users at once.
Args:
user_ids (``iterable``):
A list of User identifiers (id or username) or a single user id/username.
For a contact that exists in your Telegram address book you can... | def get_users(
self,
user_ids: Iterable[Union[int, str]]
) -> Union["pyrogram.User", List["pyrogram.User"]]:
"""Use this method to get information about a user.
You can retrieve up to 200 users at once.
Args:
user_ids (``iterable``):
A list of Use... |
Use this method to send animation files (animation or H.264/MPEG-4 AVC video without sound).
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
... | def send_animation(
self,
chat_id: Union[int, str],
animation: str,
caption: str = "",
parse_mode: str = "",
duration: int = 0,
width: int = 0,
height: int = 0,
thumb: str = None,
disable_notification: bool = None,
reply_to_message_... |
Use this method to vote a poll.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram add... | def vote_poll(
self,
chat_id: Union[int, str],
message_id: id,
option: int
) -> bool:
"""Use this method to vote a poll.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For y... |
Use this decorator to automatically register a function for handling raw updates.
This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`.
Args:
group (``int``, *optional*):
The group identifier, defaults to 0. | def on_raw_update(
self=None,
group: int = 0
) -> callable:
"""Use this decorator to automatically register a function for handling raw updates.
This does the same thing as :meth:`add_handler` using the :class:`RawUpdateHandler`.
Args:
group (``int``, *optional*)... |
Use this method to close (stop) a poll.
Closed polls can't be reopened and nobody will be able to vote in it anymore.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) yo... | def close_poll(
self,
chat_id: Union[int, str],
message_id: id
) -> bool:
"""Use this method to close (stop) a poll.
Closed polls can't be reopened and nobody will be able to vote in it anymore.
Args:
chat_id (``int`` | ``str``):
Unique i... |
Use this method to send an inline bot result.
Bot results can be retrieved using :obj:`get_inline_bot_results <pyrogram.Client.get_inline_bot_results>`
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your p... | def send_inline_bot_result(
self,
chat_id: Union[int, str],
query_id: int,
result_id: str,
disable_notification: bool = None,
reply_to_message_id: int = None,
hide_via: bool = None
):
"""Use this method to send an inline bot result.
Bot results... |
Use this method to send any media stored on the Telegram servers using a file_id.
This convenience method works with any valid file_id only.
It does the same as calling the relevant method for sending media using a file_id, thus saving you from the
hassle of using the correct method for the med... | def send_cached_media(
self,
chat_id: Union[int, str],
file_id: str,
caption: str = "",
parse_mode: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
... |
Bound method *forward* of :obj:`Message <pyrogram.Messages>`.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact th... | def forward(
self,
chat_id: Union[int, str],
disable_notification: bool = None,
as_copy: bool = False,
remove_caption: bool = False
):
"""Bound method *forward* of :obj:`Message <pyrogram.Messages>`.
Args:
chat_id (``int`` | ``str``):
... |
Use this method to delete messages, including service messages.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact ... | def delete_messages(
self,
chat_id: Union[int, str],
message_ids: Iterable[int],
revoke: bool = True
) -> bool:
"""Use this method to delete messages, including service messages.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) o... |
Use this method to unban a previously kicked user in a supergroup or channel.
The user will **not** return to the group or channel automatically, but will be able to join via link, etc.
You must be an administrator for this to work.
Args:
chat_id (``int`` | ``str``):
... | def unban_chat_member(
self,
chat_id: Union[int, str],
user_id: Union[int, str]
) -> bool:
"""Use this method to unban a previously kicked user in a supergroup or channel.
The user will **not** return to the group or channel automatically, but will be able to join via link, e... |
Use this method to change the description of a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
... | def set_chat_description(
self,
chat_id: Union[int, str],
description: str
) -> bool:
"""Use this method to change the description of a supergroup or a channel.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Args... |
Use this method to restrict a chat.
Pass True for all boolean parameters to lift restrictions from a chat.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
can_send_messages (``bool``, *optional*):
... | def restrict_chat(
self,
chat_id: Union[int, str],
can_send_messages: bool = False,
can_send_media_messages: bool = False,
can_send_other_messages: bool = False,
can_add_web_page_previews: bool = False,
can_send_polls: bool = False,
can_change_info: bool =... |
Use this method to delete a chat photo.
Photos can't be changed for private chats.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Note:
In regular groups (non-supergroups), this method will only work if the "All Members Are Admi... | def delete_chat_photo(
self,
chat_id: Union[int, str]
) -> bool:
"""Use this method to delete a chat photo.
Photos can't be changed for private chats.
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
Note:
... |
Use this method to add contacts to your Telegram address book.
Args:
contacts (List of :obj:`InputPhoneContact <pyrogram.InputPhoneContact>`):
The contact list to be added
Returns:
On success, the added contacts are returned.
Raises:
:class:... | def add_contacts(
self,
contacts: List["pyrogram.InputPhoneContact"]
):
"""Use this method to add contacts to your Telegram address book.
Args:
contacts (List of :obj:`InputPhoneContact <pyrogram.InputPhoneContact>`):
The contact list to be added
... |
Put flags at the end | def sort_args(args):
"""Put flags at the end"""
args = args.copy()
flags = [i for i in args if FLAGS_RE.match(i[1])]
for i in flags:
args.remove(i)
return args + flags |
Use this method to iterate through a user's dialogs sequentially.
This convenience method does the same as repeatedly calling :meth:`get_dialogs` in a loop, thus saving you from
the hassle of setting up boilerplate code. It is useful for getting the whole dialogs list with a single call.
Args:... | def iter_dialogs(
self,
offset_date: int = 0,
limit: int = 0
) -> Generator["pyrogram.Dialog", None, None]:
"""Use this method to iterate through a user's dialogs sequentially.
This convenience method does the same as repeatedly calling :meth:`get_dialogs` in a loop, thus sa... |
A simple method for testing your authorization. Requires no parameters.
Returns:
Basic information about the user or bot in form of a :obj:`User` object
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error. | def get_me(self) -> "pyrogram.User":
"""A simple method for testing your authorization. Requires no parameters.
Returns:
Basic information about the user or bot in form of a :obj:`User` object
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error... |
Use this method to generate a new invite link for a chat; any previously generated link is revoked.
You must be an administrator in the chat for this to work and have the appropriate admin rights.
Args:
chat_id (``int`` | ``str``):
Unique identifier for the target chat or u... | def export_chat_invite_link(
self,
chat_id: Union[int, str]
) -> str:
"""Use this method to generate a new invite link for a chat; any previously generated link is revoked.
You must be an administrator in the chat for this to work and have the appropriate admin rights.
Args... |
Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
Args:
password (``str``):
Your current password.
Returns:
True on success.
Raises:
:class:`RPCError <pyrogram.RPCError>` in case of a Te... | def remove_cloud_password(
self,
password: str
) -> bool:
"""Use this method to turn off the Two-Step Verification security feature (Cloud Password) on your account.
Args:
password (``str``):
Your current password.
Returns:
True on su... |
Use this method to send a new poll.
Args:
chat_id (``int`` | ``str``):
Unique identifier (int) or username (str) of the target chat.
For your personal cloud (Saved Messages) you can simply use "me" or "self".
For a contact that exists in your Telegram... | def send_poll(
self,
chat_id: Union[int, str],
question: str,
options: List[str],
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.