Module slack_sdk.web.internal_utils
Functions
def convert_bool_to_0_or_1(params: Dict[str, Any] | None) ‑> Dict[str, Any] | None
-
Expand source code
def convert_bool_to_0_or_1(params: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]: """Converts all bool values in dict to "0" or "1". Slack APIs safely accept "0"/"1" as boolean values. Using True/False (bool in Python) doesn't work with aiohttp. This method converts only the bool values in top-level of a given dict. Args: params: params as a dict Returns: Modified dict """ if params: return {k: _to_0_or_1_if_bool(v) for k, v in params.items()} return None
Converts all bool values in dict to "0" or "1".
Slack APIs safely accept "0"/"1" as boolean values. Using True/False (bool in Python) doesn't work with aiohttp. This method converts only the bool values in top-level of a given dict.
Args
params
- params as a dict
Returns
Modified dict
def get_user_agent(prefix: str | None = None, suffix: str | None = None)
-
Expand source code
def get_user_agent(prefix: Optional[str] = None, suffix: Optional[str] = None): """Construct the user-agent header with the package info, Python version and OS version. Returns: The user agent string. e.g. 'Python/3.6.7 slackclient/2.0.0 Darwin/17.7.0' """ # __name__ returns all classes, we only want the client client = "{0}/{1}".format("slackclient", version.__version__) python_version = "Python/{v.major}.{v.minor}.{v.micro}".format(v=sys.version_info) system_info = "{0}/{1}".format(platform.system(), platform.release()) user_agent_string = " ".join([python_version, client, system_info]) prefix = f"{prefix} " if prefix else "" suffix = f" {suffix}" if suffix else "" return prefix + user_agent_string + suffix
Construct the user-agent header with the package info, Python version and OS version.
Returns
The user agent string. e.g. 'Python/3.6.7 slackclient/2.0.0 Darwin/17.7.0'