Commit Graph

203 Commits

Author SHA1 Message Date
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
d1d54a468a Rename Server to Guild everywhere. 2017-01-03 09:51:54 -05:00
f33eaa4a61 Stateful Message and remove Invite.xkcd since it is removed. 2017-01-03 09:51:53 -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
aa8a328f0a Remove Message.timestamp and make Message.channel_mentions lazy.
Message.timestamp is replaced with Message.created_at. This commit
also affects how MESSAGE_UPDATE is handled by only assuming that two
keys are provided rather than overwriting data with missing keys.
2017-01-03 09:51:48 -05:00
044b0824e6 Begin working on the rewrite. 2017-01-03 09:51:47 -05:00
4d87b2f817 Inject full Emoji to Reaction if we have it.
Reaction objects with custom Emoji are partial. If we know of this Emoji
(can find it on this client) then inject it. Otherwise, leave it as a
hollow Emoji. We can still react with a hollow Emoji, but can't get other
metadata about it.
2016-11-03 04:39:45 -04:00
c4acc0e1a1 Add support for reactions.
Reactions can be be standard emojis, or custom server emojis.

Adds
 - add/remove_reaction
 - get_reaction_users
 - Messages have new field reactions
 - new events - message_reaction_add, message_reaction_remove
 - new permission - add_reactions
2016-10-27 21:36:32 -07:00
da986b2d7c Support for pinned system messages. 2016-09-12 20:22:53 -04:00
bd39c3ef45 Add utility properties to CallMessage to query information. 2016-07-15 23:42:53 -04:00
33eba31aac Fix the displaying of Message.system_content 2016-07-15 22:11:56 -04:00
a128249b63 Add support for different message types and call message. 2016-07-13 20:11:18 -04:00
01a46f0612 Make Message.channel_mentions unique. 2016-06-27 21:44:29 -04:00
b3edb31df5 Add support for message pinning.
This includes `Client.pin_message`, `Client.unpin_message` and
`Client.pins_from`. This also adds the `Message.pinned` attribute
to the `Message` object.
2016-06-18 02:14:44 -04:00
5fa715c350 Fix typo in Message.role_mentions documentation. 2016-05-01 07:34:48 -04:00
79f6554289 Add Message.role_mentions and handle them in Message.clean_content 2016-04-29 07:54:49 -04:00
54e9be7aed Message.clean_content now takes into consideration @here mentions. 2016-04-23 02:13:33 -04:00
e64787a415 Guard against AttributeErrors when clearing cached slot cache. 2016-04-05 18:22:44 -04:00
dfd51b95d6 Make Message.clean_content a cached property again.
Instead, clear the cached properties so they will be re-cached when
invoked again.
2016-04-05 18:01:55 -04:00
f235dc5ca4 Fix handling of message update in MESSAGE_UPDATE 2016-04-05 18:01:54 -04:00
c2ffff1549 Fix bug where @everyone usernames bypass Message.clean_content. 2016-03-02 23:30:09 -05:00
085e8d4eb3 Message.clean_content now handles everyone mentions properly. 2016-01-30 06:17:20 -05:00
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
5ca13cac8e Add Message.nonce attribute. 2016-01-07 02:06:11 -05:00
89a418a388 Add __slots__ for missing classes that didn't have it. 2016-01-06 23:40:20 -05:00
db4cc791dd Update license of files to 2016. 2016-01-04 22:28:29 -05:00
33dbd84398 Message no longer upgrades if the channel is an Object 2015-12-29 01:20:36 -05:00
f1f0e169e4 Add __slots__ where appropriate to data classes. 2015-12-19 06:18:12 -05:00
613214f197 Add Message.clean_content property to get prettified mentions. 2015-12-17 00:15:41 -05:00
ebcb532c38 Change regex from \d+ to [0-9]+ for performance reasons.
\d+ includes unicode characters while [0-9]+ doesn't.
2015-12-16 23:46:02 -05:00
9f92536441 Clean-up documentation to use NumPy style docs on remaining classes. 2015-12-16 22:20:54 -05:00
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
c3e7ba3671 Message.channel's Object instance has an is_private attribute now.
This was to allow for basic checks such as message.channel.is_private
to succeed at the very least. It is a very small mitigation and not
perfect since it doesn't have every attribute that PrivateChannel
itself has. However you could retrieve the user info through the
Message.author attribute.
2015-11-28 23:06:23 -05:00
ed53f3fb3a Add caveat note about Message.mention_everyone 2015-11-28 22:35:53 -05:00
101d8d52b6 Add warning for Message.mentions order being non-deterministic. 2015-11-28 20:16:17 -05:00
acbbaa39ad Add Message.channel_mentions 2015-11-19 23:10:15 -05:00
da37ff16c1 Add get_raw_[channel_]mentions to Message 2015-11-19 23:01:43 -05:00
e88c194e9a Fix is_private check in mentions array handling. 2015-11-19 22:21:15 -05:00
692a6a3bc6 Fix ordering issue with Message.server 2015-11-18 20:04:27 -05:00
75658f46a2 Message.mentions now returns a list of Member instead of User 2015-11-16 21:18:30 -05:00
c49ff36a7b Make Message.channel an Object if something goes wrong.
Fixes #21
2015-10-27 17:21:08 -04:00
1a13f9ad30 Add Message.server attribute shortcut. 2015-10-23 17:41:28 -04:00
c8535f714e Documentation fixes for Message. 2015-10-21 21:09:01 -04:00
15b83b2743 Message.author is now either Member or User.
Closes #11.
2015-10-14 05:58:04 -04:00
b4e6591c9d Refactor parse_time into its own utils file. 2015-09-04 22:00:22 -04:00
b00ad4ad79 Use kwargs if the number of arguments needed is too many. 2015-09-04 21:16:27 -04:00
b7fc383013 Python3 import fixes. 2015-08-28 16:55:40 -04:00
de3bce2b32 Fix issue with some MESSAGE_UPDATE events. 2015-08-24 06:34:38 -04:00