Commit Graph

374 Commits

Author SHA1 Message Date
38fd0928df Don't clear state when READY is reached for auto sharded clients. 2017-04-16 02:32:23 -04:00
ac90159c72 Improve logging in more places.
This shows the Shard ID in more places, along with a gateway trace and
session ID. Also helps show the RESUME/IDENTIFY/RESUMED/READY flow a
bit more instead of it looking like the connection has zombied out.
2017-04-12 19:43:47 -04:00
982308da3c Use global user cache to fetch reaction event data.
Also make sure it isn't dispatched unless the data meets the integrity
checks (i.e. not None).
2017-04-09 21:37:49 -04:00
bcfb31779d Fix KeyError in certain logging cases. 2017-04-07 23:22:44 -04:00
7f58853e3a Keep track of Emoji instances myself.
WeakValueDictionary cleans up too late and brings too little benefit.
Also clean up the state when the first READY is encountered for
AutoShardedClient and when any READY is encountered in regular Client.
2017-03-29 04:36:06 -04:00
cac84e517b Always overwrite Emoji references in the state.
There is potential that when recreating the Emoji list in the
GUILD_EMOJIS_UPDATE event would just fetch from cache and the element
in cache having an out of date Guild reference. This Guild reference
will be kept alive for longer than it should be.

By always overwriting the Emoji reference, this problem goes away.
2017-03-26 18:43:57 -04:00
aef170d7e0 Fix memory leak by holding on to Emoji references weakly.
The library had a memory leak in the case using the global emoji cache.
When the bot would leave the guild, the Emoji would maintain a strong
reference to the Guild keeping them alive along with the entire state
associated with it.
2017-03-24 21:46:32 -04:00
46951e27f7 Revert "Reference the ConnectionState by weakref."
This reverts commit 730a0e2d53.
2017-03-24 21:44:33 -04:00
730a0e2d53 Reference the ConnectionState by weakref instead of a strong reference.
Hopefully this means when the bot has some lingering object for
whatever reason, the memory doesn't double due to it having a strong
reference to an outdated connection state.
2017-03-22 00:02:50 -04:00
a0cdb19c5f Eventual consistency fixes. 2017-03-21 03:16:30 -04:00
9c6d9f1a84 Remove call handling for now. 2017-03-13 17:07:33 -04:00
ead18e3948 Fix issue with members not copying correctly. 2017-03-05 07:48:15 -05:00
e78a5c0643 Remove remaining voice_member tracking. 2017-02-28 18:29:27 -05:00
f6fcb62c7b Check for PrivateChannel before GuildChannel in Client.get_channel 2017-02-25 20:56:09 -05:00
29f676c42e Wrap asyncio.wait into a saner alternative that raises TimeoutError.
Fixes #494
2017-02-25 00:03:43 -05:00
b8727fd463 Fix Client.emojis returning a list of IDs. 2017-02-21 08:38:06 -05:00
0dac5e3139 Add Client.emojis to get all emojis.
This removes the older get_all_emojis generator.
2017-02-10 16:43:33 -05:00
554ae196d3 Add missing int casts in many different events in the state.
Also remove redundant role parsing in Member._update_roles.
2017-01-28 08:14:43 -05:00
b876133e87 Add compatibility shim for asyncio.Future creation.
Should provide better support for uvloop.
2017-01-25 21:38:50 -05:00
e1aaf74fa7 Add option to disable auto member chunking. 2017-01-23 07:07:42 -05:00
d206ee792b Fix issue with user bots chunking unavailable guilds. 2017-01-21 16:25:51 -05:00
ff9f5749e1 Update copyright year to 2017. 2017-01-20 23:19:19 -05:00
4c981ee631 Add support for relationships. 2017-01-20 19:28:43 -05:00
fa384f2114 Make ClientUser separate from a regular User.
This removes Client.edit_profile in favour of ClientUser.edit.
2017-01-19 19:37:11 -05:00
f465f88d81 Reimplement Guild.me property without patching it in. 2017-01-18 19:54:47 -05:00
c635ce2526 Simple parser for CHANNEL_PINS_UPDATE 2017-01-09 03:52:44 -05:00
92c1637921 Allow overriding the shard_ids used for initial shard launch. 2017-01-08 02:05:21 -05:00
20041ea756 Implement AutoShardedClient for transparent sharding.
This allows people to run their >2,500 guild bot in a single process
without the headaches of IPC/RPC or much difficulty.
2017-01-07 23:19:39 -05:00
d54d7f7ac0 Fix variable shadowing in READY parsing. 2017-01-05 07:03:56 -05:00
808a05ff2d Move global user cache to a WeakValueDictionary. 2017-01-04 05:16:59 -05:00
c863d93f69 Fix bug that made member roles go missing. 2017-01-03 20:17:58 -05:00
7690455b21 Make User and Member messageable. 2017-01-03 09:52:12 -05:00
98b981848d Move message creation to a factory method inside ConnectionState. 2017-01-03 09:52:10 -05:00
5e6bfecb07 Move away from StateContext and use ConnectionState directly. 2017-01-03 09:52:10 -05:00
4e175d36d3 Add delete_after parameter to MessageChannel.send 2017-01-03 09:52:04 -05:00
79a49f9145 Absolute import some circular dependencies to appease Python 3.4. 2017-01-03 09:52:02 -05:00
2c50c18ca3 Change dict value views into lists. 2017-01-03 09:51:59 -05:00
c187d87dae Re-add support for reactions.
We now store emojis in a global cache and make things like adding
and removing reactions part of the stateful Message class.
2017-01-03 09:51:57 -05:00
59a0df5f98 Rename try_insert_user to store_user 2017-01-03 09:51:56 -05:00
5cb3ad14e8 Make emojis and members stateful. 2017-01-03 09:51:55 -05:00
a7a60e433b Make roles and guilds stateful. 2017-01-03 09:51:55 -05:00
d1d54a468a Rename Server to Guild everywhere. 2017-01-03 09:51:54 -05:00
53ab263125 Split channel types.
This splits them into the following:

* DMChannel
* GroupChannel
* VoiceChannel
* TextChannel

This also makes the channels "stateful".
2017-01-03 09:51:52 -05:00
45c729b167 Switch IDs to use int instead of str 2017-01-03 09:51:49 -05:00
31229a53e9 Optimise VoiceState for memory.
Instead of storing one VoiceState per Member, only store them if
necessary. This should bring down the number of instances
significantly.
2017-01-03 09:51:47 -05:00
044b0824e6 Begin working on the rewrite. 2017-01-03 09:51:47 -05:00
a8264f6540 Chunk every guild if it's a user bot.
This also increases the timeout for chunking by 30 seconds for every
chunk we're waiting for.
2016-12-24 17:32:20 -05:00
bed2e90e82 Properly propagate loop. Fixes #420. 2016-12-21 00:06:19 -05:00
a0f4ad36eb Timeout waiting for chunking.
Sometimes the bot would keep waiting for chunks that somehow finished
before getting to the `wait` call. This is more so a temporary fix
rather than a fully correct one.
2016-12-16 21:28:12 -05:00
c8fd8a9e1a Fix crash on duplicate or out of order reactions.
Eventual consistency ftw
2016-11-30 16:47:00 -05:00