aboutsummaryrefslogtreecommitdiff
path: root/src/internal
Commit message (Collapse)AuthorAgeFilesLines
* Fix compilation + tests on certain feature combosZeyla Hellyer2018-08-071-10/+1
| | | | | | | | On certain feature combinations, compilation and tests would not function correctly. This commit goes through a number of feature combinations and gates some tests behind the required features and fixes other compilation errors.
* Redo how requests are formed in HTTP moduleZeyla Hellyer2018-08-041-22/+0
| | | | | | | | | | Instead of passing around a function that builds an HTTP client request builder, pass around a struct that contains the necessary information _to_ build that request builder. Additionally, instead of using a macro to generate requests, just call a request function. This saves some required code expansion and is just easier to read and maintain.
* Maintain a single, re-used HTTP clientZeyla Hellyer2018-08-041-12/+4
| | | | | | | Instead of creating a new HTTP client for each request, keep a single one for every HTTP request. This will make things faster due to keepalives.
* Log more information about failed deserializationsZeyla Hellyer2018-04-251-2/+16
| | | | | Log more information when messages over the websocket fail to deserialize properly.
* Refactor imports/exports to use nested groups and better formattingacdenisSK2018-03-292-5/+9
|
* Change the way ids and some enums are made (#295)Leah2018-03-232-12/+3
| | | | | This makes them easier to be found by tools like rls. Also update struct inits to use the shorthand version for `x: x`.
* Expose a client voice managerZeyla Hellyer2018-01-181-29/+0
|
* Convert from macro to ? (#226)Mei Boudreau2017-11-231-8/+0
|
* Implement Deserialize for {,Gateway,Voice}EventZeyla Hellyer2017-11-191-20/+4
| | | | | | | | | | | Implement Deserialize for `model::event::GatewayEvent` and `model::event::VoiceEvent`, and derive it for `model::event::Event`. Due to the natural potential slowness of deserializing into`Event` (attempting to deserialize into each variant until successful), a function named `model::event::deserialize_event_with_type` is provided for quickly deserializing into a known type if the dispatch type is known.
* Re-order use statements alphabeticallyZeyla Hellyer2017-11-113-4/+4
|
* Add Debug derives to more public typesthelearnerofcode2017-11-071-0/+1
|
* Fix some compilation feature targets, fix lintsZeyla Hellyer2017-10-171-0/+1
|
* Update to account for changes made in 0.4.1acdenisSK2017-10-142-2/+9
|\
| * Add try_opt macro for substituteMei Boudreau2017-10-121-0/+7
| |
| * Fix clippy lintsZeyla Hellyer2017-10-111-2/+2
| |
* | Switch to parking_lot::{Mutex, RwLock}Zeyla Hellyer2017-10-101-0/+13
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 shard managerZeyla Hellyer2017-09-241-16/+7
| | | | The shard manager will queue up shards for booting.
* Apply rustfmtZeyla Hellyer2017-09-181-4/+4
|
* Fix compiles of a variety of feature combinationsZeyla Hellyer2017-09-181-6/+11
| | | | | This fixes compilation errors and warnings when compiling a mixture of non-default feature targets.
* Add ability to play DCA and Opus files. (#148)Maiddog2017-08-271-4/+4
|
* Revamp `RwLock` usage in the libacdenisSK2017-08-243-4/+26
| | | | Also not quite sure if they goofed rustfmt or something, but its changes it did were a bit bizarre.
* Fix rustfmt lines that are too longZeyla Hellyer2017-08-181-1/+2
| | | | | Apparently rustfmt can't fix some of these, causing it to exit with 3 and therefore failing the build.
* Apply rustfmtZeyla Hellyer2017-08-181-2/+3
|
* Clippy and rustfmtacdenisSK2017-08-011-1/+1
|
* Handle the `None`s betteracdenisSK2017-07-301-3/+8
|
* Remove a few clonesacdenisSK2017-07-291-6/+7
|
* Change the config a bit, and a few nitpicksacdenisSK2017-07-271-5/+2
|
* rustfmtacdenisSK2017-07-275-23/+23
|
* Use a consistent indentation styleZeyla Hellyer2017-07-261-8/+8
| | | | | | | | | This project has - in the past - used an indentation style of 4 spaces, without trailing whitespace. This commit modifies lines with tab indentation to 4 spaces. Whether to use tabs or spaces is up to the current maintainer, but consistency avoids files eventually being completely mixed styles.
* Revert the ignoring of protocol and data frame errors, while actually ↵acdenisSK2017-07-241-12/+16
| | | | | | handling ping pongs When receiving pings, serenity MUST send the pong with the same data as the ping. Well, as said in the rfc for websockets anyway. Though, regarding the errors, i found out that serenity's gateway wouldn't work, but i do see that i'll have to file an issue to see if they know why are these happening at all
* Update dependenciesZeyla Hellyer2017-06-211-6/+6
|
* Upgrade rust-websocket, rust-openssl, and hyperZeyla Hellyer2017-06-072-35/+51
| | | | | | | | | | | | | | | | 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.
* Use chrono for struct timestamp fieldsZeyla Hellyer2017-06-061-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove unused internal macroZeyla Hellyer2017-05-241-9/+0
| | | | | The `base!` macro providing the base URI for discordapp is no longer in use and can be safely removed.
* Restructure modulesZeyla Hellyer2017-05-224-2/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Switch to using serde for deserializationZeyla Hellyer2017-04-111-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* (╯°□°)╯︵ ┻━┻Austin Hellyer2016-12-191-1/+1
|
* More config for CreateCommand, add various methodsIllia2016-12-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Adds multiple configurations to the command builder, and adds methods to various structs. Context::get_current_user is a shortcut to retrieve the current user from the cache. Message::get_member retrieves the member object of the message, if sent in a guild. Message::is_private checks if the message was sent in a Group or PrivateChannel. User::member retrieves the user's member object in a guild by Id; Adds 6 configurations to the command builder: - dm_only: whether the command can only be used in direct messages; - guild_only: whether the command can only be used in guilds; - help_available: whether the command should be displayed in the help list; - max_args: specify the maximum number of arguments a command must be given; - min_args: specify the minimum number of arguments a command must be given; - required_permissions: the permissions a member must have to be able to use the command;
* Change all try's into ?sacdenisSK2016-12-071-3/+3
| | | This breaks compatibility with < 1.13, but we didn't support that anyway.
* Clean up the codebaseAustin Hellyer2016-11-291-12/+13
|
* Re-organize the client moduleAustin Hellyer2016-11-211-5/+4
| | | | | | | | | | | | | | | | | | Re-organize the client module, creating a `gateway` submodule, and splitting the connection into separate files in it. The connection was a conglomeration of a number of purposes, most of which are actually used elsewhere in the library and/or exposed to the user. Thus, it makes sense to separate each item in a gateway-specific module. By splitting the client module further, this is a re-organization for preliminary RPC support WRT the Client. Additionally, rename the Connection struct to a Shard. The Connection itself was not the actual connection, and was a higher-level interface to the real connection logic. A Shard is a more accurate representation of what it actually is.
* Add voice connection supportAustin Hellyer2016-11-143-0/+112
|
* Add internal moduleAustin Hellyer2016-11-142-0/+10
Create a general `internal` module, and move `prelude_internal` to `internal::prelude`.