aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* Add a message cache API (#345)zeyla2018-07-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds an API for message caching. By default this caches 0 messages per channel. This can be customized when instantiating: ```rust use serenity::cache::{Cache, Settings}; let mut settings = Settings::new(); // Cache 10 messages per channel. settings.max_messages(10); let cache = Cache::new_with_settings(settings); ``` After instantiation: ```rust use serenity::cache::Cache; let mut cache = Cache::new(); cache.settings_mut().max_messages(10); ``` And during runtime through the global cache: ```rust use serenity::CACHE; CACHE.write().settings_mut().max_messages(10); ```
* Fix links to the repoZeyla Hellyer2018-05-231-2/+2
| | | | | Fixes links to the repo from `https://github.com/zeyla/serenity` to `https://github.com/serenity-rs/serenity`.
* Bump to v0.5.0v0.5.0Zeyla Hellyer2018-01-201-1/+1
|
* Update readme exampleZeyla Hellyer2018-01-181-4/+7
|
* Revamp the internals of `Args`acdenisSK2017-12-161-2/+0
| | | | Fixes #180, however this partially breaks `single_zc` and `multiple_quoted`, but since they're minor it's better to fix them later for now.
* Merge v0.4.3acdenisSK2017-11-041-1/+6
|\
| * Fix ping bot example (#211)Ben2017-10-311-1/+6
| |
* | Fix some compilation feature targets, fix lintsZeyla Hellyer2017-10-171-2/+1
| |
* | Update to account for changes made in 0.4.1acdenisSK2017-10-141-13/+11
|\|
| * Feature-flag extern crates behind their nameZeyla Hellyer2017-10-141-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An issue with modifying what features enable compilation of what crates was possible due to crates being feature-flagged behind a module name instead of their own name. Instead of writing cfg features for crates as: ```rust \#[cfg(feature = "utils")] extern crate base64; ``` Write the feature name as its own name: ```rust \#[cfg(feature = "base64")] extern crate base64; ``` This way, crates can simply have compilation enabled in the project's features section in the `Cargo.toml` file.
| * Fix clippy lintsZeyla Hellyer2017-10-111-3/+0
| |
| * Add a threadpool to the shard runnerZeyla Hellyer2017-10-091-0/+2
| | | | | | | | | | | | A threadpool will help with giving event dispatches a threaded behaviour while still allowing the library the ability to perform other actions, such as receiving new events and heartbeating over the websocket client.
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-11/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to the `parking_lot` crate's implementations of `std::sync::Mutex` and `std::sync::RwLock`, which are more efficient. A writeup on why `parking_lot` is more efficient can be read here: <https://github.com/Amanieu/parking_lot> Upgrade path: Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to unwrap or handle a result), and `rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to `rwlock.read()` and `rwlock.write()`. For example, modify: ```rust use serenity::CACHE; println!("{}", CACHE.read().unwrap().user.id); ``` to: ```rust use serenity::CACHE; println!("{}", CACHE.read().user.id); ```
* | Add a threadpool to the shard runnerZeyla Hellyer2017-10-091-0/+2
|/ | | | | | A threadpool will help with giving event dispatches a threaded behaviour while still allowing the library the ability to perform other actions, such as receiving new events and heartbeating over the websocket client.
* Update readme exampleZeyla Hellyer2017-09-251-1/+2
|
* Bump to v0.4.0Zeyla Hellyer2017-09-251-1/+1
|
* Switch to temporary rust-websocket forkZeyla Hellyer2017-09-251-1/+1
|
* Remove tokio usageZeyla Hellyer2017-09-211-4/+0
|
* Fix compiles of a variety of feature combinationsZeyla Hellyer2017-09-181-4/+10
| | | | | This fixes compilation errors and warnings when compiling a mixture of non-default feature targets.
* Revamp `CacheEventsImpl`acdenisSK2017-09-121-2/+0
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-241-3/+3
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Allow FromStr for User to use REST (#147)Maiddog2017-08-241-1/+2
|
* Fix tests (#145)Maiddog2017-08-221-1/+1
|
* feature-flag the vec_shift dependencyacdenisSK2017-08-211-1/+2
|
* Revamp the args to an `Args` structacdenisSK2017-08-201-4/+1
| | | | Fixes #142
* Use wildcardacdenisSK2017-08-191-1/+1
|
* Move builtin framework impl to its own moduleZeyla Hellyer2017-08-191-1/+1
| | | | | | | | | | | | | | | | | The framework is now moved in its entirity to the `framework` module, with the `Framework` trait currently on its own and the builtin implementation provided. The builtin implementation has been renamed to "Standard". Upgrade path: Rename the `BuiltinFramework` import to `StandardFramework`. Instead of importing builtin framework items from `serenity::framework`, import them from `serenity::framework::standard`. This is the beginning to #60. The root `framework` module (non-standard implementation) will be built more by the time it's closed.
* Add html_root_urlacdenisSK2017-08-191-0/+1
|
* Move Clippy lints to a cfg_attrZeyla Hellyer2017-08-181-1/+1
|
* Move the Framework trait to the frameworkZeyla Hellyer2017-08-181-21/+0
|
* ClippyacdenisSK2017-08-191-1/+1
|
* Fix string delimiters (#134)Lakelezz2017-08-131-0/+4
|
* Split event handling in the cache to a traitacdenisSK2017-08-101-0/+2
| | | | note: This trait might become like `framework::Framework` in the future.
* Remove the `ext` module and remove a matchacdenisSK2017-08-011-2/+0
| | | | | The `ext` has existed for a long while just for backwards compatibility. But then again, majority of people should have migrated to the current modules already; making this module useless to keep in the library.
* rustfmtacdenisSK2017-07-271-33/+35
|
* Make the `framework` module feature-gated and fix the names in the helper macroacdenisSK2017-07-271-2/+21
|
* Switch to tokio for events (#122)Alex Lyon2017-07-141-0/+5
|
* Fixed clippy warnings (#118)Kaidan2017-06-281-2/+0
|
* Bump to v0.3.0v0.3.0Zeyla Hellyer2017-06-241-1/+1
|
* Fix no-framework compilationZeyla Hellyer2017-06-141-0/+2
|
* Upgrade rust-websocket, rust-openssl, and hyperZeyla Hellyer2017-06-071-0/+4
| | | | | | | | | | | | | | | | Upgrade `rust-websocket` to v0.20, maintaining use of its sync client. This indirectly switches from `rust-openssl` v0.7 - which required openssl-1.0 on all platforms - to `native-tls`, which allows for use of schannel on Windows, Secure Transport on OSX, and openssl-1.1 on other platforms. Additionally, since hyper is no longer even a dependency of rust-websocket, we can safely and easily upgrade to `hyper` v0.10 and `multipart` v0.12. This commit is fairly experimental as it has not been tested on a long-running bot.
* Deprecate Client::login, add Client::newZeyla Hellyer2017-06-061-3/+3
|
* Clippy lintsZeyla Hellyer2017-06-061-2/+0
|
* Use chrono for struct timestamp fieldsZeyla Hellyer2017-06-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Chrono is easier to use than timestamped strings, so they should be automatically deserialized and available for the user, instead of having the user deserialize the strings themselves. These fields have been changed to use a type of `DateTime<FixedOffset>`: - `ChannelPinsUpdateEvent.last_pin_timestamp` - `Group.last_pin_timestamp` - `Guild.joined_at` - `GuildChannel.last_pin_timestamp` - `Invite.created_at` - `Member.joined_at` - `Message.edited_timestamp - `Message.timestamp` - `MessageUpdateEvent.edited_timestamp` - `MessageUpdateEvent.timestamp` - `PrivateChannel.last_pin_timestamp` `Member.joined_at` is now also an `Option`. Previously, if a Guild Member Update was received for a member not in the cache, a new Member would be instantiated with a default String value. This is incorrect behaviour, and has now been replaced with being set to `None` in that case. Id methods' `created_at()` method now return a `chrono::NaiveDateTime` instead of a `time::Timespec`, and `User::created_at` has been updated to reflect that. Additionally, drop `time` as a direct dependency and use chrono for internals.
* Fix compilations across feature combinationsZeyla Hellyer2017-06-021-0/+2
|
* Restructure modulesZeyla Hellyer2017-05-221-17/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modules are now separated into a fashion where the library can be used for most use cases, without needing to compile the rest. The core of serenity, with no features enabled, contains only the struct (model) definitions, constants, and prelude. Models do not have most functions compiled in, as that is separated into the `model` feature. The `client` module has been split into 3 modules: `client`, `gateway`, and `http`. `http` contains functions to interact with the REST API. `gateway` contains the Shard to interact with the gateway, requiring `http` for retrieving the gateway URL. `client` requires both of the other features and acts as an abstracted interface over both the gateway and REST APIs, handling the event loop. The `builder` module has been separated from `utils`, and can now be optionally compiled in. It and the `http` feature are required by the `model` feature due to a large number of methods requiring access to them. `utils` now contains a number of utilities, such as the Colour struct, the `MessageBuilder`, and mention parsing functions. Each of the original `ext` modules are still featured, with `cache` not requiring any feature to be enabled, `framework` requiring the `client`, `model`, and `utils`, and `voice` requiring `gateway`. In total the features and their requirements are: - `builder`: none - `cache`: none - `client`: `gateway`, `http` - `framework`: `client`, `model`, `utils` - `gateway`: `http` - `http`: none - `model`: `builder`, `http` - `utils`: none - `voice`: `gateway` The default features are `builder`, `cache`, `client`, `framework`, `gateway`, `model`, `http`, and `utils`. To help with forwards compatibility, modules have been re-exported from their original locations.
* Bump to v0.2.0v0.2.0Zeyla Hellyer2017-05-131-2/+1
|
* Update most dependency version requirementsZeyla Hellyer2017-04-231-1/+2
| | | | | | | | Update the dependencies `base64`, `bitflags`, `byteorder`, `serde`, `serde_derive`, and `serde_json`. These dependencies have been updated, with byteorder and serde** hitting v1.0.0, so they should be updated for the v0.2.0 serenity release.
* Update the way errors are handled in dispatchIllia2017-04-191-1/+1
|
* Switch to using serde for deserializationZeyla Hellyer2017-04-111-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current build system is rudimentary, incomplete, and rigid, offering little in the way of customizing decoding options. To solve this, switch to using serde-derive with custom Deserialization implementations. This allows very simple deserialization when special logic does not need to be applied, yet allows us to implement our own deserialization logic when required. The problem with the build system was that it built enums and structs from YAML files. This is not so good, because it requires creating a custom build system (which was rudimentary), creating "special struct configs" when logic needed to be ever so slightly extended (rigid), and if special logic needed to be applied, a custom deserialization method would have been needed to be made anyway (incomplete). To solve this, switch to serde-derive and implementing Deserialize ourselves where required. This reduces YAML definitions that might look like: ```yaml --- name: Group description: > A group channel, potentially including other users, separate from a [`Guild`]. [`Guild`]: struct.Guild.html fields: - name: channel_id description: The Id of the group channel. from: id type: ChannelId - name: icon description: The optional icon of the group channel. optional: true type: string - name: last_message_id description: The Id of the last message sent. optional: true type: MessageId - name: last_pin_timestamp description: Timestamp of the latest pinned message. optional: true type: string - name: name description: The name of the group channel. optional: true type: string - name: owner_id description: The Id of the group channel creator. type: UserId - name: recipients description: Group channel's members. custom: decode_users t: UserId, Arc<RwLock<User>> type: hashmap ``` to: ```rs /// A group channel - potentially including other [`User`]s - separate from a /// [`Guild`]. /// /// [`Guild`]: struct.Guild.html /// [`User`]: struct.User.html pub struct Group { /// The Id of the group channel. #[serde(rename="id")] pub channel_id: ChannelId, /// The optional icon of the group channel. pub icon: Option<String>, /// The Id of the last message sent. pub last_message_id: Option<MessageId>, /// Timestamp of the latest pinned message. pub last_pin_timestamp: Option<String>, /// The name of the group channel. pub name: Option<String>, /// The Id of the group owner. pub owner_id: UserId, /// A map of the group's recipients. #[serde(deserialize_with="deserialize_users")] pub recipients: HashMap<UserId, Arc<RwLock<User>>>, } ``` This is much simpler and does not have as much boilerplate. There should not be any backwards incompatible changes other than the old, public - yet undocumented (and hidden from documentation) - decode methods being removed. Due to the nature of this commit, field names may be incorrect, and will need to be corrected as deserialization errors are found.