INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
parse testcase/ testsuite config. | def __prepare_config(config, project_mapping, session_variables_set=None):
""" parse testcase/testsuite config.
"""
# get config variables
raw_config_variables = config.pop("variables", {})
raw_config_variables_mapping = utils.ensure_mapping_format(raw_config_variables)
override_variables = util... |
init func as lazy functon instance | 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 {} | 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. | 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 | 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. | 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. | 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. | 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 | 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. | 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 | 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 | 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 | 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 | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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. | 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 >. | 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 >. | 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 >. | 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 >. | 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_chat_action * of: obj: Message <pyrogram. Message >. | def reply_chat_action(
self,
action: Union[ChatAction, str],
progress: int = 0
) -> "Message":
"""Bound method *reply_chat_action* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_chat_action(
... |
Bound method * reply_contact * of: obj: Message <pyrogram. Message >. | def reply_contact(
self,
phone_number: str,
first_name: str,
quote: bool = None,
last_name: str = "",
vcard: str = "",
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMark... |
Bound method * reply_document * of: obj: Message <pyrogram. Message >. | 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_game * of: obj: Message <pyrogram. Message >. | 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_inline_bot_result * of: obj: Message <pyrogram. Message >. | 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_location * of: obj: Message <pyrogram. Message >. | def reply_location(
self,
latitude: float,
longitude: float,
quote: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup: Union[
"pyrogram.InlineKeyboardMarkup",
"pyrogram.ReplyKeyboardMarkup",
... |
Bound method * reply_media_group * of: obj: Message <pyrogram. Message >. | 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_photo * of: obj: Message <pyrogram. Message >. | 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 >. | 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 >. | 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 >. | 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 >. | 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 >. | 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 >. | 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 > | 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 > | 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 >. | 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 >. | 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 >. | 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 * download * of: obj: Message <pyrogram. Message >. | def download(
self,
file_name: str = "",
block: bool = True,
progress: callable = None,
progress_args: tuple = ()
) -> "Message":
"""Bound method *download* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
... |
Bound method * pin * of: obj: Message <pyrogram. Message >. | 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. | 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. | 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 vote a poll. | 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 method to send animation files ( animation or H. 264/ MPEG - 4 AVC video without sound ). | 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 decorator to automatically register a function for handling raw updates. This does the same thing as: meth: add_handler using the: class: RawUpdateHandler. | 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. | 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 > | 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. | 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 >. | 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. | 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 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. | 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 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. | 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 restrict a chat. Pass True for all boolean parameters to lift restrictions from a chat. | 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. | 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. | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.