-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
134 changed files
with
193,448 additions
and
655 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,3 @@ | ||
[package] | ||
name = "rain-bot" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serenity = { git = "https://github.com/serenity-rs/serenity", branch = "next", default-features = false, features = ["client", "gateway", "rustls_backend", "model","collector"] } | ||
hertz = { path = "hertz" } | ||
tokio = { version = "1.0", features = ["full"] } | ||
reqwest = { version = "0.11", features = ["json"] } | ||
sqlx = { version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres","chrono","macros"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
chrono = "0.4.23" | ||
bcrypt = "0.13" | ||
rand = "0.8.5" | ||
image = "0.24.5" | ||
imageproc = "0.23.0" | ||
rusttype = "0.9.3" | ||
lazy_static = "1.4.0" | ||
[workspace] | ||
members = ["discord","hertz","material","image-edit","binding"] | ||
resolver = "2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "binding" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
chrono = "0.4.31" | ||
material = { version = "0.1.0", path = "../material" } | ||
serde = { version = "1.0.193", features = ["derive"] } | ||
serde_json = "1.0.108" | ||
sqlx = { version = "0.7.3", features = ["postgres", "chrono", "runtime-tokio-native-tls"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use super::{Bitwise,BitwiseError,ItemCode}; | ||
use material::ItemPedia; | ||
|
||
impl ItemCode{ | ||
pub fn reverse_key(&self)->Result<String, BitwiseError>{ | ||
if self.key.len()!=4{ | ||
Err(BitwiseError::InvalidKey) | ||
}else { | ||
let key:Vec<_> = self.key.chars().collect(); | ||
Ok([key[2],key[3],key[0],key[1]].iter().collect::<String>()) | ||
} | ||
} | ||
pub fn text(&self,item:&ItemPedia)->Option<String>{ | ||
let item = item.dictionary(self.types, &self.key)?; | ||
Some(format!("{} x{}",item,self.count)) | ||
} | ||
pub fn check(&self,item:&ItemPedia)->bool{ | ||
item.dictionary(self.types, &self.key).is_some() | ||
} | ||
} | ||
impl<'a> Default for Bitwise<'a> { | ||
fn default() -> Bitwise<'a> { | ||
Bitwise { item: &[] } | ||
} | ||
} | ||
impl<'a> Bitwise<'a> { | ||
pub fn new(data:&'a [ItemCode])->Bitwise<'a>{ | ||
Bitwise { item: data } | ||
} | ||
fn no_item(&self)->Result<(),BitwiseError>{ | ||
if self.item.len() == 0{ | ||
Err(BitwiseError::NoItem) | ||
}else { | ||
Ok(()) | ||
} | ||
} | ||
pub fn multiple_item(&self)->Result<Vec<u8>,BitwiseError>{ | ||
self.no_item()?; | ||
let mut data = format!("{:04X}",self.item.len()); | ||
for code in self.item{ | ||
data.push_str(&format!("{:02X}0000{}0000{:04X}00000000", | ||
code.types,code.reverse_key()?,code.count)); | ||
} | ||
Bitwise::decode(&data) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
use serde::{Serialize,Deserialize}; | ||
use crate::bitwise::ItemCode; | ||
|
||
|
||
#[derive(PartialEq, Eq,Clone,Hash)] | ||
pub enum Category{ | ||
Bronze, | ||
Silver, | ||
Gold, | ||
Free, | ||
Event, | ||
Custom | ||
} | ||
|
||
#[derive(Clone,Serialize,Deserialize)] | ||
#[serde(rename_all="snake_case")] | ||
pub enum Methode{ | ||
Solo, | ||
Multi | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Title{ | ||
pub bounty_bronze:bool, | ||
pub bounty_silver:bool, | ||
pub bounty_gold:bool, | ||
pub trade_bronze:bool, | ||
pub trade_silver:bool, | ||
pub trade_gold:bool, | ||
} | ||
|
||
#[derive(PartialEq, Eq,Clone,Hash,Serialize,Deserialize)] | ||
pub enum BBQ{ | ||
BBQ01, | ||
BBQ02, | ||
BBQ03, | ||
BBQ04, | ||
BBQ05, | ||
BBQ06, | ||
BBQ07, | ||
BBQ08, | ||
BBQ09, | ||
BBQ10, | ||
BBQ11, | ||
BBQ12, | ||
BBQ13, | ||
BBQ14, | ||
BBQ15, | ||
BBQ16, | ||
BBQ17, | ||
BBQ18, | ||
BBQ19, | ||
BBQ20, | ||
BBQ21, | ||
BBQ22, | ||
BBQ23, | ||
BBQ24, | ||
BBQ25, | ||
} | ||
|
||
#[derive(Serialize,Deserialize,PartialEq, Eq,Clone,Debug)] | ||
pub struct BountyReward{ | ||
coin:u32, | ||
ticket:u32, | ||
items:Vec<ItemCode> | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Hunter{ | ||
pub member:String, | ||
pub title:Title, | ||
pub event:Event, | ||
} | ||
#[derive(Clone)] | ||
pub struct BountySubmit{ | ||
pub method:Methode, | ||
pub category:Category, | ||
pub bbq:BBQ, | ||
pub hunter:Vec<Hunter>, | ||
pub url:String, | ||
pub thumb:String, | ||
pub time:i64, | ||
pub reward:BountyReward | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod bitwise; | ||
pub mod bounty; | ||
pub mod postgres; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use sqlx::{Pool, Postgres, postgres::PgPoolOptions}; | ||
use serde::{Serialize,Deserialize}; | ||
use sqlx::Result; | ||
|
||
pub mod card; | ||
pub mod account; | ||
pub mod server; | ||
pub mod gacha; | ||
pub mod custom; | ||
pub mod guild; | ||
|
||
|
||
#[derive(Debug)] | ||
pub enum PgCustomError{ | ||
Sqlx(sqlx::error::Error), | ||
Custom(String) | ||
} | ||
|
||
impl std::error::Error for PgCustomError {} | ||
|
||
impl std::fmt::Display for PgCustomError { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::Sqlx(x) => x.fmt(f), | ||
Self::Custom(x) => x.fmt(f) | ||
} | ||
} | ||
} | ||
|
||
impl From<sqlx::error::Error> for PgCustomError { | ||
fn from(value: sqlx::error::Error) -> Self { | ||
Self::Sqlx(value) | ||
} | ||
} | ||
|
||
impl From<&str> for PgCustomError { | ||
fn from(value: &str) -> Self { | ||
Self::Custom(value.to_owned()) | ||
} | ||
} | ||
|
||
|
||
|
||
#[derive(Serialize,Deserialize,Clone,Debug)] | ||
pub struct DbConf{ | ||
user:String, | ||
password:String, | ||
host:String, | ||
port:u16, | ||
database:String | ||
} | ||
|
||
|
||
#[derive(Clone,Debug)] | ||
pub struct Db(Pool<Postgres>); | ||
|
||
impl std::ops::Deref for Db { | ||
type Target = Pool<Postgres>; | ||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl Db { | ||
pub async fn connect(conf:&DbConf)->Result<Self> { | ||
let url = format!("postgres://{}:{}@{}:{}/{}", | ||
conf.user, | ||
conf.password, | ||
conf.host, | ||
conf.port, | ||
conf.database); | ||
let pool = PgPoolOptions::new() | ||
.max_connections(100) | ||
.connect(url.as_str()).await?; | ||
Ok(Self(pool)) | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "rain-bot" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model","collector"] } | ||
hertz = { path = "../hertz" } | ||
tokio = { version = "1.0", features = ["full"] } | ||
reqwest = { version = "0.11", features = ["json"] } | ||
sqlx = { version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres","chrono","macros"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
chrono = "0.4.23" | ||
bcrypt = "0.13" | ||
rand = "0.8.5" | ||
image = "0.24.5" | ||
imageproc = "0.23.0" | ||
rusttype = "0.9.3" | ||
lazy_static = "1.4.0" |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
455622761168109569_rengokudata.bin, |
Binary file not shown.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use std::num::ParseIntError; | ||
use std::fmt; | ||
use serde::{Serialize,Deserialize}; | ||
|
||
pub mod distribution; | ||
|
||
#[derive(Debug,Serialize,Deserialize,Clone,PartialEq,Eq)] | ||
pub struct ItemCode { | ||
pub key: String, | ||
pub count: u16, | ||
pub types: u8, | ||
} | ||
impl Default for ItemCode { | ||
fn default() -> Self { | ||
ItemCode { key: "0700".to_string(), count: 1, types: 7 } | ||
} | ||
} | ||
|
||
//create own error enum | ||
#[derive(Debug)] | ||
pub enum BitwiseError { | ||
OddLength, | ||
InvalidKey, | ||
NoItem, | ||
ParseInt(ParseIntError), | ||
Sqlx(sqlx::Error), | ||
} | ||
|
||
impl fmt::Display for BitwiseError { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
BitwiseError::OddLength => "input string has an odd number of bytes".fmt(f), | ||
BitwiseError::InvalidKey => "the key for converting endian is invalid length".fmt(f), | ||
BitwiseError::NoItem => "no item on the selected data".fmt(f), | ||
BitwiseError::ParseInt(e) => e.fmt(f), | ||
BitwiseError::Sqlx(e)=>e.fmt(f) | ||
} | ||
} | ||
} | ||
impl std::error::Error for BitwiseError {} | ||
|
||
//implement parser for error | ||
impl From<ParseIntError> for BitwiseError { | ||
fn from(e: ParseIntError) -> Self { | ||
BitwiseError::ParseInt(e) | ||
} | ||
} | ||
impl From<sqlx::Error> for BitwiseError{ | ||
fn from(value: sqlx::Error) -> Self { | ||
BitwiseError::Sqlx(value) | ||
} | ||
} | ||
|
||
pub struct Bitwise<'a>{ | ||
item:&'a [ItemCode] | ||
} | ||
|
||
impl<'a> Bitwise<'a>{ | ||
pub fn decode(hex_value:&str)->Result<Vec<u8>,BitwiseError>{ | ||
if hex_value.len()%2 != 0{ | ||
return Err(BitwiseError::OddLength); | ||
} | ||
//pair it two then decode | ||
(0..hex_value.len()) | ||
.step_by(2) | ||
.map(|i| u8::from_str_radix(&hex_value[i..i + 2], 16).map_err(|e| e.into())) | ||
.collect() | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.