worthless-launcher/worthless/classes/launcher/banner.py
tretrauit a7ddd0c49a
Object-oriented programming
All launcher functions are now return an object instead of a dict
2022-01-29 23:25:03 +07:00

30 lines
1.0 KiB
Python

class Banner:
"""Contains a launcher banner information
Note that the banner name is in chinese, so you may not find this variable useful.
Also, the banner has a variable called `order`, you can use that to sort the banner
like the official launcher does.
Attributes:
- :class:`str` banner_id: The launcher banner id.
- :class:`str` name: The banner name.
- :class:`str` img: The banner image url.
- :class:`str` url: The banner target url.
- :class:`str` order: The banner order.
- :class:`str` name: The banner name.
- :class:`dict` raw: The banner raw information.
"""
def __init__(self, banner_id, name, img, url, order, raw):
self.banner_id = banner_id
self.name = name
self.img = img
self.url = url
self.order = order
self.raw = raw
@staticmethod
def from_dict(data) -> 'Banner':
"""Creates a launcher banner from a dictionary."""
return Banner(data["banner_id"], data["name"], data["img"], data["url"], data["order"], data)