text
stringlengths
81
112k
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...
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: ...
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...
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:...
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 ...
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...
Bound method *download* of :obj:`Message <pyrogram.Message>`. Use as a shortcut for: .. code-block:: python client.download_media(message) Example: .. code-block:: python message.download() Args: file_name (``str``, *optional*): ...
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 ...
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...
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...
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...
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". ...
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=Non...
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...
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...
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...
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...
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 ...
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. ...
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``): ...
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*): ...
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...
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:...
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:...
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": ...
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...
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...
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...
Use this method to delete contacts from your Telegram address book. Args: ids (List of ``int``): A list of unique identifiers for the target users. Can be an ID (int), a username (string) or phone number (string). Returns: True on success. ...
Use this method to send a group of photos or videos as an album. 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...
Use this method to set the score of the specified user in a game. 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 contac...
Use this method to pin a message in a group, channel or your own chat. You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in the supergroup or "can_edit_messages" admin right in the channel. Args: chat_id (``int`` | ``str``): ...
Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. You must be an administrator in the chat for this to work and must have ...
Use this method to forward messages of any kind. 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 ...
Use this method to download the media from a message. Args: message (:obj:`Message <pyrogram.Message>` | ``str``): Pass a Message containing the media, the media itself (message.audio, message.video, ...) or the file id as string. file_name (``str``, *op...
Use this method to send 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...
Use this method to edit audio, document, photo, or video messages. If a message is a part of a message album, then it can be edited only to a photo or a video. Otherwise, message type can be changed arbitrarily. When inline message is edited, new file can't be uploaded. Use previously uploaded ...
Use this method to enable the Two-Step Verification security feature (Cloud Password) on your account. This password will be asked when you log-in on a new device in addition to the SMS code. Args: password (``str``): Your password. hint (``str``, *optional*): ...
Use this method to get the preview of a chat using the invite link. This method only returns a chat preview, if you want to join a chat use :meth:`join_chat` Args: invite_link (``str``): Unique identifier for the target chat in form of *t.me/joinchat/* links. Retur...
Use this method to change the title of a chat. Titles 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 A...
Use this method to get data for high score tables. 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 that exists i...
Use this method to unpin a message in a group, channel or your own chat. You must be an administrator in the chat for this to work and must have the "can_pin_messages" admin right in the supergroup or "can_edit_messages" admin right in the channel. Args: chat_id (``int`` | ``str``):...
Bound method *answer* of :obj:`CallbackQuery <pyrogram.CallbackQuery>`. Use this method as a shortcut for: .. code-block:: python client.answer_callback_query( callback_query.id, text="Hello", show_alert=True ) Example: ...
Use this method to get up to date information about the chat. Information include current name of the user for one-on-one conversations, current username of a user, group or channel, etc. Args: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of...
Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. Args: callback_query_id (``str``): Unique identifier for the query to be answered. ...
Use this method to create a Filter. Custom filters give you extra control over which updates are allowed or not to be processed by your handlers. Args: name (``str``): Your filter's name. Can be anything you like. func (``callable``): A function that accepts two argume...
Filter commands, i.e.: text messages starting with "/" or any other custom prefix. Args: commands (``str`` | ``list``): The command or list of commands as string the filter should look for. Examples: "start", ["start", "help", "settings"]. When a message text contain...
Filter messages that match a given RegEx pattern. Args: pattern (``str``): The RegEx pattern as string, it will be applied to the text of a message. When a pattern matches, all the `Match Objects <https://docs.python.org/3/library/re.html#match-objects>`_ ...
Use this method to change your Two-Step Verification password (Cloud Password) with a new one. Args: current_password (``str``): Your current password. new_password (``str``): Your new password. new_hint (``str``, *optional*): ...
Use this method to get information about one member of a chat. Args: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. user_id (``int`` | ``str``):: Unique identifier (int) or username (str) of the target chat. ...
Use this method to iterate through the members of a chat sequentially. This convenience method does the same as repeatedly calling :meth:`get_chat_members` in a loop, thus saving you from the hassle of setting up boilerplate code. It is useful for getting the whole members list of a chat with a...
Check that the argument is a type, and return it (internal helper). As a special case, accept None and return type(None) instead. Also, _TypeAlias instances (e.g. Match, Pattern) are acceptable. The msg argument is a human-readable error message, e.g. "Union[arg, ...]: arg should be a type." ...
Return the repr() of an object, special-casing types (internal helper). If obj is a type, we return a shorter version than the default type.__repr__, based on the module and qualified name, which is typically enough to uniquely identify a type. For everything else, we fall back on repr(obj). def _typ...
An internal helper function: replace arg if it is a type variable found in tvars with corresponding substitution from args or with corresponding substitution sub-tree if arg is a generic type. def _replace_arg(arg, tvars, args): """An internal helper function: replace arg if it is a type variable found...
An internal helper function: calculate substitution tree for generic cls after replacing its type parameters with substitutions in tvars -> args (if any). Repeat the same following __origin__'s. Return a list of arguments with all possible substitutions performed. Arguments that are generic classes...
An internal helper for Union creation and substitution: flatten Union's among parameters, then remove duplicates and strict subclasses. def _remove_dups_flatten(parameters): """An internal helper for Union creation and substitution: flatten Union's among parameters, then remove duplicates and strict subcla...
Internal wrapper caching __getitem__ of generic types with a fallback to original function for non-hashable arguments. def _tp_cache(func): """Internal wrapper caching __getitem__ of generic types with a fallback to original function for non-hashable arguments. """ cached = functools.lru_cache()(f...
Construct a __subclasshook__ callable that incorporates the associated __extra__ class in subclass checks performed against cls. def _make_subclasshook(cls): """Construct a __subclasshook__ callable that incorporates the associated __extra__ class in subclass checks performed against cls. """ ...
Internal helper: copy class __dict__ and clean slots class variables. (They will be re-created if necessary by normal class machinery.) def _no_slots_copy(dct): """Internal helper: copy class __dict__ and clean slots class variables. (They will be re-created if necessary by normal class machinery.) """...
Internal helper to extract the default arguments, by name. def _get_defaults(func): """Internal helper to extract the default arguments, by name.""" try: code = func.__code__ except AttributeError: # Some built-in functions don't have __code__, __defaults__, etc. return {} pos_c...
Return type hints for an object. This is often the same as obj.__annotations__, but it handles forward references encoded as string literals, and if necessary adds Optional[t] if a default value equal to None is set. The argument may be a module, class, method, or function. The annotations are ret...
Decorator to indicate that annotations are not type hints. The argument must be a class or function; if it is a class, it applies recursively to all methods and classes defined in that class (but not to methods defined in its superclasses or subclasses). This mutates the function(s) or class(es) in pl...
Decorator to give another decorator the @no_type_check effect. This wraps the decorator with something that wraps the decorated function in @no_type_check. def no_type_check_decorator(decorator): """Decorator to give another decorator the @no_type_check effect. This wraps the decorator with something...
NewType creates simple unique types with almost zero runtime overhead. NewType(name, tp) is considered a subtype of tp by static type checkers. At runtime, NewType(name, tp) returns a dummy function that simply returns its argument. Usage:: UserId = NewType('UserId', int) def name_by_id(us...
Use this method to get one or more messages that belong to a specific chat. You can retrieve up to 200 messages at once. Args: chat_id (``int`` | ``str``): Unique identifier (int) or username (str) of the target chat. For your personal cloud (Saved Messages) ...
Use this method to send information about a venue. 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 i...
Use this method to get bot results via inline queries. You can then send a result using :obj:`send_inline_bot_result <pyrogram.Client.send_inline_bot_result>` Args: bot (``int`` | ``str``): Unique identifier of the inline bot you want to get results from. You can specify ...
Use this method to join a group chat or channel. Args: chat_id (``str``): Unique identifier for the target chat in form of a *t.me/joinchat/* link or username of the target channel/supergroup (in the format @username). Returns: On success, a :obj...
Use this method to get contacts from your Telegram address book. Returns: On success, a list of :obj:`User` objects is returned. Raises: :class:`RPCError <pyrogram.RPCError>` in case of a Telegram RPC error. def get_contacts(self): """Use this method to get contacts fr...
Use this method to update a channel or a supergroup username. To update your own username (for users only, not bots) you can use :meth:`update_username`. Args: chat_id (``int`` | ``str``) Unique identifier (int) or username (str) of the target chat. user...
Use this method to send a game. 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...
Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). 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 "m...
Use this method to delete your own profile photos. Args: id (``str`` | ``list``): A single :obj:`Photo <pyrogram.Photo>` id as string or multiple ids as list of strings for deleting more than one photos at once. Returns: True on success. ...
Bound method *answer* of :obj:`InlineQuery <pyrogram.InlineQuery>`. Use this method as a shortcut for: .. code-block:: python client.answer_inline_query( inline_query.id, results=[...] ) Example: .. code-block:: python ...
Use this method to set a new profile photo for the chat. 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...
Use this method to get a chunk of the members list of a chat. You can get up to 200 chat members at once. A chat can be either a basic group, a supergroup or a channel. You must be admin to retrieve the members list of a channel (also known as "subscribers"). For a more convenient way o...
Use this method to leave a group chat or channel. Args: chat_id (``int`` | ``str``): Unique identifier for the target chat or username of the target channel/supergroup (in the format @username). delete (``bool``, *optional*): Deletes the ...
grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x') def grouper(n, iterable, padvalue=None): "grouper(3, 'abcdefg', 'x') --> ('a','b','c'), ('d','e','f'), ('g','x','x')" return zip_longest(*[iter(iterable)]*n, fillvalue=padvalue)
Returns a truncated random walk. path_length: Length of the random walk. alpha: probability of restarts. start: the start node of the random walk. def random_walk(self, path_length, alpha=0, rand=random.Random(), start=None): """ Returns a truncated random walk. path_length: Lengt...
Counts the word frequences in a list of sentences. Note: This is a helper function for parallel execution of `Vocabulary.from_text` method. def count_words(file): """ Counts the word frequences in a list of sentences. Note: This is a helper function for parallel execution of `Vocabulary.from_text` ...
Generates the random walks which will be used as the skip-gram input. :return: List of walks. Each walk is a list of nodes. def parallel_generate_walks(d_graph, global_walk_length, num_walks, cpu_num, sampling_strategy=None, num_walks_key=None, walk_length_key=None, neighbors_key=None, ...
Generated a KeyedVectors instance with all :return: def as_keyed_vectors(self): """ Generated a KeyedVectors instance with all :return: """ edge_generator = combinations_with_replacement(self.kv.index2word, r=2) if not self.quiet: vocab_size = len(s...
Precomputes transition probabilities for each node. def _precompute_probabilities(self): """ Precomputes transition probabilities for each node. """ d_graph = self.d_graph first_travel_done = set() nodes_generator = self.graph.nodes() if self.quiet \ else t...
Generates the random walks which will be used as the skip-gram input. :return: List of walks. Each walk is a list of nodes. def _generate_walks(self): """ Generates the random walks which will be used as the skip-gram input. :return: List of walks. Each walk is a list of nodes. ...
Creates the embeddings using gensim's Word2Vec. :param skip_gram_params: Parameteres for gensim.models.Word2Vec - do not supply 'size' it is taken from the Node2Vec 'dimensions' parameter :type skip_gram_params: dict :return: A gensim word2vec model def fit(self, **skip_gram_params): ""...
An example of using the query_user_info method :param twitter_user: the twitter user to capture user data :return: twitter_user_data: returns a dictionary of twitter user data def get_user_info(twitter_user): """ An example of using the query_user_info method :param twitter_user: the twitter user t...
Returns tweets from the given URL. :param query: The query parameter of the query url :param lang: The language parameter of the query url :param pos: The query url parameter that determines where to start looking :param retry: Number of retries if something goes wrong. :return: The list of tweets,...
Queries twitter for all the tweets you want! It will load all pages it gets from twitter. However, twitter might out of a sudden stop serving new pages, in that case, use the `query_tweets` method. Note that this function catches the KeyboardInterrupt so it can return tweets on incomplete queries if th...
Returns the scraped user data from a twitter user page. :param url: The URL to get the twitter user info from (url contains the user page) :param retry: Number of retries if something goes wrong. :return: Returns the scraped user data from a twitter user page. def query_user_page(url, retry=10): """ ...
Returns the scraped user data from a twitter user page. :param user: the twitter user to web scrape its twitter page info def query_user_info(user): """ Returns the scraped user data from a twitter user page. :param user: the twitter user to web scrape its twitter page info """ try: ...
Returns the scraped user data from a twitter user page. :param tag_prof_header: captures the left hand part of user info :param tag_prof_nav: captures the upper part of user info :return: Returns a User object with captured data via beautifulsoup def from_soup(self, tag_prof_header, tag_prof_n...
:param link_f: latent variables link(f) :type link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: includes censoring information in dictionary key 'censored' :returns: likelihood evaluated for this point :rtype: float def pdf_link(self, link_f, y, Y_me...
:param link_f: latent variables (link(f)) :type link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: includes censoring information in dictionary key 'censored' :returns: likelihood evaluated for this point :rtype: float def logpdf_link(self, link_f, y,...
derivative of logpdf wrt link_f param .. math:: :param link_f: latent variables link(f) :type link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: includes censoring information in dictionary key 'censored' :returns: likelihood evaluated for thi...
Gradient of the log-likelihood function at y given f, w.r.t shape parameter .. math:: :param inv_link_f: latent variables link(f) :type inv_link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: includes censoring information in dictionary key 'censored'...
:param link_f: latent variables link(f) :type link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: Y_metadata not used in gaussian :returns: derivative of log likelihood evaluated at points link(f) w.r.t variance parameter :rtype: Nx1 array def dlogpdf_...
:param link_f: latent variables link(f) :type link_f: Nx1 array :param y: data :type y: Nx1 array :param Y_metadata: Y_metadata not used in gaussian :returns: derivative of log likelihood evaluated at points link(f) w.r.t variance parameter :rtype: Nx1 array def d2logpdf...
Returns a set of samples of observations based on a given value of the latent variable. :param gp: latent variable def samples(self, gp, Y_metadata=None): """ Returns a set of samples of observations based on a given value of the latent variable. :param gp: latent variable """...
Check if the values of the observations correspond to the values assumed by the likelihood function. ..Note:: Binary classification algorithm works better with classes {-1, 1} def _preprocess_values(self, Y): """ Check if the values of the observations correspond to the values ...