Skip to Content
ReferencePythonopentele2.devices

opentele2.devices

The device classes. Every device is picked by the core from a weighted catalog; RandomDevice(unique_id) returns the same device for the same unique_id (a str as given, anything else as its str()) and a random device without one.

from opentele2.devices import AndroidDevice, IOSDevice, WebBrowserDevice, WindowsDevice

DeviceInfo

opentele2/devices.py
class DeviceInfo: def __init__(self, model: str, version: str) -> None: ... model: str version: str

A device model and system version; str() is "<model> <version>".

Device classes

opentele2/devices.py
class SystemInfo: deviceList: list[DeviceInfo] device_models: list[str] system_versions: list[str] @classmethod def RandomDevice(cls, unique_id: str | None = None) -> DeviceInfo: ... class GeneralDesktopDevice(SystemInfo): ... class WindowsDevice(GeneralDesktopDevice): ... class LinuxDevice(GeneralDesktopDevice): ... class macOSDevice(GeneralDesktopDevice): @classmethod def RandomDevice(cls, unique_id: str | None = None, variant: str = "tdesktop") -> DeviceInfo: ... class AndroidDevice(SystemInfo): ... class IOSDevice(SystemInfo): ... iOSDevice = IOSDevice class WebBrowserDevice(SystemInfo): BROWSER_WEIGHTS: dict[str, int] @classmethod def RandomDevice(cls, unique_id: str | None = None, variant: str = "z") -> DeviceInfo: ...
ClassRandomDevice gives
WindowsDeviceA Telegram Desktop Windows device: Windows 11 or Windows 10, with x64 on AMD64.
LinuxDeviceA Telegram Desktop Linux device: Linux, the desktop environment, the display server and glibc <version>.
macOSDeviceA Mac; variant="tdesktop" formats the version as Telegram Desktop does (macOS 26.7.1), variant="swift" keeps the bare 26.7.1 of Telegram for macOS. Both pick the same Mac for the same unique_id.
AndroidDeviceA Telegram Android device: manufacturer and model as one string, SDK <level>.
IOSDeviceA marketing name such as iPhone 15 Pro and an iOS version such as 17.4.1.
WebBrowserDeviceA browser user agent with the OS name (variant="z", Web A) or the navigator.platform string (variant="k", Web K and Webogram).
SystemInfoRaises NotImplementedError.

Catalog attributes

AttributeDescription
deviceListEvery catalog pair as a DeviceInfo, repeated by its weight, in catalog order.
device_modelsThe catalog’s models in file order (desktop, Mac and iOS classes; empty for Android).
system_versionsThe catalog’s system versions in file order (desktop, Mac and iOS classes). Mac versions are bare.
WebBrowserDevice.BROWSER_WEIGHTSThe browser weights of the web pool: chrome 19, edge 2, firefox 1.

The attributes are read only: each read returns a new list or dict, so editing one changes nothing RandomDevice picks. The web devices are drawn with opentele2-browser and are deterministic per unique_id and per Chrome and Firefox major.

devices.py
from opentele2.devices import AndroidDevice, macOSDevice print(AndroidDevice.RandomDevice("account-42")) print(macOSDevice.RandomDevice("account-42", variant="swift")) print(len(AndroidDevice.deviceList))
Last updated on