async def report(self): bots_are_running = True bots_were_connected = False while bots_are_running or not bots_were_connected: # Wait for any bot to connect on app start if not bots_were_connected: bots_were_connected = self.is_any_bot_running() await asyncio.sleep(1) continue wallets: List[BotWallet] = [ session.bot.wallet for session in self.bot_sessions ] summary_tick = sum([wallet.tick for wallet in wallets]) / 1000 summary_score = sum([wallet.score for wallet in wallets]) / 1000 summary_hourly_rate = sum( [wallet.hourly_rate for wallet in wallets]) / 1000 Logger.log_warning(_("VKCoinPy stats")) Logger.log_warning( _("{} bots are running").format(self.count_bots_running())) Logger.log_warning( _("Summary speed: {} / tick | Summary score: {} | Summary hourly rate: {}" ).format(summary_tick, summary_score, summary_hourly_rate)) bots_are_running = self.is_any_bot_running() # Recheck, sometimes it returns False when bots are actually running, maybe some threading magic if not bots_are_running: await asyncio.sleep(1) bots_are_running = self.is_any_bot_running() await asyncio.sleep(self.report_interval)
async def report(self): while True: wallets: List[BotWallet] = [session.bot.wallet for session in self.bot_sessions] summary_tick = sum([wallet.tick for wallet in wallets]) / 1000 summary_score = sum([wallet.score for wallet in wallets]) / 1000 summary_hourly_rate = sum([wallet.hourly_rate for wallet in wallets]) / 1000 Logger.log_warning(_("VKCoinPy stats")) Logger.log_warning(_("{} bots are running").format(self.count_bots_running())) Logger.log_warning( _("Summary speed: {} / tick | Summary score: {} | Summary hourly rate: {}").format(summary_tick, summary_score, summary_hourly_rate)) await asyncio.sleep(self.report_interval)
def check_bot_group_subscription(self): user_groups = self.vk_session.method("groups.get").get('items', []) if self.BOT_GROUP_ID not in user_groups: Logger.log_warning(_("Subscribe to our VK public")) Logger.log_warning(self.BOT_GROUP_URL)