Skip to content

Commit

Permalink
Add war dec
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Sep 17, 2023
1 parent 66f53e1 commit 8bc85cb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
22 changes: 22 additions & 0 deletions pinger/migrations/0016_add_more_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Aaron on 2022-01-03

from django.db import migrations


def add_ping_types(apps, schema_editor):
PingType = apps.get_model('pinger', 'PingType')

# StructureUnderAttack
PingType.objects.create(name="Wars: War Declared",
class_tag="WarDeclared")


class Migration(migrations.Migration):

dependencies = [
('pinger', '0015_add_more_types'),
]

operations = [
migrations.RunPython(add_ping_types)
]
44 changes: 44 additions & 0 deletions pinger/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -1937,3 +1937,47 @@ def build_ping(self):
self._corp = self._notification.character.character.corporation_id
self._alli = self._notification.character.character.alliance_id
self._region = system_db.constellation.region.region_id


# WAR stuffs

class WarDeclared(NotificationPing):
category = "wars" # Structure Alerts

"""
WarDeclared
againstID: 99011747
cost: 100000000
declaredByID: 1900696668
delayHours: 24
hostileState: false
timeStarted: 133394547000000000
warHQ: <b>Keba - The High Sec Initative.</b>
warHQ_IdType:
- 1042059347183
- 35833
"""

def build_ping(self):
title = "War Declared"
declared_by_name, _ = ctm.EveName.objects.get_or_create_from_esi(
self._data['declaredByID'])
against_by_name, _ = ctm.EveName.objects.get_or_create_from_esi(
self._data['againstID'])
body = f"War against `{against_by_name}` declared by `{declared_by_name}`\nWar HQ `{strip_tags(self._data['warHQ'])}`\nFighting can commence in {self._data['delayHours']} hours"

corp_id = self._notification.character.character.corporation_id
corp_ticker = self._notification.character.character.corporation_ticker
footer = {"icon_url": "https://imageserver.eveonline.com/Corporation/%s_64.png" % (str(corp_id)),
"text": "%s (%s)" % (self._notification.character.character.corporation_name, corp_ticker)}

self.package_ping(title,
body,
self._notification.timestamp,
footer=footer,
colour=15158332)

self._corp = self._notification.character.character.corporation_id
self._alli = self._notification.character.character.alliance_id
self.force_at_ping = False
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ envlist = py3
setenv =
DJANGO_SETTINGS_MODULE = tests.test_settings

basepython =
py3: python3

deps=
py3: coverage
coverage

install_command = pip install -e ".[testing]" -U {opts} {packages}
commands =
pip install -r requirements.txt
pip freeze
coverage run runtests.py
coverage report -m
Expand Down

0 comments on commit 8bc85cb

Please sign in to comment.