mirror of https://github.com/PiyushXCoder/lupt.git
Migrated to new Tenor API
This commit is contained in:
parent
b92a889e3a
commit
ab3a31426d
17
src/main.rs
17
src/main.rs
|
|
@ -156,15 +156,24 @@ async fn gif(req: HttpRequest) -> Result<HttpResponse, Error> {
|
|||
let tenor_key = TENOR_API_KEY.read().unwrap();
|
||||
let key = match &*tenor_key {
|
||||
Some(a) => a.as_str(),
|
||||
None => "",
|
||||
None => panic!("No api key!"),
|
||||
};
|
||||
|
||||
let url = format!(
|
||||
"https://g.tenor.com/v1/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
let url = if name != "" {
|
||||
format!(
|
||||
"https://tenor.googleapis.com/v2/search?q={}&key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
name.replace(" ", "+"),
|
||||
key,
|
||||
pos
|
||||
);
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"https://tenor.googleapis.com/v2/featured?key={}&limit=20&media_filter=tinygif&pos={}",
|
||||
key,
|
||||
pos
|
||||
)
|
||||
};
|
||||
|
||||
let response = client
|
||||
.get(url)
|
||||
.header("User-Agent", "actix-web/3.0")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ if(!('WebSocket' in window || 'MozWebSocket' in window)) {
|
|||
socket.onopen = function(event) {
|
||||
var params = window.location.search;
|
||||
params = params.substr(1,params.length).split('&');
|
||||
|
||||
|
||||
if(params.length < 3) {
|
||||
State.hideProgress();
|
||||
return;
|
||||
|
|
@ -187,7 +187,7 @@ function connect_next() {
|
|||
socket.send(JSON.stringify({ cmd: 'randnext' }));
|
||||
}
|
||||
|
||||
function leave() {
|
||||
function leave() {
|
||||
if(actions.has_key('leave')) return;
|
||||
actions.clear();
|
||||
actions.add('leave', function() {
|
||||
|
|
@ -294,14 +294,14 @@ function refreshVayaktiList() {
|
|||
.append($('<td>').append(key)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function autosize(el){
|
||||
setTimeout(function(){
|
||||
el.style.cssText = 'height:auto; padding:0';
|
||||
el.style.cssText = 'height:' + el.scrollHeight + 'px';
|
||||
$('#reply_clip').css('bottom', (el.scrollHeight + 20) + 'px');
|
||||
$('#selected_clip').css('bottom', (el.scrollHeight + 30) + 'px');
|
||||
},0);
|
||||
},0);
|
||||
}
|
||||
|
||||
// Dialog
|
||||
|
|
@ -311,7 +311,7 @@ function dialog(prop, call) {
|
|||
$('#dialog_title').text(prop.title);
|
||||
$('#dialog_text').text(prop.text);
|
||||
$('#dialog_check_label').text(prop.checkLabel);
|
||||
|
||||
|
||||
if(prop.check) $('#dialog_checkbox').removeClass('is-hidden');
|
||||
else $('#dialog_checkbox').addClass('is-hidden');
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ function loadGif() {
|
|||
area.find('[name=more]').remove();
|
||||
positiongif = data.next;
|
||||
data.results.forEach(function(result) {
|
||||
var gif = result.media[0].tinygif.url;
|
||||
var gif = result.media_formats.tinygif.url;
|
||||
area.append($('<button>', {class: 'button', onclick: 'sendGif("'+encodeURI(gif)+'"); $("#gif_clip").addClass("is-hidden");'})
|
||||
.append($('<img>', {src: gif})));
|
||||
});
|
||||
|
|
@ -361,4 +361,4 @@ function sendGif(gif) {
|
|||
cmd: "img",
|
||||
src: gif
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue