45 Commits

Author SHA1 Message Date
Rapptz
1c623ccf11 Begin working on gateway v4 support.
Bump websockets requirement to v3.1

Should be squashed...
2016-04-27 18:36:13 -04:00
Rapptz
8d7dd79673 Fix deadlock issue when joining large guilds. 2016-04-15 23:27:23 -04:00
Rapptz
7eb9a7dfdc Handle bot tag updates in GUILD_MEMBER_UPDATE. 2016-04-12 18:19:02 -04:00
Rapptz
7023b353f6 User JSON object has 'username' keys not 'name'. 2016-04-11 14:39:04 -04:00
Rapptz
6076c8c671 Better chunking behaviour and add members on PRESENCE_UPDATE.
This should hopefully cover all cases where members are added.
There was a bug where an array of chunks received would get entirely
processed if only a single chunk was received. This was fixed by
explicitly bailing early if we're requesting for chunks.
2016-04-11 14:24:15 -04:00
Khazhismel
84f1342b85 Fix chunk requests not actually being batched. 2016-04-11 11:53:54 -04:00
Rapptz
0401ab561b Proper chunking for unavailable guilds.
This will also delay on_ready until all chunking is complete.
2016-04-10 00:47:00 -04:00
Zeta
f235dc5ca4 Fix handling of message update in MESSAGE_UPDATE 2016-04-05 18:01:54 -04:00
Rapptz
8b7f15ef8d Skip member_update event when a member is not in a guild. 2016-04-02 23:38:45 -04:00
Rapptz
80587fc1e9 Change parsing of READY to be eager again. 2016-03-06 14:41:31 -05:00
Rapptz
6ac2e07833 Fix bug where large servers in GUILD_CREATE did not get chunked. 2016-03-06 05:52:05 -05:00
Rapptz
425bd2c091 Move chunking logic back into ConnectionState.
This allows for a nicer design when dealing with parsers that could
end up being coroutines.
2016-03-06 05:24:18 -05:00
Rapptz
3802e7f534 Server.me is now a dynamic property to avoid outdated references. 2016-03-01 22:54:28 -05:00
Rapptz
3862b1abcf Do not overwrite members that are already in cache during chunking. 2016-02-17 05:44:00 -05:00
Rapptz
4584c68f0c Remove request_offline option. 2016-02-14 21:49:34 -05:00
Rapptz
841e584ee9 Update owner references when we get a chunk. 2016-02-14 20:00:50 -05:00
Rapptz
4768d950c5 Offline members are now added by default automatically.
This commit adds support for GUILD_MEMBERS_CHUNK which had to be done
due to forced large_threshold requirements in the library.
2016-02-14 19:24:26 -05:00
Rapptz
530fbe78b8 Handle case where PRESENCE_UPDATE adds members to cache.
When we don't request offline members, members that are going from
offline to online in the server will become available via the
PRESENCE_UPDATE event. This should be transparent to the user since
technically the member exists in the server and thus on_member_update
is used instead of on_member_join.
2016-02-13 22:34:38 -05:00
Rapptz
7b135725bc Add Server.member_count property for actual member count.
This will always work regardless of chunking or not.
2016-02-13 22:08:13 -05:00
Rapptz
6682691012 Fix cases where Member.roles would have a string instead of Role.
Fixes #81.
2016-02-01 18:39:39 -05:00
Rapptz
654001ba3e Update the unavailable guild's data when it becomes available. 2016-01-21 07:00:39 -05:00
Khazhismel
bbe6455eb9 Guild member add will include deaf and mute now, do not provide default values 2016-01-12 11:49:22 -05:00
Rapptz
4ea015067f Handle cases where people put False-like values for game presences. 2016-01-11 19:50:13 -05:00
Rapptz
8974dffc4e Change internal update functions to have a leading underscore. 2016-01-11 14:44:13 -05:00
Steven Berler
777b5a09e2 document public get_ methods and make others private 2016-01-08 13:24:56 -05:00
Steven Berler
10b0b62f50 performance improvements
Replaced server member lists, channel lists, and private channel lists
with dicts. This allows O(1) lookups and removes (previously it would be
an O(N) operation to lookup or remove). I did pretty extensive testing
and benchmarking to compare the performance of using lists vs using
dicts. Iterating through lists to find an item is only faster in the
average case for extremely small lists (less than 3 items). For 100
items, using a dict is about 10 times faster on average (and about 100
times faster for 1000 items). The overhead in dicts is in memory usage
and initial creation time. Creating and populating a dict is about 2 to
3 times slower than creating and appending items to a list. However this
cost is still tiny.  For 1000 items this equates to about a 70
microsecond difference (on an i7 CPU) for populating the entire dict.
The memory overhead for a dict (compared to a list) is about 25-60 KB
per 1000 items (can vary depending on dict resizing).

