Skip to content

Commit

Permalink
Log Transfers
Browse files Browse the repository at this point in the history
missing from #4285
  • Loading branch information
BreezeRo authored Aug 20, 2016
1 parent d734567 commit c5c120a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pokemongo_bot/cell_workers/transfer_pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
from pokemongo_bot.human_behaviour import action_delay
from pokemongo_bot.base_task import BaseTask
from pokemongo_bot.inventory import Pokemons, Pokemon, Attack
from pokemongo_bot.datastore import Datastore
from operator import attrgetter

class TransferPokemon(BaseTask):
class TransferPokemon(Datastore, BaseTask):
SUPPORTED_TASK_API_VERSION = 1

def __init__(self, bot, config):
super(TransferPokemon, self).__init__(bot, config)
def initialize(self):
self.transfer_wait_min = self.config.get('transfer_wait_min', 1)
self.transfer_wait_max = self.config.get('transfer_wait_max', 4)
Expand Down Expand Up @@ -177,6 +180,24 @@ def release_pokemon(self, pokemon):
'dps': pokemon.moveset.dps
}
)
with self.bot.database as conn:
c = conn.cursor()
c.execute("SELECT COUNT(name) FROM sqlite_master WHERE type='table' AND name='transfer_log'")

result = c.fetchone()

while True:
if result[0] == 1:
conn.execute('''INSERT INTO transfer_log (pokemon, iv, cp) VALUES (?, ?, ?)''', (pokemon.name, pokemon.iv, pokemon.cp))
break
else:
self.emit_event(
'transfer_log',
sender=self,
level='info',
formatted="transfer_log table not found, skipping log"
)
break
action_delay(self.transfer_wait_min, self.transfer_wait_max)

def _get_release_config_for(self, pokemon):
Expand Down

0 comments on commit c5c120a

Please sign in to comment.