2
0
telebot-reverser/config.js

109 lines
3.8 KiB
JavaScript
Raw Normal View History

2019-11-14 00:19:07 +01:00
const fs = require('fs');
const Markup = require('telegraf/markup');
const Extra = require('telegraf/extra');
const request = require('request');
const rev = require("./reverser.js");
2019-11-14 11:44:07 +01:00
const supported_mime = ['video/mp4','video/avi','video/mkv'];
2019-11-14 00:19:07 +01:00
//=== TOOL FUNCTIONS
var download = function(uri, filename, callback){
request(uri).on('error', function(err) {
throw err;
}).pipe(fs.createWriteStream(filename)).on('close', callback);
};
//=== MAIN MODULE CONFIG
module.exports = function(){
return {
name : "Reverser",
key : 'revrs',
version : 0.1,
requirements : {
gps: false,
},
text : [
{
trigger : ["/reverse"],
public : true,
desc : {
2019-11-14 00:19:36 +01:00
0: "Reverses a video/...",
1: "Inverse une video/...",
2019-11-14 00:19:07 +01:00
},
requirements : (bot,event,message)=>{
return new Promise((resolve, reject)=>{
if(message.reply_to_message){
return resolve(200);
}
return reject(430);
});
},
action : (bot,event,message)=>{
var id;
var vid = false;
if(message.reply_to_message.document){
id = message.reply_to_message.document.file_id;
if(message.reply_to_message.document.mime_type.indexOf('image')==0){
return;
}else if(message.reply_to_message.document.mime_type.indexOf('video')==0){
2019-11-14 11:44:07 +01:00
if(message.reply_to_message.document.mime_type == 'video/mp4'){
2019-11-14 00:19:07 +01:00
vid = "mp4";
2019-11-14 11:44:07 +01:00
}else if(message.reply_to_message.document.mime_type == 'video/avi'){
2019-11-14 00:19:07 +01:00
vid = "avi";
2019-11-14 11:44:07 +01:00
}else if(message.reply_to_message.document.mime_type == 'video/mkv'){
2019-11-14 00:19:07 +01:00
vid = "mkv";
}else{
2019-11-14 11:44:07 +01:00
console.log(message.reply_to_message.document);
2019-11-14 00:19:07 +01:00
return;
}
}else{
return;
}
}else if(message.reply_to_message.sticker){
id = message.reply_to_message.sticker.file_id;
2019-11-14 11:44:07 +01:00
console.log(message.reply_to_message.video);
2019-11-14 00:19:07 +01:00
return;
}else if(message.reply_to_message.video){
2019-11-14 11:44:07 +01:00
id = message.reply_to_message.video.file_id;
if(message.reply_to_message.video.mime_type == 'video/mp4'){
2019-11-14 00:19:07 +01:00
vid = "mp4";
2019-11-14 11:44:07 +01:00
}else if(message.reply_to_message.video.mime_type == 'video/avi'){
2019-11-14 00:19:07 +01:00
vid = "avi";
2019-11-14 11:44:07 +01:00
}else if(message.reply_to_message.video.mime_type == 'video/mkv'){
2019-11-14 00:19:07 +01:00
vid = "mkv";
}else{
2019-11-14 11:44:07 +01:00
console.log(message.reply_to_message.video);
2019-11-14 00:19:07 +01:00
return;
}
}else {
return;
}
if(!vid)
return;
return bot.telegram.getFileLink(id).then(link=>{
const file = "/tmp/"+id+"."+vid;
2019-11-14 00:37:04 +01:00
download(link,file,function(){
2019-11-14 00:19:07 +01:00
rev.reverse(file).then(res=>{
return event.replyWithVideo({source: res.path});
}).catch(err=>{bot.error(err)});
});
}).catch(err=>{bot.error(err)});
}
},
],
reply : [],
regex : [],
media : [],
callback : [],
inline : [],
new_member : (bot,event)=>{},
weburl : [],
2019-11-18 13:39:15 +01:00
cron : []
2019-11-14 00:19:07 +01:00
}
}