Skip to content
This repository has been archived by the owner on May 29, 2023. It is now read-only.

Commit

Permalink
Added support for ignoring specific factions via configuration; confi…
Browse files Browse the repository at this point in the history
…gured to ignore Pilots Federation Local Branch
  • Loading branch information
marcosparks committed Sep 28, 2017
1 parent 7387866 commit 425b75d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gurgle.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ distance: 50

[events]
today_only: yes
# Defines the decimal places in distance, -1 means don't truncate
#distancedp: -1
# Comma-separated list of factions to ignore
ignore_factions: Pilots Federation Local Branch

[logging]
directory: logs
Expand Down
10 changes: 10 additions & 0 deletions module/influence.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
# Determine if only looking for events today
_TODAY_ONLY = Config.getBoolean('events', 'today_only', True)
_ROUND_DISTANCE = Config.getInteger('events', 'distancedp', -1)
# Allow specific factions to be ignored
_IGNORE_FACTION_SET = set()
_IGNORE_FACTIONS = Config.getString('events', 'ignore_factions')
if _IGNORE_FACTIONS is not None and len(_IGNORE_FACTIONS.strip()) > 0:
_IGNORE_FACTION_SET.update([faction.strip() for faction in _IGNORE_FACTIONS.split(",")])

# Interested in activity around a specified location
_LOCATION_X = Config.getFloat('location', 'x')
Expand Down Expand Up @@ -65,6 +70,8 @@ def ConsumeFSDJump(event):
# Only want to update if we have factions to report on...
if len(factionList) == 0:
_LOGGER.debug("Event for %s (%.1fly) discarded since no factions present.", starName, distance)
elif set([x["Name"] for x in factionList]).issubset(_IGNORE_FACTION_SET):
_LOGGER.debug("Event for %s (%.1fly) discarded since no interesting factions present.", starName, distance)
else: # len(factionList) > 0
_LOGGER.debug("Processing update for %s (%.1fly) from %s", starName, distance, timestamp)
# Create the update
Expand Down Expand Up @@ -99,6 +106,9 @@ def CreateUpdate(timestamp, starName, systemFaction, factionList):
data["SystemEconomy"] = ""
factionNo = 1
for faction in factionList:
# Not interested in these factions
if faction["Name"] in _IGNORE_FACTION_SET:
continue
prefix = "Faction{:d}".format(factionNo)
data[prefix+"Name"] = faction["Name"]
data[prefix+"Influence"] = faction["Influence"]
Expand Down

0 comments on commit 425b75d

Please sign in to comment.