This repository was archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.py
More file actions
49 lines (38 loc) · 1.22 KB
/
comment.py
File metadata and controls
49 lines (38 loc) · 1.22 KB
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
49
from abc import abstractmethod, ABC
# Moderator comment constants.
SIGNATURE = "\n*I am a bot, " \
"and this action was performed automatically at the request of my senpai, " \
"[LZ58840](https://www.reddit.com/user/LZ58840/).* "
class Comment:
def __init__(self):
self.body = ""
@abstractmethod
def add(self, *args):
pass
@abstractmethod
def update(self, *args):
pass
def is_empty(self):
self.update()
return self.body == ""
def to_string(self):
self.update()
return self.body
class RemovalComment(Comment, ABC):
def __init__(self):
super().__init__()
self.violations = {}
def add(self, rule, comment):
if rule in self.violations:
self.violations[rule] += ", " + comment
else:
self.violations[rule] = comment
def update(self):
self.body = ""
if len(self.violations) > 0:
self.body = "removed, "
for rule in self.violations.keys():
self.body += "rule " + str(rule) + ": "
self.body += self.violations[rule]
self.body += ".\n\n; "
self.body = self.body.rstrip("; ")