├── libs └── CQP.dll ├── Cargo.toml ├── com.github.res.pupurium_r.json ├── README.md └── src └── lib.rs /libs/CQP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evshiron/PupuriumR/HEAD/libs/CQP.dll -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | 3 | name = "pupurium_r" 4 | version = "0.1.0" 5 | authors = [ "evshiron", "doylecnn" ] 6 | links = "CQP" 7 | build = "build.rs" 8 | 9 | [dependencies] 10 | encoding = "*" 11 | 12 | [dependencies.cqpsdk] 13 | git = "https://github.com/evshiron/cqpsdk-rust" 14 | 15 | [lib] 16 | 17 | name = "pupurium_r" 18 | crate-type = [ "dylib" ] 19 | 20 | -------------------------------------------------------------------------------- /com.github.res.pupurium_r.json: -------------------------------------------------------------------------------- 1 | { 2 | "ret": 1, 3 | "appid": "com.github.res.pupurium_r", 4 | "name": "PupuriumR", 5 | "apiver": 9, 6 | "version": "0.1.0", 7 | "version_id": 1, 8 | "author": "evshiron, Diberium", 9 | "description": "The daughter of Diberium", 10 | "event": [ 11 | { 12 | "id": 1, 13 | "type": 21, 14 | "name": "PrivateMessageHandler", 15 | "function": "PrivateMessageHandler", 16 | "priority": 30000 17 | }, 18 | { 19 | "id": 2, 20 | "type": 2, 21 | "name": "GroupMessageHandler", 22 | "function": "GroupMessageHandler", 23 | "priority": 20000 24 | } 25 | ], 26 | "auth": [ 27 | 101, 28 | 106, 29 | ] 30 | 31 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PupuriumR 2 | 3 | An example project for CQP SDK for Rust. 4 | 5 | ## How To Build 6 | 7 | ```bash 8 | 9 | # First have your rustc and cargo in the PATH. 10 | 11 | # Build. 12 | ./build.bat 13 | 14 | # Done. 15 | 16 | 17 | ``` 18 | 19 | Then get your `.dll` and `.json` in `./dist/`. 20 | 21 | ## How To Deploy 22 | 23 | If you are in developer mode, simply put `.dll` and `.json` inside `$DIR_CQP/app/`. 24 | 25 | ## Documentation 26 | 27 | Currently there is no documentation, you might want to read the official [Developer Wiki](https://d.cqp.cc/) and the [Wiki](https://github.com/evshiron/PupuriumR/wiki/) for some information. 28 | 29 | ## The MIT License 30 | 31 | Copyright © 2015 evshiron 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 36 | 37 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | extern crate encoding; 3 | 4 | extern crate cqpsdk; 5 | 6 | use std::ffi::{ CString, CStr }; 7 | 8 | use encoding::{ Encoding, EncoderTrap, DecoderTrap }; 9 | use encoding::all::{ UTF_8, GBK }; 10 | 11 | use cqpsdk::cqpapi; 12 | 13 | // Some macros for convenience. 14 | // Should have been integrated in evshiron/cqpsdk-rust. 15 | // But just leave here for easy reading. 16 | 17 | macro_rules! gbk { 18 | 19 | ( $x: expr ) => (CString::new(GBK.encode($x, EncoderTrap::Ignore).unwrap()).unwrap().into_raw()); 20 | 21 | } 22 | 23 | macro_rules! utf8 { 24 | 25 | ( $x: expr ) => (&GBK.decode(CStr::from_ptr($x).to_bytes(), DecoderTrap::Ignore).unwrap()[..]); 26 | 27 | } 28 | 29 | static mut AUTH_CODE: i32 = 0; 30 | 31 | // https://github.com/rust-lang/rust/issues/17806 32 | 33 | #[export_name="\x01_AppInfo"] 34 | pub extern "stdcall" fn app_info() -> *const i8 { 35 | 36 | return gbk!("9,com.github.res.pupurium_r"); 37 | 38 | } 39 | 40 | #[export_name="\x01_Initialize"] 41 | pub extern "stdcall" fn initialize(AuthCode: i32) -> i32 { 42 | 43 | unsafe { 44 | 45 | AUTH_CODE = AuthCode; 46 | 47 | } 48 | 49 | return cqpapi::EVENT_IGNORE; 50 | 51 | } 52 | 53 | #[export_name="\x01_PrivateMessageHandler"] 54 | pub extern "stdcall" fn private_message_handler(subType: i32, sendTime: i32, qqNum: i64, msg: *const i8, font: i32) -> i32 { 55 | 56 | return cqpapi::EVENT_IGNORE; 57 | 58 | } 59 | 60 | #[export_name="\x01_GroupMessageHandler"] 61 | pub extern "stdcall" fn group_message_handler(subType: i32, sendTime: i32, groupNum: i64, qqNum: i64, anonymousName: *const i8, msg: *const i8, font: i32) -> i32 { 62 | 63 | return cqpapi::EVENT_IGNORE; 64 | 65 | } 66 | --------------------------------------------------------------------------------