ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

bot.save_user_stats() does not save updated stats #548

Closed 1326570 closed 6 years ago

1326570 commented 6 years ago

Before submitting an issue, make sure you have:

Purpose of your issue?


Code:

in 'ultimate.py'
def stats():
    bot.save_user_stats(bot.username)

schedule.every(1).hours.do(run_threaded, stats)

but this saves the first value over and over. Probably because in get_user_info() there is a check to see if user stats were already asked for. 

def get_user_info(self, user_id):
    user_id = self.convert_to_user_id(user_id)
    if user_id not in self._user_infos:
        self.api.get_username_info(user_id)
        if 'user' not in self.api.last_json:
            return False
        user_info = self.api.last_json['user']
        self._user_infos[user_id] = user_info
    return self._user_infos[user_id]

Error/Debug Log:


Describe your issue

In the ultimate file we save the usere stats every hour, however bot.save_user_stats() does not save updated stats, but the ones when the function was first run. This saves the same value over and over. Probably because in get_user_info() there is a check to see if user stats were already asked for.

--> add check to see if user stats are requested from own user ID, or remove check altogether and always overwrite when function is called.

orcunbaslak commented 6 years ago

Same issue here

lubislutfi commented 6 years ago

same issue too...

basnijholt commented 6 years ago

https://github.com/instagrambot/instabot/pull/556 should fix it ;)

1326570 commented 6 years ago

Need to add the use_cache part to the bot.py file as well. Seems to work well otherwise

basnijholt commented 6 years ago

Thanks for using it. I've reopened the issue. Could you be a bit more specific about where you added the use_cache?

lubislutfi commented 6 years ago

In bot/bot.py Change: def get_user_info(self, user_id): return get_user_info(self, user_id) To: def get_user_info(self, user_id, use_cache): return get_user_info(self, user_id, use_cache)

basnijholt commented 6 years ago

Good point! I've just changed ithttps://github.com/instagrambot/instabot/commit/b7404c645b31c4424dbdf8beb4035d25307a484a

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.