Skip to content

Commit f78d749

Browse files
Sebastian Wagnerwaldbauer-certat
authored andcommitted
BUG: lib/bot: Collector bot: fix accuracy default value
and refactor __add_report_fields a bit
1 parent fd2f6d4 commit f78d749

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

intelmq/lib/bot.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ class CollectorBot(Bot):
11741174

11751175
__is_multithreadable: bool = False
11761176
name: Optional[str] = None
1177-
accuracy: Optional[str] = None
1177+
accuracy: Optional[str] = 100
11781178
code: Optional[str] = None
11791179
provider: Optional[str] = None
11801180
documentation: Optional[str] = None
@@ -1196,15 +1196,25 @@ def __filter_empty_report(self, message: libmessage.Report):
11961196
return True
11971197

11981198
def __add_report_fields(self, report: libmessage.Report):
1199-
if hasattr(self, 'name'):
1199+
"""
1200+
Adds the configured feed parameters to the report, of they are set (!= None).
1201+
The following parameters are set to these report fields:
1202+
* name -> feed.name
1203+
* code -> feed.code
1204+
* documentation -> feed.documentation
1205+
* provider -> feed.provider
1206+
* accuracy -> feed.accuracy
1207+
"""
1208+
if self.name:
12001209
report.add("feed.name", self.name)
1201-
if hasattr(self, 'code'):
1210+
if self.code:
12021211
report.add("feed.code", self.code)
1203-
if hasattr(self, 'documentation'):
1212+
if self.documentation:
12041213
report.add("feed.documentation", self.documentation)
1205-
if hasattr(self, 'provider'):
1214+
if self.provider:
12061215
report.add("feed.provider", self.provider)
1207-
report.add("feed.accuracy", self.accuracy)
1216+
if self.accuracy:
1217+
report.add("feed.accuracy", self.accuracy)
12081218
return report
12091219

12101220
def send_message(self, *messages, path: str = "_default", auto_add: bool = True):

0 commit comments

Comments
 (0)