1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
from enum import StrEnum
class GraphicType(StrEnum):
STICKER = "STICKER"
ANIMATION = "ANIMATION"
VIDEO = "VIDEO"
class Response(StrEnum):
TEXT = "TEXT"
GRAPHIC = "GRAPHIC"
class ChatData:
def __init__(
self,
id: str,
chat_type: str,
name: str,
processed_messages: int = 0,
message_period: int = 10,
answer_chance: float = 0.5,
restricted: bool = False,
silenced: bool = False,
) -> None:
self.id = id
self.type = chat_type
self.name = name
self.processed_messages = processed_messages
self.message_period = message_period
self.answer_chance = answer_chance
self.restricted = restricted
self.silenced = silenced
@staticmethod
def from_sql_row(row: tuple[str, str, str, int, int, float, int, int]):
print("From SQL row:", repr(row))
return ChatData(
row[0],
row[1],
row[2],
int(row[3]),
int(row[4]),
float(row[5]),
int(row[6]) == 1,
int(row[7]) == 1,
)
|