TransactionPartnerTelegramAds

class telegram.TransactionPartnerTelegramAds(*, api_kwargs=None)[source]

Bases: telegram.TransactionPartner

Describes a withdrawal transaction to the Telegram Ads platform.

Added in version 21.4.

type[source]

The type of the transaction partner, always 'telegram_ads'.

Type:

str

__deepcopy__(memodict)[source]

Customizes how copy.deepcopy() processes objects of this type. The only difference to the default implementation is that the telegram.Bot instance set via set_bot() (if any) is not copied, but shared between the original and the copy, i.e.:

assert telegram_object.get_bot() is copy.deepcopy(telegram_object).get_bot()
Parameters:

memodict (dict) – A dictionary that maps objects to their copies.

Returns:

The copied object.

Return type:

telegram.TelegramObject

__delattr__(key)[source]

Overrides object.__delattr__() to prevent the deletion of attributes.

Raises:

AttributeError

__dir__()[source]

Default dir() implementation.

__eq__(other)[source]

Compares this object with other in terms of equality. If this object and other are not objects of the same class, this comparison will fall back to Python’s default implementation of object.__eq__(). Otherwise, both objects may be compared in terms of equality, if the corresponding subclass of TelegramObject has defined a set of attributes to compare and the objects are considered to be equal, if all of these attributes are equal. If the subclass has not defined a set of attributes to compare, a warning will be issued.

Tip

If instances of a class in the telegram module are comparable in terms of equality, the documentation of the class will state the attributes that will be used for this comparison.

Parameters:

other (object) – The object to compare with.

Returns:

bool

__format__(format_spec, /)[source]

Default object formatter.

Return str(self) if format_spec is empty. Raise TypeError otherwise.

__ge__(value, /)[source]

Return self>=value.

__getattribute__(name, /)[source]

Return getattr(self, name).

__getitem__(item)[source]

Objects of this type are subscriptable with strings, where telegram_object["attribute_name"] is equivalent to telegram_object.attribute_name.

Tip

This is useful for dynamic attribute lookup, i.e. telegram_object[arg] where the value of arg is determined at runtime. In all other cases, it’s recommended to use the dot notation instead, i.e. telegram_object.attribute_name.

Changed in version 20.0: telegram_object['from'] will look up the key from_user. This is to account for special cases like Message.from_user that deviate from the official Bot API.

Parameters:

item (str) – The name of the attribute to look up.

Returns:

object

Raises:

KeyError – If the object does not have an attribute with the appropriate name.

__getstate__()[source]

Overrides object.__getstate__() to customize the pickling process of objects of this type. The returned state does not contain the telegram.Bot instance set with set_bot() (if any), as it can’t be pickled.

Returns:

The state of the object.

Return type:

state (dict[str, object])

__gt__(value, /)[source]

Return self>value.

__hash__()[source]

Builds a hash value for this object such that the hash of two objects is equal if and only if the objects are equal in terms of __eq__().

Returns:

int

classmethod __init_subclass__()[source]

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)[source]

Return self<=value.

__lt__(value, /)[source]

Return self<value.

__ne__(value, /)[source]

Return self!=value.

classmethod __new__(*args, **kwargs)[source]
__reduce__()[source]

Helper for pickle.

__reduce_ex__(protocol, /)[source]

Helper for pickle.

__repr__()[source]

Gives a string representation of this object in the form ClassName(attr_1=value_1, attr_2=value_2, ...), where attributes are omitted if they have the value None or are empty instances of collections.abc.Sized (e.g. list, dict, set, str, etc.).

As this class doesn’t implement object.__str__(), the default implementation will be used, which is equivalent to __repr__().

Returns:

str

__setattr__(key, value)[source]

Overrides object.__setattr__() to prevent the overriding of attributes.

Raises:

AttributeError

__setstate__(state)[source]

Overrides object.__setstate__() to customize the unpickling process of objects of this type. Modifies the object in-place.

If any data was stored in the api_kwargs of the pickled object, this method checks if the class now has dedicated attributes for those keys and moves the values from api_kwargs to the dedicated attributes. This can happen, if serialized data is loaded with a new version of this library, where the new version was updated to account for updates of the Telegram Bot API.

If on the contrary an attribute was removed from the class, the value is not discarded but made available via api_kwargs.

Parameters:

state (dict) – The data to set as attributes of this object.

__sizeof__()[source]

Size of object in memory, in bytes.

__str__()[source]

Return str(self).

classmethod __subclasshook__(object, /)[source]

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

classmethod de_list(data, bot=None)[source]

Converts a list of JSON objects to a tuple of Telegram objects.

Changed in version 20.0:

  • Returns a tuple instead of a list.

  • Filters out any None values.

Parameters:
  • data (list[dict[str, …]]) – The JSON data.

  • bot (telegram.Bot, optional) –

    The bot associated with these object. Defaults to None, in which case shortcut methods will not be available.

    Changed in version 21.4: bot is now optional and defaults to None

Returns:

A tuple of Telegram objects.

get_bot()[source]

Returns the telegram.Bot instance associated with this object.

See also

set_bot()

Raises:

RuntimeError – If no telegram.Bot instance was set for this object.

set_bot(bot)[source]

Sets the telegram.Bot instance associated with this object.

See also

get_bot()

Parameters:

bot (telegram.Bot | None) – The bot instance.

to_dict(recursive=True)[source]

Gives representation of object as dict.

Changed in version 20.0:

  • Now includes all entries of api_kwargs.

  • Attributes whose values are empty sequences are no longer included.

Parameters:

recursive (bool, optional) –

If True, will convert any TelegramObjects (if found) in the attributes to a dictionary. Else, preserves it as an object itself. Defaults to True.

Added in version 20.0.

Returns:

dict

to_json()[source]

Gives a JSON representation of object.

Changed in version 20.0: Now includes all entries of api_kwargs.

Returns:

str