code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
assert_type_or_raise(chat_id, (int, unicode_type), parameter_name="chat_id") result = self.do("getChat", chat_id=chat_id) if self.return_python_objects: logger.debug("Trying to parse {data}".format(data=repr(result))) from pytgbot.api_types.receivable.pe...
def get_chat(self, chat_id)
Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. https://core.telegram.org/bots/api#getchat Parameters: :param chat_id: U...
3.487219
3.526212
0.988942
assert_type_or_raise(chat_id, (int, unicode_type), parameter_name="chat_id") result = self.do("getChatAdministrators", chat_id=chat_id) if self.return_python_objects: logger.debug("Trying to parse {data}".format(data=repr(result))) from pytgbot.api_types...
def get_chat_administrators(self, chat_id)
Use this method to get a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned. https://core.t...
3.527688
3.453423
1.021505
assert_type_or_raise(chat_id, (int, unicode_type), parameter_name="chat_id") assert_type_or_raise(sticker_set_name, unicode_type, parameter_name="sticker_set_name") result = self.do("setChatStickerSet", chat_id=chat_id, sticker_set_name=sticker_set_name) if sel...
def set_chat_sticker_set(self, chat_id, sticker_set_name)
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success. ...
3.40586
2.96215
1.149793
assert_type_or_raise(callback_query_id, unicode_type, parameter_name="callback_query_id") assert_type_or_raise(text, None, unicode_type, parameter_name="text") assert_type_or_raise(show_alert, None, bool, parameter_name="show_alert") assert_type_or_rai...
def answer_callback_query(self, callback_query_id, text=None, show_alert=None, url=None, cache_time=None)
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. On success, True is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, yo...
2.524524
2.437585
1.035666
from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup assert_type_or_raise(text, unicode_type, parameter_name="text") assert_type_or_raise(chat_id, None, (int, unicode_type), parameter_name="chat_id") assert_type_or_raise(message_id,...
def edit_message_text(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, disable_web_page_preview=None, reply_markup=None)
Use this method to edit text and game messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. https://core.telegram.org/bots/api#editmessagetext Parameters: :param...
1.834741
1.753921
1.04608
assert_type_or_raise(name, unicode_type, parameter_name="name") result = self.do("getStickerSet", name=name) if self.return_python_objects: logger.debug("Trying to parse {data}".format(data=repr(result))) from pytgbot.api_types.receivable.stickers import...
def get_sticker_set(self, name)
Use this method to get a sticker set. On success, a StickerSet object is returned. https://core.telegram.org/bots/api#getstickerset Parameters: :param name: Name of the sticker set :type name: str|unicode Returns: :return: On succes...
3.461299
3.53527
0.979076
from pytgbot.api_types.sendable.files import InputFile assert_type_or_raise(user_id, int, parameter_name="user_id") assert_type_or_raise(png_sticker, InputFile, parameter_name="png_sticker") result = self.do("uploadStickerFile", user_id=user_id, png_st...
def upload_sticker_file(self, user_id, png_sticker)
Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. https://core.telegram.org/bots/api#uploadstickerfile Parameters: :param user_id: User iden...
2.860324
2.787112
1.026268
from pytgbot.api_types.receivable.stickers import MaskPosition from pytgbot.api_types.sendable.files import InputFile assert_type_or_raise(user_id, int, parameter_name="user_id") assert_type_or_raise(name, unicode_type, parameter_name="name") a...
def create_new_sticker_set(self, user_id, name, title, png_sticker, emojis, contains_masks=None, mask_position=None)
Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success. https://core.telegram.org/bots/api#createnewstickerset Parameters: :param user_id: User identifier of created sticker set owner :t...
2.146161
1.949575
1.100835
assert_type_or_raise(sticker, unicode_type, parameter_name="sticker") assert_type_or_raise(position, int, parameter_name="position") result = self.do("setStickerPositionInSet", sticker=sticker, position=position) if self.return_python_objects: logge...
def set_sticker_position_in_set(self, sticker, position)
Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success. https://core.telegram.org/bots/api#setstickerpositioninset Parameters: :param sticker: File identifier of the sticker :type sticker: str|unicode ...
4.321121
3.667954
1.178074
from pytgbot.api_types.sendable.inline import InlineQueryResult assert_type_or_raise(inline_query_id, unicode_type, parameter_name="inline_query_id") assert_type_or_raise(results, list, parameter_name="results") assert_type_or_raise(cache_time, None, i...
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None, switch_pm_text=None, switch_pm_parameter=None)
Use this method to send answers to an inline query. On success, True is returned.No more than 50 results per query are allowed. https://core.telegram.org/bots/api#answerinlinequery Parameters: :param inline_query_id: Unique identifier for the answered query :type inl...
2.04787
1.867891
1.096354
from pytgbot.api_types.sendable.payments import ShippingOption assert_type_or_raise(shipping_query_id, unicode_type, parameter_name="shipping_query_id") assert_type_or_raise(ok, bool, parameter_name="ok") assert_type_or_raise(shipping_options, None, li...
def answer_shipping_query(self, shipping_query_id, ok, shipping_options=None, error_message=None)
If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned. https://core.telegram.org/bots/api#answershippingquery ...
2.732312
2.416995
1.130458
assert_type_or_raise(pre_checkout_query_id, unicode_type, parameter_name="pre_checkout_query_id") assert_type_or_raise(ok, bool, parameter_name="ok") assert_type_or_raise(error_message, None, unicode_type, parameter_name="error_message") result = self....
def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=None)
Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the...
3.162977
2.725476
1.160523
from pytgbot.api_types.sendable.passport import PassportElementError assert_type_or_raise(user_id, int, parameter_name="user_id") assert_type_or_raise(errors, list, parameter_name="errors") result = self.do("setPassportDataErrors", user_id=user_id, err...
def set_passport_data_errors(self, user_id, errors)
Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. Use this if the data submitted by t...
4.092308
3.336196
1.226639
from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup assert_type_or_raise(chat_id, int, parameter_name="chat_id") assert_type_or_raise(game_short_name, unicode_type, parameter_name="game_short_name") assert_type_or_raise(disable_not...
def send_game(self, chat_id, game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None)
Use this method to send a game. On success, the sent Message is returned. https://core.telegram.org/bots/api#sendgame Parameters: :param chat_id: Unique identifier for the target chat :type chat_id: int :param game_short_name: Short name of the game,...
1.935295
1.900635
1.018236
assert_type_or_raise(user_id, int, parameter_name="user_id") assert_type_or_raise(chat_id, None, int, parameter_name="chat_id") assert_type_or_raise(message_id, None, int, parameter_name="message_id") assert_type_or_raise(inline_message_id, None, unico...
def get_game_high_scores(self, user_id, chat_id=None, message_id=None, inline_message_id=None)
Use this method to get data for high score tables. Will return the score of the specified user and several of his neighbors in a game. On success, returns an Array of GameHighScore objects. This method will currently return scores for the target user, plus two of his closest neighbors on each side. Will also r...
2.401125
2.298058
1.04485
import requests url, params = self._prepare_request(command, query) r = requests.post(url, params=params, files=files, stream=use_long_polling, verify=True, # No self signed certificates. Telegram should be trustworthy anyway... time...
def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query)
Send a request to the api. If the bot is set to return the json objects, it will look like this: ```json { "ok": bool, "result": {...}, # optionally present: "description": "human-readable description of the result", "error_code": int...
5.787019
6.417216
0.901796
from DictObject import DictObject import requests assert isinstance(r, requests.Response) try: logger.debug(r.json()) res = DictObject.objectify(r.json()) except Exception: logger.exception("Parsing answer failed.\nRequest: {r!s}\nCo...
def _postprocess_request(self, r)
This converts the response to either the response or a parsed :class:`pytgbot.api_types.receivable.Receivable`. :param r: the request response :type r: requests.Response :return: The json response from the server, or, if `self.return_python_objects` is `True`, a parsed return type. :r...
3.961436
3.733773
1.060974
from .api_types.receivable.media import File assert isinstance(file, File) return file.get_download_url(self.api_key)
def get_download_url(self, file)
Creates a url to download the file. Note: Contains the secret API key, so you should not share this url! :param file: The File you want to get the url to download. :type file: pytgbot.api_types.receivable.media.File :return: url :rtype: str
10.329956
4.422898
2.335563
myself = self.get_me() if self.return_python_objects: self._id = myself.id self._username = myself.username else: self._id = myself["result"]["id"] self._username = myself["result"]["username"]
def _load_info(self)
This functions stores the id and the username of the bot. Called by `.username` and `.id` properties. :return:
4.894471
3.544194
1.380983
if full_data: data = self.to_array() data['media'], file = self.get_inputfile_data(self.media, var_name, suffix='_media') return data, file # end if return self.get_inputfile_data(self.media, var_name, suffix='_media')
def get_request_data(self, var_name, full_data=False)
:param var_name: :param full_data: If you want `.to_array()` with this data, ready to be sent. :return: A tuple of `to_array()` dict and the files (:py:func:`InputFile.get_request_files()`). Files can be None, if no file was given, but an url or existing `file_id`. If `...
5.011336
3.303895
1.516796
if not full_data: raise ArithmeticError('we have a thumbnail, please use `full_data=True`.') # end if file = {} data, file_to_add = super(InputMediaWithThumb, self).get_request_data(var_name, full_data=True) if file_to_add: file.update(file_to_add...
def get_request_data(self, var_name, full_data=False)
:param var_name: :param full_data: If you want `.to_array()` with this data, ready to be sent. :return: A tuple of `to_array()` dict and the files (:py:func:`InputFile.get_request_files()`). Files can be None, if no file was given, but an url or existing `file_id`. If ...
4.605335
3.950482
1.165765
from .files import InputFile array = super(InputMediaVideo, self).to_array() # 'type' given by superclass # 'media' given by superclass if self.thumb is not None: if isinstance(self.thumb, InputFile): array['thumb'] = None # type InputFile ...
def to_array(self)
Serializes this InputMediaVideo to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.346583
2.119044
1.107378
array = super(InputMediaAnimation, self).to_array() # 'type' given by superclass # 'media' given by superclass if self.thumb is not None: if isinstance(self.thumb, InputFile): array['thumb'] = None # type InputFile elif isinstance(self.th...
def to_array(self)
Serializes this InputMediaAnimation to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.497829
2.270752
1.100001
array = super(InputMediaAudio, self).to_array() # 'type' given by superclass # 'media' given by superclass if self.thumb is not None: if isinstance(self.thumb, InputFile): array['thumb'] = None # type InputFile elif isinstance(self.thumb,...
def to_array(self)
Serializes this InputMediaAudio to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.30965
2.147435
1.075539
array = super(InputMediaDocument, self).to_array() # 'type' given by superclass # 'media' given by superclass if self.thumb is not None: if isinstance(self.thumb, InputFile): array['thumb'] = None # type InputFile elif isinstance(self.thu...
def to_array(self)
Serializes this InputMediaDocument to a dictionary. :return: dictionary representation of this object. :rtype: dict
3.564964
3.087507
1.154642
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.files import InputFile data = {} # 'type' is given by class type data['media'] = u(array.get('media...
def from_array(array)
Deserialize a new InputMediaDocument from a given dictionary. :return: new InputMediaDocument instance. :rtype: InputMediaDocument
2.802762
2.447481
1.145162
merged = array('i', [0] * len(map2)) for i, shift in enumerate(map2): merged[i] = shift + map1[i + shift] return merged
def _mergemap(map1, map2)
Positions in map2 have an integer indicating the relative shift to the equivalent position in map1. E.g., the i'th position in map2 corresponds to the i + map2[i] position in map1.
4.667645
3.576084
1.305239
if not exists(path): raise REPPError('REPP config file not found: {}'.format(path)) confdir = dirname(path) # TODO: can TDL parsing be repurposed for this variant? conf = io.open(path, encoding='utf-8').read() conf = re.sub(r';.*', '', conf).replace('\n',' '...
def from_config(cls, path, directory=None)
Instantiate a REPP from a PET-style `.set` configuration file. The *path* parameter points to the configuration file. Submodules are loaded from *directory*. If *directory* is not given, it is the directory part of *path*. Args: path (str): the path to the REPP configuratio...
2.851802
2.830025
1.007695
name = basename(path) if name.endswith('.rpp'): name = name[:-4] lines = _repp_lines(path) directory = dirname(path) if directory is None else directory r = cls(name=name, modules=modules, active=active) _parse_repp(lines, r, directory) return...
def from_file(cls, path, directory=None, modules=None, active=None)
Instantiate a REPP from a `.rpp` file. The *path* parameter points to the top-level module. Submodules are loaded from *directory*. If *directory* is not given, it is the directory part of *path*. A REPP module may utilize external submodules, which may be defined in two ways. ...
4.273137
4.041458
1.057326
r = cls(name=name, modules=modules, active=active) _parse_repp(s.splitlines(), r, None) return r
def from_string(cls, s, name=None, modules=None, active=None)
Instantiate a REPP from a string. Args: name (str, optional): the name of the REPP module modules (dict, optional): a mapping from identifiers to REPP modules active (iterable, optional): an iterable of default module activations
6.18864
7.079707
0.874138
if mod in self.active: self.active.remove(mod)
def deactivate(self, mod)
Set external module *mod* to inactive.
4.257676
3.647807
1.167188
if active is None: active = self.active return self.group.apply(s, active=active)
def apply(self, s, active=None)
Apply the REPP's rewrite rules to the input string *s*. Args: s (str): the input string to process active (optional): a collection of external module names that may be applied if called Returns: a :class:`REPPResult` object containing the processed ...
3.742559
6.19467
0.604158
if active is None: active = self.active return self.group.trace(s, active=active, verbose=verbose)
def trace(self, s, active=None, verbose=False)
Rewrite string *s* like `apply()`, but yield each rewrite step. Args: s (str): the input string to process active (optional): a collection of external module names that may be applied if called verbose (bool, optional): if `False`, only output rules or ...
3.066832
6.397186
0.479403
if pattern is None: if self.tokenize_pattern is None: pattern = r'[ \t]+' else: pattern = self.tokenize_pattern if active is None: active = self.active return self.group.tokenize(s, pattern=pattern, active=active)
def tokenize(self, s, pattern=None, active=None)
Rewrite and tokenize the input string *s*. Args: s (str): the input string to process pattern (str, optional): the regular expression pattern on which to split tokens; defaults to `[ \t]+` active (optional): a collection of external module names ...
2.492968
2.665511
0.935268
if self.receiver is None: self.receiver = receiver # end if if self.reply_id is DEFAULT_MESSAGE_ID: self.reply_id = reply_id
def _apply_update_receiver(self, receiver, reply_id)
Updates `self.receiver` and/or `self.reply_id` if they still contain the default value. :param receiver: The receiver `chat_id` to use. Either `self.receiver`, if set, e.g. when instancing `TextMessage(receiver=10001231231, ...)`, or the `chat.id` of the update ...
4.022811
3.27214
1.229413
return sender.send_message( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id text=self.text, chat_id=self.receiver, reply_to_message_id=self.reply_id, parse_mode=self.parse_mode, disable_web_page_preview=self.disable_web_page_p...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.521927
2.708553
0.931098
array = super(TextMessage, self).to_array() array['text'] = u(self.text) # py2: type unicode, py3: type str if self.receiver is not None: if isinstance(self.receiver, None): array['chat_id'] = None(self.receiver) # type Noneelif isinstance(self.receiver, s...
def to_array(self)
Serializes this TextMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.658867
1.638063
1.0127
return sender.send_photo( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id photo=self.photo, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, disable_notification=self....
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.965837
3.059237
0.96947
return sender.send_audio( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id audio=self.audio, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, duration=self.duration, pe...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.566917
2.704495
0.94913
array = super(AudioMessage, self).to_array() if isinstance(self.audio, InputFile): array['audio'] = self.audio.to_array() # type InputFile elif isinstance(self.audio, str): array['audio'] = u(self.audio) # py2: type unicode, py3: type str else: ...
def to_array(self)
Serializes this AudioMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.504337
1.480116
1.016365
return sender.send_document( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id document=self.document, chat_id=self.receiver, reply_to_message_id=self.reply_id, thumb=self.thumb, caption=self.caption, parse_mode=self.parse_mode,...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.910611
3.075571
0.946365
return sender.send_video( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id video=self.video, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, width=self.width, height=self.height, thumb=self.thu...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.522563
2.684248
0.939765
return sender.send_animation( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id animation=self.animation, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, width=self.width, height=self.height, th...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.580864
2.727812
0.94613
array = super(AnimationMessage, self).to_array() if isinstance(self.animation, InputFile): array['animation'] = self.animation.to_array() # type InputFile elif isinstance(self.animation, str): array['animation'] = u(self.animation) # py2: type unicode, py3: typ...
def to_array(self)
Serializes this AnimationMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.52213
1.498485
1.01578
return sender.send_voice( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id voice=self.voice, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, duration=self.duration, di...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.043864
3.279164
0.928244
array = super(VoiceMessage, self).to_array() if isinstance(self.voice, InputFile): array['voice'] = self.voice.to_array() # type InputFile elif isinstance(self.voice, str): array['voice'] = u(self.voice) # py2: type unicode, py3: type str else: ...
def to_array(self)
Serializes this VoiceMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.630363
1.610216
1.012512
return sender.send_video_note( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id video_note=self.video_note, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, length=self.length, thumb=self.thumb,...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.115086
3.323957
0.937162
array = super(VideoNoteMessage, self).to_array() if isinstance(self.video_note, InputFile): array['video_note'] = self.video_note.to_array() # type InputFile elif isinstance(self.video_note, str): array['video_note'] = u(self.video_note) # py2: type unicode, py...
def to_array(self)
Serializes this VideoNoteMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.568257
1.518914
1.032486
return sender.send_media_group( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id media=self.media, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification )
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.496421
3.867356
0.904086
array = super(MediaGroupMessage, self).to_array() if isinstance(self.media, InputMediaPhoto): array['media'] = self._as_array(self.media) # type list of InputMediaPhoto | list of InputMediaVideo elif isinstance(self.media, InputMediaVideo): array['media'] = self...
def to_array(self)
Serializes this MediaGroupMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.388833
2.303066
1.03724
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.input_media import InputMediaPhoto from pytgbot.api_types.sendable.input_media import InputMediaVideo ...
def from_array(array)
Deserialize a new MediaGroupMessage from a given dictionary. :return: new MediaGroupMessage instance. :rtype: MediaGroupMessage
1.856321
1.758023
1.055914
return sender.send_location( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id latitude=self.latitude, longitude=self.longitude, chat_id=self.receiver, reply_to_message_id=self.reply_id, live_period=self.live_period, disable_not...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.181278
3.340485
0.95234
array = super(LocationMessage, self).to_array() array['latitude'] = float(self.latitude) # type float array['longitude'] = float(self.longitude) # type float if self.receiver is not None: if isinstance(self.receiver, None): array['chat_id'] = None(s...
def to_array(self)
Serializes this LocationMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.783563
1.744182
1.022578
return sender.send_venue( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id latitude=self.latitude, longitude=self.longitude, title=self.title, address=self.address, chat_id=self.receiver, reply_to_message_id=self.reply_id, four...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
2.702659
2.792638
0.96778
array = super(VenueMessage, self).to_array() array['latitude'] = float(self.latitude) # type float array['longitude'] = float(self.longitude) # type float array['title'] = u(self.title) # py2: type unicode, py3: type str array['address'] = u(self.address) # py2: typ...
def to_array(self)
Serializes this VenueMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.660543
1.628906
1.019423
return sender.send_contact( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id phone_number=self.phone_number, first_name=self.first_name, chat_id=self.receiver, reply_to_message_id=self.reply_id, last_name=self.last_name, vcard=...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.133752
3.214903
0.974758
array = super(ContactMessage, self).to_array() array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str if self.receiver is not None: if isinstance(self.receiver, N...
def to_array(self)
Serializes this ContactMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.720972
1.696553
1.014393
return sender.send_chat_action( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id action=self.action, chat_id=self.receiver )
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
6.555262
7.151574
0.916618
array = super(ChatActionMessage, self).to_array() array['action'] = u(self.action) # py2: type unicode, py3: type str if self.receiver is not None: if isinstance(self.receiver, None): array['chat_id'] = None(self.receiver) # type Noneelif isinstance(self.r...
def to_array(self)
Serializes this ChatActionMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
3.736141
3.42485
1.090892
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") data = {} data['action'] = u(array.get('action')) if array.get('chat_id') is None: data['receiver'] = None elif isinstan...
def from_array(array)
Deserialize a new ChatActionMessage from a given dictionary. :return: new ChatActionMessage instance. :rtype: ChatActionMessage
2.903899
2.546785
1.140221
return sender.send_sticker( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id sticker=self.sticker, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification, reply_markup=self.repl...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.479856
3.730852
0.932724
array = super(StickerMessage, self).to_array() if isinstance(self.sticker, InputFile): array['sticker'] = self.sticker.to_array() # type InputFile elif isinstance(self.sticker, str): array['sticker'] = u(self.sticker) # py2: type unicode, py3: type str ...
def to_array(self)
Serializes this StickerMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.713621
1.659807
1.032422
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.files import InputFile from pytgbot.api_types.sendable.reply_markup import ForceReply from pytgbot.api_types....
def from_array(array)
Deserialize a new StickerMessage from a given dictionary. :return: new StickerMessage instance. :rtype: StickerMessage
1.546904
1.512368
1.022836
return sender.send_invoice( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id title=self.title, description=self.description, payload=self.payload, provider_token=self.provider_token, start_parameter=self.start_parameter, curren...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
1.660075
1.700356
0.97631
array = super(InvoiceMessage, self).to_array() array['title'] = u(self.title) # py2: type unicode, py3: type str array['description'] = u(self.description) # py2: type unicode, py3: type str array['payload'] = u(self.payload) # py2: type unicode, py3: type str arra...
def to_array(self)
Serializes this InvoiceMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.511785
1.495146
1.011128
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.payments import LabeledPrice from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup ...
def from_array(array)
Deserialize a new InvoiceMessage from a given dictionary. :return: new InvoiceMessage instance. :rtype: InvoiceMessage
1.440165
1.398246
1.02998
return sender.send_game( # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id game_short_name=self.game_short_name, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification, reply_mar...
def send(self, sender: PytgbotApiBot)
Send the message via pytgbot. :param sender: The bot instance to send with. :type sender: pytgbot.bot.Bot :rtype: PytgbotApiMessage
3.477679
3.664513
0.949015
array = super(GameMessage, self).to_array() array['game_short_name'] = u(self.game_short_name) # py2: type unicode, py3: type str if self.receiver is not None: if isinstance(self.receiver, None): array['chat_id'] = None(self.receiver) # type Noneelif isins...
def to_array(self)
Serializes this GameMessage to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.268575
2.251011
1.007803
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup data = {} data['game_short_name'] = u(array.get('game_shor...
def from_array(array)
Deserialize a new GameMessage from a given dictionary. :return: new GameMessage instance. :rtype: GameMessage
2.017756
1.898057
1.063064
def datamatch(nid): ep = xmrs.ep(nid) return ((iv is None or ep.iv == iv) and (pred is None or ep.pred == pred) and (label is None or ep.label == label)) return list(filter(datamatch, xmrs.nodeids()))
def select_nodeids(xmrs, iv=None, label=None, pred=None)
Return the list of matching nodeids in *xmrs*. Nodeids in *xmrs* match if their corresponding :class:`~delphin.mrs.components.ElementaryPredication` object matches its `intrinsic_variable` to *iv*, `label` to *label*, and `pred` to *pred*. The *iv*, *label*, and *pred* filters are ignored if they a...
3.447068
3.649809
0.944452
nodematch = lambda n: ((nodeid is None or n.nodeid == nodeid) and (pred is None or n.pred == pred)) return list(filter(nodematch, nodes(xmrs)))
def select_nodes(xmrs, nodeid=None, pred=None)
Return the list of matching nodes in *xmrs*. DMRS :class:`nodes <delphin.mrs.components.node>` for *xmrs* match if their `nodeid` matches *nodeid* and `pred` matches *pred*. The *nodeid* and *pred* filters are ignored if they are `None`. Args: xmrs (:class:`~delphin.mrs.xmrs.Xmrs`): semantic s...
3.296883
4.022703
0.819569
epmatch = lambda n: ((nodeid is None or n.nodeid == nodeid) and (iv is None or n.iv == iv) and (label is None or n.label == label) and (pred is None or n.pred == pred)) return list(filter(epmatch, xmrs.eps()))
def select_eps(xmrs, nodeid=None, iv=None, label=None, pred=None)
Return the list of matching elementary predications in *xmrs*. :class:`~delphin.mrs.components.ElementaryPredication` objects for *xmrs* match if their `nodeid` matches *nodeid*, `intrinsic_variable` matches *iv*, `label` matches *label*, and `pred` to *pred*. The *nodeid*, *iv*, *label*, and *pred* fi...
2.271007
2.567575
0.884495
argmatch = lambda a: ((nodeid is None or a[0] == nodeid) and (rargname is None or a[1].upper() == rargname.upper()) and (value is None or a[2] == value)) all_args = ( (nid, role, val) for nid in xmrs.nodeids() ...
def select_args(xmrs, nodeid=None, rargname=None, value=None)
Return the list of matching (nodeid, role, value) triples in *xmrs*. Predication arguments in *xmrs* match if the `nodeid` of the :class:`~delphin.mrs.components.ElementaryPredication` they are arguments of match *nodeid*, their role matches *rargname*, and their value matches *value*. The *nodeid*, *r...
2.810562
2.746696
1.023252
linkmatch = lambda l: ( (start is None or l.start == start) and (end is None or l.end == end) and (rargname is None or l.rargname == rargname) and (post is None or l.post == post)) return list(filter(linkmatch, links(xmrs)))
def select_links(xmrs, start=None, end=None, rargname=None, post=None)
Return the list of matching links for *xmrs*. :class:`~delphin.mrs.components.Link` objects for *xmrs* match if their `start` matches *start*, `end` matches *end*, `rargname` matches *rargname*, and `post` matches *post*. The *start*, *end*, *rargname*, and *post* filters are ignored if they are `None`...
2.098516
2.3396
0.896955
hcmatch = lambda hc: ( (hi is None or hc.hi == hi) and (relation is None or hc.relation == relation) and (lo is None or hc.lo == lo)) return list(filter(hcmatch, xmrs.hcons()))
def select_hcons(xmrs, hi=None, relation=None, lo=None)
Return the list of matching HCONS for *xmrs*. :class:`~delphin.mrs.components.HandleConstraint` objects for *xmrs* match if their `hi` matches *hi*, `relation` matches *relation*, and `lo` matches *lo*. The *hi*, *relation*, and *lo* filters are ignored if they are `None`. Args: xmrs (:cla...
2.895469
2.980479
0.971478
icmatch = lambda ic: ( (left is None or ic.left == left) and (relation is None or ic.relation == relation) and (right is None or ic.right == right)) return list(filter(icmatch, xmrs.icons()))
def select_icons(xmrs, left=None, relation=None, right=None)
Return the list of matching ICONS for *xmrs*. :class:`~delphin.mrs.components.IndividualConstraint` objects for *xmrs* match if their `left` matches *left*, `relation` matches *relation*, and `right` matches *right*. The *left*, *relation*, and *right* filters are ignored if they are `None`. Args:...
2.828863
2.869109
0.985972
tgt = xmrs.args(nodeid)[rargname] if tgt in xmrs.variables(): try: return xmrs.nodeid(tgt) except KeyError: pass try: tgt = xmrs.hcon(tgt).lo return next(iter(xmrs.labelset_heads(tgt)), None) except KeyError: pass ...
def find_argument_target(xmrs, nodeid, rargname)
Return the target of an argument (rather than just the variable). Note: If the argument value is an intrinsic variable whose target is an EP that has a quantifier, the non-quantifier EP's nodeid will be returned. With this nodeid, one can then use :meth:`Xmrs.nodeid() <delphin.mrs.x...
4.042448
3.448931
1.172087
preds = list(preds) count = len(preds) # find all lists of nodeids such that the lists have no repeated nids; # keep them as a list (fixme: why not just get sets?) nidsets = set( tuple(sorted(ns)) for ns in filter( lambda ns: len(set(ns)) == count, produc...
def find_subgraphs_by_preds(xmrs, preds, connected=None)
Yield subgraphs matching a list of predicates. Predicates may match multiple EPs/nodes in the *xmrs*, meaning that more than one subgraph is possible. Also, predicates in *preds* match in number, so if a predicate appears twice in *preds*, there will be two matching EPs/nodes in each subgraph. Arg...
5.332167
5.883059
0.90636
ivs = set( ep.intrinsic_variable for ep in xmrs.eps() if not ep.is_quantifier() and ep.intrinsic_variable is not None ) return sorted(ivs, key=var_id)
def intrinsic_variables(xmrs)
Return the list of all intrinsic variables in *xmrs*
5.435201
5.056525
1.074889
bvs = set( ep.intrinsic_variable for ep in xmrs.eps() if ep.is_quantifier() and ep.intrinsic_variable is not None ) return sorted(bvs, key=var_id)
def bound_variables(xmrs)
Return the list of all bound variables in *xmrs*
6.19392
5.845613
1.059584
nodeids = set(nodeids) if label is None: label = xmrs.ep(next(iter(nodeids))).label return nodeids.issubset(xmrs._vars[label]['refs']['LBL'])
def in_labelset(xmrs, nodeids, label=None)
Test if all nodeids share a label. Args: nodeids: iterable of nodeids label (str, optional): the label that all nodeids must share Returns: bool: `True` if all nodeids share a label, otherwise `False`
7.574464
9.635788
0.786076
# file to be uploaded string = 'attach://{name}'.format(name=var_name) return string, self.get_request_files(var_name)
def get_input_media_referenced_files(self, var_name)
Generates a tuple with the value for the json/url argument and a dictionary for the multipart file upload. Will return something which might be similar to `('attach://{var_name}', {var_name: ('foo.png', open('foo.png', 'rb'), 'image/png')})` or in the case of the :class:`InputFileUseFileID` cla...
9.647192
10.85702
0.888567
if create_instance: clazz, args, kwargs = cls.factory( file_id=file_id, path=path, url=url, blob=blob, mime=mime, create_instance=False, ) return clazz(*args, **kwargs) ...
def factory( cls, file_id=None, path=None, url=None, blob=None, mime=None, prefer_local_download=True, prefer_str=False, create_instance=True )
Creates a new InputFile subclass instance fitting the given parameters. :param prefer_local_download: If `True`, we download the file and send it to telegram. This is the default. If `False`, we send Telegram just the URL, and they'll try to download it. :type pre...
3.078896
2.713259
1.134759
array = super(PassportData, self).to_array() array['data'] = self._as_array(self.data) # type list of EncryptedPassportElement array['credentials'] = self.credentials.to_array() # type EncryptedCredentials return array
def to_array(self)
Serializes this PassportData to a dictionary. :return: dictionary representation of this object. :rtype: dict
5.165143
4.370925
1.181705
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") data = {} data['data'] = EncryptedPassportElement.from_array_list(array.get('data'), list_level=1) data['credentials'] = EncryptedCredentia...
def from_array(array)
Deserialize a new PassportData from a given dictionary. :return: new PassportData instance. :rtype: PassportData
3.971239
3.227184
1.230559
array = super(PassportFile, self).to_array() array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str array['file_size'] = int(self.file_size) # type int array['file_date'] = int(self.file_date) # type int return array
def to_array(self)
Serializes this PassportFile to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.585634
2.358651
1.096234
array = super(EncryptedPassportElement, self).to_array() array['type'] = u(self.type) # py2: type unicode, py3: type str array['hash'] = u(self.hash) # py2: type unicode, py3: type str if self.data is not None: array['data'] = u(self.data) # py2: type unicode, p...
def to_array(self)
Serializes this EncryptedPassportElement to a dictionary. :return: dictionary representation of this object. :rtype: dict
1.522291
1.515677
1.004364
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") data = {} data['type'] = u(array.get('type')) data['hash'] = u(array.get('hash')) data['data'] = u(array.get('data')) if array.get(...
def from_array(array)
Deserialize a new EncryptedPassportElement from a given dictionary. :return: new EncryptedPassportElement instance. :rtype: EncryptedPassportElement
1.736038
1.547495
1.121838
array = super(EncryptedCredentials, self).to_array() array['data'] = u(self.data) # py2: type unicode, py3: type str array['hash'] = u(self.hash) # py2: type unicode, py3: type str array['secret'] = u(self.secret) # py2: type unicode, py3: type str return array
def to_array(self)
Serializes this EncryptedCredentials to a dictionary. :return: dictionary representation of this object. :rtype: dict
2.746619
2.262532
1.213958
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") data = {} data['data'] = u(array.get('data')) data['hash'] = u(array.get('hash')) data['secret'] = u(array.get('secret')) da...
def from_array(array)
Deserialize a new EncryptedCredentials from a given dictionary. :return: new EncryptedCredentials instance. :rtype: EncryptedCredentials
3.703406
2.988552
1.239197
result = self.do("getMe") if self.return_python_objects: logger.debug("Trying to parse {data}".format(data=repr(result))) from pytgbot.api_types.receivable.peer import User try: return User.from_array(result) except TgApiParseExcep...
def get_me(self)
A simple method for testing your bot's auth token. Requires no parameters. Returns basic information about the bot in form of a :class:`pytgbot.api_types.receivable.peer.User` object. https://core.telegram.org/bots/api#getme Returns: :return: Returns basic information about the bot i...
4.904485
4.064276
1.20673
assert_type_or_raise(chat_id, (int, unicode_type), parameter_name="chat_id") assert_type_or_raise(from_chat_id, (int, unicode_type), parameter_name="from_chat_id") assert_type_or_raise(message_id, int, parameter_name="message_id") assert_type_or_raise(disable_notification, No...
def forward_message(self, chat_id, from_chat_id, message_id, disable_notification=False)
Use this method to forward messages of any kind. On success, the sent Message is returned. https://core.telegram.org/bots/api#forwardmessage Parameters: :param chat_id: Unique identifier for the target chat (chat id of user chat or group chat) or username of the target...
2.279421
2.172832
1.049055
assert_type_or_raise(chat_id, (int, unicode_type), parameter_name="chat_id") from .api_types.sendable.input_media import InputMediaPhoto, InputMediaVideo files = {} new_media = [] assert_type_or_raise(media, list, parameter_name="media") for i, medium in enumera...
def send_media_group(self, chat_id, media, disable_notification=None, reply_to_message_id=None)
Use this method to send a group of photos or videos as an album. On success, an array of the sent Messages is returned. https://core.telegram.org/bots/api#sendmediagroup Parameters: :param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channe...
3.043208
2.967787
1.025413
assert_type_or_raise(user_id, int, parameter_name="user_id") assert_type_or_raise(score, int, parameter_name="score") assert_type_or_raise(force, None, bool, parameter_name="force") assert_type_or_raise(disable_edit_message, None, bool, parameter_name="disable_edit_message") ...
def set_game_score(self, user_id, score, force=False, disable_edit_message=False, chat_id=None, message_id=None, inline_message_id=None)
Use this method to set the score of the specified user in a game. On success, if the message was sent by the bot, returns the edited Message, otherwise returns True. Returns an error, if the new score is not greater than the user's current score in the chat and force is False. https://core.tele...
1.940017
1.801504
1.076888
from DictObject import DictObject import requests assert isinstance(r, requests.Response) try: logger.debug(r.json()) res = DictObject.objectify(r.json()) except Exception as e: raise TgApiResponseException('Parsing answer as json fa...
def _postprocess_request(self, r)
This converts the response to either the response or a parsed :class:`pytgbot.api_types.receivable.Receivable`. :param r: the request response :type r: requests.Response :return: The json response from the server, or, if `self.return_python_objects` is `True`, a parsed return type. :r...
5.353155
4.775428
1.120979
from .api_types.sendable.files import InputFile from luckydonaldUtils.encoding import unicode_type from luckydonaldUtils.encoding import to_native as n if value is None and _file_is_optional: # Is None but set optional, so do nothing. pass elif i...
def _do_fileupload(self, file_param_name, value, _command=None, _file_is_optional=False, **kwargs)
:param file_param_name: For what field the file should be uploaded. :type file_param_name: str :param value: File to send. You can either pass a file_id as String to resend a file file that is already on the Telegram servers, or upload a new file, specifying...
3.533526
3.097246
1.14086
array = super(LabeledPrice, self).to_array() array['label'] = u(self.label) # py2: type unicode, py3: type str array['amount'] = int(self.amount) # type int return array
def to_array(self)
Serializes this LabeledPrice to a dictionary. :return: dictionary representation of this object. :rtype: dict
5.902792
3.787541
1.558476
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") data = {} data['label'] = u(array.get('label')) data['amount'] = int(array.get('amount')) instance = LabeledPrice(**data) ...
def from_array(array)
Deserialize a new LabeledPrice from a given dictionary. :return: new LabeledPrice instance. :rtype: LabeledPrice
4.03774
3.101956
1.301675
array = super(ShippingOption, self).to_array() array['id'] = u(self.id) # py2: type unicode, py3: type str array['title'] = u(self.title) # py2: type unicode, py3: type str array['prices'] = self._as_array(self.prices) # type list of LabeledPrice return array
def to_array(self)
Serializes this ShippingOption to a dictionary. :return: dictionary representation of this object. :rtype: dict
3.530576
3.183109
1.109159
if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.sendable.payments import LabeledPrice data = {} data['id'] = u(array.get('id')) data['title'] = u(ar...
def from_array(array)
Deserialize a new ShippingOption from a given dictionary. :return: new ShippingOption instance. :rtype: ShippingOption
3.418355
3.051906
1.120072