Clan functionalities¶
-
class
clans.
Clan
(name, set_exp=False, set_dict=True)¶ Class with attributes of a Runescape Clan using Jagex’s RS3 API
Most of Runescape 3’s API can be accessed at: http://runescape.wikia.com/wiki/Application_programming_interface
…
Parameters: - name : str
The name of the clan. Does not need to be case-sensitive.
- set_exp : bool, optional
If True, set.exp will be set with the total Exp from the clan. False by default.
- set_dict : bool, optional
If True, self.member will be set with info from all members from the clan in dict format. True by default.
Raises: - ClanNotFoundError
If an invalid clan name is passed when creating object Clan.
Attributes: - name : str
The name of the clan. Set when creating object.
- exp : int or None
The total Exp of the clan, or None if argument set_exp is False (False by default).
- member : dict or None
- All info from members in the clan in dictionary format as below::
>>> member_info = { ... 'player_1': { ... 'exp': 225231234, ... 'rank': 'Leader' ... }, ... 'player_2': { ... 'exp': 293123082, ... 'rank': 'Overseer' ... }, ... }
or None if argument set_dict is False (True by default).
- count : int
The number of members in the Clan.
- avg_exp : int or None
The average clan exp per member in the Clan, or None if either set_exp or set_dict arguments are False.
Methods
dict_lookup
([rank_key, exp_key])Used for getting all information available from a clan using Rs3’s Clan API. list_lookup
()Used for getting all information available from a clan using Rs3’s Clan API. -
dict_lookup
(rank_key='rank', exp_key='exp')¶ Used for getting all information available from a clan using Rs3’s Clan API.
Contrary to list_lookup it returns it as a Dictionary format instead. The dict format makes easier to find info specific to certain members of the Clan instead of looping over it.
Parameters: - rank_key : str
The key for Clan Rank to be used in the returned dictionary with all members info of clan.
- exp_key : str
The key for Clan Exp to be used in the returned dictionary with all members info of clan.
Returns: - dict
Information from all members in the clan in dictionary format for ease of access.
-
list_lookup
()¶ Used for getting all information available from a clan using Rs3’s Clan API. Mainly used for calculating the total exp of a clan manually.
Returns: - list
- All players information from a clan in list format like so::
>>> clan_list = [ ... ['Clanmate', ' Clan Rank', ' Total XP', ' Kills'], ... ['Pedim', 'Owner', '739711654', '2'], ... ['Tusoroxo', 'Deputy Owner', '1132958333', '0'], ... ]
-
exception
clans.
ClanNotFoundError
(value)¶ Error exception to be called when a clan is not found when trying to read the clan’s URL using Rs3’s Official API.
- Correct error handling when reading a clan::
>>> import rs3clans >>> try: ... clan_name = "oasdiuahsiubasiufbasuf" ... clan = rs3clans.Clan(name=clan_name) ... except rs3clans.ClanNotFoundError: ... print("Exception encountered!") Exception encountered!