-
Notifications
You must be signed in to change notification settings - Fork 46
Merge Events branch #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- `coc.login(email, pass)` function will now create a client and automatically create HTTP session and all related (and to come) "stuffs". - `Client.on_key_reset()` event has been removed. It is redundant since the client handles all key changes - All methods now have optional (default to True) `update_cache` parameter. This was necessary for the events branch, however should not affect normal usage.
- They compare via private `_data` attribute.
- Thrown when a 502 or 504 error occurs. The html given by api has been parsed into a text string
… session is ready for use
- This is still a very much work in progress. - Provides same functionality as regular client - You can 'subscribe' to events such as change in war (new attack, state change etc.), clan update (member join/leave, settings change etc.) or player update (troop level up, achievement change) - Undocumented at present; read the source code if you wish to beta test, however lots of changes to make it better/easier to use / actually work incoming.
Clans: - Clan - BasicClan - SearchClan - WarClan - LeagueClan Players - Player - BasicPlayer - WarMember - SearchPlayer - LeaguePlayer - LeagueRankedPlayer Wars - BaseWar - WarLog - CurrentWar - WarAttack - LeagueGroup - LeagueWar - LeagueWarLogEntry `await Timestamp.save(fp)` is now a thing.
- All master event runners now implement an `asyncio.Event` for better/easier use to start/stop the loop - Everything moved out of __init__ into setup() function - Added documentation - You can now register multiple events with method `add_events(*fctns, function_dict)`. This will hopefully aid use. - Redesign how meth `start_updates` works to utilise new events. Add a corresponding `stop_updates` method too. - Add clan and player objects to some events that were missing these.
…r()` blocking method to run the script forever.
methods `add_war_update` and `add_player_update`s are no longer coroutines to aid setup fix correct `event.set()` and `event.clear()` orders (got them backwards)
- `Client` now accepts `default_cache` parameter, a function to determine how cache will be set on client initiation. This defaults to `Client.default_cache()`, must **not** be a coroutine, and **must** take client as it's first and only parameter. - `Client._cache_lookup` now provides a dict of all cache objects. The preferred way of accessing these is still `Client.get_cache`. - `Client.set_cache` has been removed, replaced by `Client.default_cache` and `Client.edit_cache`. - Copy Client docstring to EventsClient docstring automatically
string slice rather than index troop, spell, hero dicts
`on_player_troop_unlock` -> new troop unlocked `on_player_spell_unlock` -> new spell unlocked `on_player_hero_unlock` -> new hero unlocked This also fixes a bug trying to index a list which didn't contain the new troop.
`cwl` --> the war is a league war `friendly` --> the war is friendly (23hr prep) `random` --> the war is random (other length prep)
- `CurrentWar` has been renamed to `ClanWar` - `WarIterator` has been renamed to `ClanWarIterator` - `Client.get_current_war` has been renamed to `Client.get_clan_war` - `Client.get_current_wars` has been renamed to `Client.get_clan_wars` - New Method: `Client.get_league_wars`: pass in multiple war tags to return a `LeagueWarIterator` of league wars found. - New Method: `Client.get_current_war`: get a current war of a clan, be it ClanWar or LeagueWar. This abstracts the worries of dealing with war tags and simplifies what would otherwise be 2-3 calls. - Likewise, `Client.get_current_wars` has been added: pass in multiple tags to get a `CurrentWarIterator` of current wars.
…` renamed to `time`, making it easier and shorter to use.
These are called after every 'round' of updater tasks is completed, ie after each sleep. They contain a List[List[event args]]. You can differentiate between different events within that group via the first arg which is the event name (with on_ prefix). Add an extra cache to record events dispatched to aid with `on_X_batch_update` use.
Due to the way iterators use multithreading, this fails if a key needs to be reset. The function `Client.reset_keys()` has been added, and utilised in iterators. Babysteps, there please report more bugs.
…ed, won, lost, tie.
…e {f: n} makes 0 sense
Remove extra `on_` from batch updates.
…ly getting args for cache. Generally just make it work
…or all errors given.
- Previous implementation assumed that all events were going to be utilised, meaning default cache had no TTL even if events hadn't been started/added. - Default cache for `EventsClient` is now the same as `Client`, with relevant cache instances only being cleared once an event has been startd.
…ceived` When donations given + received respectively.
…n the docs. Tidy up some linting/other minor fixes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please see the changelog with v0.2.0 for more information.