talkomatic.py 0.1.2
An easy-to-use Python versatile wrapper for the Talkomatic Bot interface ensuring best practices for making bots, and handling the REST API.
 
Loading...
Searching...
No Matches
offensive_words.py
Go to the documentation of this file.
1from requests import get as requests_get
2
3from dataclasses import dataclass
4
5
6@dataclass
8 """
9 A class representing the list of blacklisted words and whitelisted words.
10
11 Contains:
12 - offensive_words (list[str]): A list of all the blacklisted strings.
13 - whitelisted_words (list[str]): A list of all the strings allowed overriding the blacklisted strings.
14 """
15
16 offensive_words: list[str]
17 whitelisted_words: list[str]
18
19 @classmethod
20 def get(cls) -> "WordFilter":
21 response = requests_get("https://classic.talkomatic.co/js/offensive_words.json")
22 if response.status_code != 200: raise RuntimeError("Unable to get offensive_words.json.")
23 data = response.json()
24
25 return cls(
26 offensive_words = data["offensive_words"],
27 whitelisted_words = data["whitelisted_words"],
28 )
29
30__all__ = ["WordFilter"]