Skip to content

Commit

Permalink
Better state handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebag333 committed Oct 25, 2016
1 parent 4366599 commit 864b4ce
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions bot/messenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,18 @@ def write_fit(self, channel_id, msgtext):
itemid = False

try:
state = str(msg_chunks[4])
state_chunk = str(msg_chunks[4])

if state_chunk == "active":
state_condition = State.active
elif state_chunk == "online":
state_condition = State.online
elif state_chunk == "overload":
state_condition = State.overload
else:
state_condition = State.offline
except:
state = False
state_condition = State.offline

try:
ammo = str(msg_chunks[5])
Expand All @@ -134,15 +143,15 @@ def write_fit(self, channel_id, msgtext):
self.fit.validate()
answer = "Added ship: " + str(itemid)
elif command == "addhigh" and not answer:
self.fit.modules.high.equip(ModuleHigh(itemid, state=state, charge=Charge(ammo)))
self.fit.modules.high.equip(ModuleHigh(itemid, state=state_condition, charge=Charge(ammo)))
self.fit.validate()
answer = "Added high slot: " + str(itemid)
elif command == "addmid" and not answer:
self.fit.modules.med.equip(ModuleMed(itemid, state=state))
self.fit.modules.med.equip(ModuleMed(itemid, state=state_condition))
self.fit.validate()
answer = "Added mid slot: " + str(itemid)
elif command == "addlow" and not answer:
self.fit.modules.low.equip(ModuleLow(itemid, state=state))
self.fit.modules.low.equip(ModuleLow(itemid, state=state_condition))
self.fit.validate()
answer = "Added mid slot: " + str(itemid)
elif command == "addrig" and not answer:
Expand Down

0 comments on commit 864b4ce

Please sign in to comment.