Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79943efdf7 | ||
|
|
bd987bf72a | ||
|
|
abe3cf87a1 |
@@ -1,4 +1,3 @@
|
||||
|
||||
*️⃣
|
||||
0️⃣
|
||||
1️⃣
|
||||
@@ -242,6 +241,7 @@
|
||||
🆘
|
||||
🆙
|
||||
🆚
|
||||
🇦
|
||||
🇦🇨
|
||||
🇦🇩
|
||||
🇦🇪
|
||||
@@ -259,6 +259,7 @@
|
||||
🇦🇼
|
||||
🇦🇽
|
||||
🇦🇿
|
||||
🇧
|
||||
🇧🇦
|
||||
🇧🇧
|
||||
🇧🇩
|
||||
@@ -280,6 +281,7 @@
|
||||
🇧🇼
|
||||
🇧🇾
|
||||
🇧🇿
|
||||
🇨
|
||||
🇨🇦
|
||||
🇨🇨
|
||||
🇨🇩
|
||||
@@ -301,6 +303,7 @@
|
||||
🇨🇽
|
||||
🇨🇾
|
||||
🇨🇿
|
||||
🇩
|
||||
🇩🇪
|
||||
🇩🇬
|
||||
🇩🇯
|
||||
@@ -308,6 +311,7 @@
|
||||
🇩🇲
|
||||
🇩🇴
|
||||
🇩🇿
|
||||
🇪
|
||||
🇪🇦
|
||||
🇪🇨
|
||||
🇪🇪
|
||||
@@ -317,12 +321,14 @@
|
||||
🇪🇸
|
||||
🇪🇹
|
||||
🇪🇺
|
||||
🇫
|
||||
🇫🇮
|
||||
🇫🇯
|
||||
🇫🇰
|
||||
🇫🇲
|
||||
🇫🇴
|
||||
🇫🇷
|
||||
🇬
|
||||
🇬🇦
|
||||
🇬🇧
|
||||
🇬🇩
|
||||
@@ -342,12 +348,14 @@
|
||||
🇬🇺
|
||||
🇬🇼
|
||||
🇬🇾
|
||||
🇭
|
||||
🇭🇰
|
||||
🇭🇲
|
||||
🇭🇳
|
||||
🇭🇷
|
||||
🇭🇹
|
||||
🇭🇺
|
||||
🇮
|
||||
🇮🇨
|
||||
🇮🇩
|
||||
🇮🇪
|
||||
@@ -359,10 +367,12 @@
|
||||
🇮🇷
|
||||
🇮🇸
|
||||
🇮🇹
|
||||
🇯
|
||||
🇯🇪
|
||||
🇯🇲
|
||||
🇯🇴
|
||||
🇯🇵
|
||||
🇰
|
||||
🇰🇪
|
||||
🇰🇬
|
||||
🇰🇭
|
||||
@@ -374,6 +384,7 @@
|
||||
🇰🇼
|
||||
🇰🇾
|
||||
🇰🇿
|
||||
🇱
|
||||
🇱🇦
|
||||
🇱🇧
|
||||
🇱🇨
|
||||
@@ -385,6 +396,7 @@
|
||||
🇱🇺
|
||||
🇱🇻
|
||||
🇱🇾
|
||||
🇲
|
||||
🇲🇦
|
||||
🇲🇨
|
||||
🇲🇩
|
||||
@@ -408,6 +420,7 @@
|
||||
🇲🇽
|
||||
🇲🇾
|
||||
🇲🇿
|
||||
🇳
|
||||
🇳🇦
|
||||
🇳🇨
|
||||
🇳🇪
|
||||
@@ -420,7 +433,9 @@
|
||||
🇳🇷
|
||||
🇳🇺
|
||||
🇳🇿
|
||||
🇴
|
||||
🇴🇲
|
||||
🇵
|
||||
🇵🇦
|
||||
🇵🇪
|
||||
🇵🇫
|
||||
@@ -435,12 +450,15 @@
|
||||
🇵🇹
|
||||
🇵🇼
|
||||
🇵🇾
|
||||
🇶
|
||||
🇶🇦
|
||||
🇷
|
||||
🇷🇪
|
||||
🇷🇴
|
||||
🇷🇸
|
||||
🇷🇺
|
||||
🇷🇼
|
||||
🇸
|
||||
🇸🇦
|
||||
🇸🇧
|
||||
🇸🇨
|
||||
@@ -462,6 +480,7 @@
|
||||
🇸🇽
|
||||
🇸🇾
|
||||
🇸🇿
|
||||
🇹
|
||||
🇹🇦
|
||||
🇹🇨
|
||||
🇹🇩
|
||||
@@ -479,6 +498,7 @@
|
||||
🇹🇻
|
||||
🇹🇼
|
||||
🇹🇿
|
||||
🇺
|
||||
🇺🇦
|
||||
🇺🇬
|
||||
🇺🇲
|
||||
@@ -486,6 +506,7 @@
|
||||
🇺🇸
|
||||
🇺🇾
|
||||
🇺🇿
|
||||
🇻
|
||||
🇻🇦
|
||||
🇻🇨
|
||||
🇻🇪
|
||||
@@ -493,11 +514,15 @@
|
||||
🇻🇮
|
||||
🇻🇳
|
||||
🇻🇺
|
||||
🇼
|
||||
🇼🇫
|
||||
🇼🇸
|
||||
🇽
|
||||
🇽🇰
|
||||
🇾
|
||||
🇾🇪
|
||||
🇾🇹
|
||||
🇿
|
||||
🇿🇦
|
||||
🇿🇲
|
||||
🇿🇼
|
||||
|
||||
@@ -219,7 +219,7 @@ impl MessageFlagsValue {
|
||||
self.has_value(flag as u32)
|
||||
}
|
||||
pub fn has_value(&self, bit: u32) -> bool {
|
||||
let mask = 1 << bit;
|
||||
let mask = 1 << (bit - 1);
|
||||
self.0 & mask == mask
|
||||
}
|
||||
|
||||
@@ -227,10 +227,11 @@ impl MessageFlagsValue {
|
||||
self.set_value(flag as u32, toggle)
|
||||
}
|
||||
pub fn set_value(&mut self, bit: u32, toggle: bool) -> &mut Self {
|
||||
let mask = 1 << (bit - 1);
|
||||
if toggle {
|
||||
self.0 |= 1 << bit;
|
||||
self.0 |= mask;
|
||||
} else {
|
||||
self.0 &= !(1 << bit);
|
||||
self.0 &= !mask;
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ use tokio::sync::RwLock;
|
||||
|
||||
pub mod types;
|
||||
|
||||
const TENOR_API_BASE_URL: &str = "https://compat.gifbox.me/v2";
|
||||
const TENOR_API_BASE_URL: &str = "https://tenor.googleapis.com/v2";
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum TenorError {
|
||||
@@ -59,11 +59,7 @@ impl Tenor {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn request<T: DeserializeOwned>(
|
||||
&self,
|
||||
path: &str,
|
||||
query: &[Option<(&str, &str)>],
|
||||
) -> Result<Arc<T>, TenorError> {
|
||||
pub async fn request<T: DeserializeOwned>(&self, path: &str, query: &[Option<(&str, &str)>]) -> Result<Arc<T>, TenorError> {
|
||||
let response = self
|
||||
.client
|
||||
.get(format!("{TENOR_API_BASE_URL}{path}"))
|
||||
@@ -99,27 +95,24 @@ impl Tenor {
|
||||
}
|
||||
}
|
||||
|
||||
let res = self
|
||||
.coalescion
|
||||
.execute(unique_key.clone(), || async move {
|
||||
self.request::<types::PaginatedMediaResponse>(
|
||||
"/search",
|
||||
&[
|
||||
Some(("key", &self.key)),
|
||||
Some(("q", query)),
|
||||
Some(("client_key", "Gifbox")),
|
||||
Some(("media_filter", "webm,tinywebm")),
|
||||
Some(("locale", locale)),
|
||||
Some(("contentfilter", "high")),
|
||||
Some(("limit", &limit.to_string())),
|
||||
position.is_empty().then_some(("pos", position)),
|
||||
is_category.then_some(("component", "categories")),
|
||||
],
|
||||
)
|
||||
.await
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let res = self.coalescion.execute(unique_key.clone(), || async move {
|
||||
self.request::<types::PaginatedMediaResponse>(
|
||||
"/search",
|
||||
&[
|
||||
Some(("key", &self.key)),
|
||||
Some(("q", query)),
|
||||
Some(("client_key", "Gifbox")),
|
||||
Some(("media_filter", "webm,tinywebm")),
|
||||
Some(("locale", locale)),
|
||||
Some(("contentfilter", "high")),
|
||||
Some(("limit", &limit.to_string())),
|
||||
position.is_empty().then_some(("pos", position)),
|
||||
is_category.then_some(("component", "categories"))
|
||||
]
|
||||
).await
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if let Ok(resp) = &*res {
|
||||
self.cache.write().await.insert(unique_key, resp.clone());
|
||||
@@ -150,9 +143,8 @@ impl Tenor {
|
||||
Some(("client_key", "Gifbox")),
|
||||
Some(("locale", locale)),
|
||||
Some(("contentfilter", "high")),
|
||||
],
|
||||
)
|
||||
.await
|
||||
]
|
||||
).await
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -181,25 +173,22 @@ impl Tenor {
|
||||
}
|
||||
}
|
||||
|
||||
let res = self
|
||||
.coalescion
|
||||
.execute(unique_key.clone(), || async move {
|
||||
self.request::<types::PaginatedMediaResponse>(
|
||||
"/featured",
|
||||
&[
|
||||
Some(("key", &self.key)),
|
||||
Some(("client_key", "Gifbox")),
|
||||
Some(("media_filter", "webm,tinywebm")),
|
||||
Some(("locale", locale)),
|
||||
Some(("contentfilter", "high")),
|
||||
Some(("limit", &limit.to_string())),
|
||||
position.is_empty().then_some(("pos", position)),
|
||||
],
|
||||
)
|
||||
.await
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let res = self.coalescion.execute(unique_key.clone(), || async move {
|
||||
self.request::<types::PaginatedMediaResponse>(
|
||||
"/featured",
|
||||
&[
|
||||
Some(("key", &self.key)),
|
||||
Some(("client_key", "Gifbox")),
|
||||
Some(("media_filter", "webm,tinywebm")),
|
||||
Some(("locale", locale)),
|
||||
Some(("contentfilter", "high")),
|
||||
Some(("limit", &limit.to_string())),
|
||||
position.is_empty().then_some(("pos", position)),
|
||||
]
|
||||
).await
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
if let Ok(resp) = &*res {
|
||||
self.featured.write().await.insert(unique_key, resp.clone());
|
||||
|
||||
Reference in New Issue
Block a user