Originally I wanted to use OrderedDicts to presereve order, but in my
testing OrderedDicts have about 6x the memory overhead compared to
normal dicts.
2016-01-08 13:24:55 -05:00
Rapptz
a2b97ae2db Fix handling of embed-only MESSAGE_UPDATE. 2016-01-07 02:54:01 -05:00
Rapptz
0fbb58cde9 Change the way MESSAGE_UPDATE events are handled.
Previously we created a copy of the object and did some strange
iteration over the data and set the attributes that we thought
were valid. This worked back then in v0.1.0 of the library when
it was written, but it no longer works nowadays when we want to
be as future proof as possible.
2016-01-07 01:27:38 -05:00
Rapptz
c1583dd7d6 Unavailable guilds get added to cache. 2016-01-06 12:57:09 -05:00
Rapptz
db4cc791dd Update license of files to 2016. 2016-01-04 22:28:29 -05:00
Rapptz
c11bd9b8f4 ConnectionState is now constructed in Client.__init__.
This should reduce the amount of checks for None if someone doesn't
want a websocket connection. The connection state is instead cleared
rather than reconstructed.
2015-12-29 11:59:18 -05:00
Khazhismel
0aa46e6def Add game data class, replace game_id. 2015-12-23 21:28:18 -05:00
Rapptz
7258a9e700 Delete messages from message cache when you leave the server. 2015-12-19 10:36:11 -05:00
Rapptz
f1f0e169e4 Add __slots__ where appropriate to data classes. 2015-12-19 06:18:12 -05:00
Rapptz
9075d46efd Add on_member_ban and on_member_unban events.
Fixes #58.
2015-12-17 18:22:16 -05:00
Rapptz
63565026c4 Remove on_status event. Superseded by on_member_update. 2015-12-17 06:18:08 -05:00
Rapptz
49d78c69c7 All update related events now pass in the previous state. 2015-12-17 06:05:35 -05:00
Rapptz
4f66d41ca3 Add Server.me attribute to access the Member version of Client.user. 2015-12-16 23:35:05 -05:00
Rapptz
de1c74a399 Make more things into properties.
A lot of the expensive getters were transformed into cached properties
instead. A lot of things that were properties were transformed into
properties as well.
2015-12-16 22:03:16 -05:00
Rapptz
7f0a048299 Fix GUILD_ROLE_DELETE triggering ValueError. 2015-12-14 23:26:22 -05:00
Steven Berler
037da750dd avoid potential bug when creating new private msgs
It probably isn't good to rely on an item that was added to a list to
still be the last item, especially if we could have other async
coroutines modify the list. This may not be an actual issue, but having
the function explicitly return the object that it just added to the list
should guarantee that we don't accidentally pull the wrong item from the
end of the list later.
2015-12-13 13:01:05 -05:00
Rapptz
cfc26b894f Fix issue with member.roles being empty. 2015-12-08 00:46:58 -05:00
Rapptz
80b32e769e Handle GUILD_UPDATE 2015-12-06 03:09:55 -05:00
Rapptz
79bdf2a721 Add enumerators instead of strings.
Changes channel type, status and server region into 3.4 enums.
2015-12-04 22:13:17 -05:00
Rapptz
f197c34583 Begin working on asyncio port. 2015-12-04 00:16:34 -05:00