mirror of
https://github.com/ahabhyde/miguelbridge
synced 2025-01-10 06:24:20 +01:00
Aumentato sleep time delle richieste, disattivato stickers
This commit is contained in:
parent
ff563363da
commit
9a27f18ca8
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/cwebp
Executable file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/cwebp
Executable file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/dwebp
Executable file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/dwebp
Executable file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/gif2webp
Executable file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/gif2webp
Executable file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/vwebp
Executable file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/vwebp
Executable file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/webpmux
Executable file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/bin/webpmux
Executable file
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
<!-- Creator : groff version 1.21 -->
|
<!-- Creator : groff version 1.21 -->
|
||||||
<!-- CreationDate: Mon Jul 28 19:46:48 2014 -->
|
<!-- CreationDate: Mon Jul 28 19:47:26 2014 -->
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Creator : groff version 1.21 -->
|
<!-- Creator : groff version 1.21 -->
|
||||||
<!-- CreationDate: Mon Jul 28 19:46:48 2014 -->
|
<!-- CreationDate: Mon Jul 28 19:47:26 2014 -->
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Creator : groff version 1.21 -->
|
<!-- Creator : groff version 1.21 -->
|
||||||
<!-- CreationDate: Mon Jul 28 19:46:48 2014 -->
|
<!-- CreationDate: Mon Jul 28 19:47:27 2014 -->
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Creator : groff version 1.21 -->
|
<!-- Creator : groff version 1.21 -->
|
||||||
<!-- CreationDate: Mon Jul 28 19:46:48 2014 -->
|
<!-- CreationDate: Mon Jul 28 19:47:26 2014 -->
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
@ -1,5 +1,5 @@
|
|||||||
<!-- Creator : groff version 1.21 -->
|
<!-- Creator : groff version 1.21 -->
|
||||||
<!-- CreationDate: Mon Jul 28 19:46:49 2014 -->
|
<!-- CreationDate: Mon Jul 28 19:47:27 2014 -->
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||||
"http://www.w3.org/TR/html4/loose.dtd">
|
"http://www.w3.org/TR/html4/loose.dtd">
|
||||||
<html>
|
<html>
|
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebp.a
Normal file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebp.a
Normal file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebpdemux.a
Normal file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebpdemux.a
Normal file
Binary file not shown.
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebpmux.a
Normal file
BIN
WebPConverter/libwebp-0.4.1-linux-x86-32/lib/libwebpmux.a
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -26,6 +26,7 @@ import org.telegram.telegrambots.TelegramBotsApi;
|
|||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public final static String fileSettings = "files/botsettings.json";
|
public final static String fileSettings = "files/botsettings.json";
|
||||||
|
private final static int sleepTime = 750;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// Inizializza il context delle API Telegram (richiesto)
|
// Inizializza il context delle API Telegram (richiesto)
|
||||||
@ -64,7 +65,7 @@ public class Launcher {
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
//Main loop del bot di matrix
|
//Main loop del bot di matrix
|
||||||
Thread.sleep(500);
|
Thread.sleep(sleepTime);
|
||||||
rooms = getRooms();
|
rooms = getRooms();
|
||||||
for (int roomNumber=0; roomNumber<rooms.size(); roomNumber++) {
|
for (int roomNumber=0; roomNumber<rooms.size(); roomNumber++) {
|
||||||
JSONObject room = (JSONObject) rooms.get(roomNumber);
|
JSONObject room = (JSONObject) rooms.get(roomNumber);
|
||||||
|
@ -70,6 +70,8 @@ public class TGBot extends TelegramLongPollingBot {
|
|||||||
if (destination == null)
|
if (destination == null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
matrixBot.sendMessage(sender + ":\n" + testoMessaggio, destination);
|
matrixBot.sendMessage(sender + ":\n" + testoMessaggio, destination);
|
||||||
|
} catch (IOException | ParseException ex) {
|
||||||
|
ex.printStackTrace(System.err);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
||||||
}
|
}
|
||||||
@ -122,9 +124,10 @@ public class TGBot extends TelegramLongPollingBot {
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
matrixBot.sendMessage(sender + " ha inviato una foto:", destination);
|
matrixBot.sendMessage(sender + " ha inviato una foto:", destination);
|
||||||
matrixBot.sendFile(destination, downloadedFile, null, "jpg");
|
matrixBot.sendFile(destination, downloadedFile, null, "jpg");
|
||||||
|
} catch (IOException | ParseException ex) {
|
||||||
|
ex.printStackTrace(System.err);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
||||||
ex.printStackTrace(System.err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,12 +170,14 @@ public class TGBot extends TelegramLongPollingBot {
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
matrixBot.sendMessage(sender + " ha inviato un file:", destination);
|
matrixBot.sendMessage(sender + " ha inviato un file:", destination);
|
||||||
matrixBot.sendFile(destination, downloadedFile, nomeFile, "file");
|
matrixBot.sendFile(destination, downloadedFile, nomeFile, "file");
|
||||||
|
} catch (IOException | ParseException ex) {
|
||||||
|
ex.printStackTrace(System.err);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
||||||
ex.printStackTrace(System.err);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
//Sticker
|
//Sticker
|
||||||
else if (update.hasMessage()) {
|
else if (update.hasMessage()) {
|
||||||
String chat_id = "" + update.getMessage().getChatId();
|
String chat_id = "" + update.getMessage().getChatId();
|
||||||
@ -205,7 +210,7 @@ public class TGBot extends TelegramLongPollingBot {
|
|||||||
// Download the file calling AbsSender::downloadFile method
|
// Download the file calling AbsSender::downloadFile method
|
||||||
downloadedFile = downloadFile(filePath);
|
downloadedFile = downloadFile(filePath);
|
||||||
|
|
||||||
if (WebPConverter.convert(downloadedFile.getAbsolutePath(), nomeFile) == 0) {
|
if (WebPConverter.convert(downloadedFile.getAbsolutePath(), "./" + nomeFile, false) == 0) {
|
||||||
System.out.println("Done converting");
|
System.out.println("Done converting");
|
||||||
convertedImage = new File(nomeFile);
|
convertedImage = new File(nomeFile);
|
||||||
}
|
}
|
||||||
@ -223,13 +228,15 @@ public class TGBot extends TelegramLongPollingBot {
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
matrixBot.sendMessage(sender + " ha inviato uno sticker " + sticker.getEmoji() + ":", destination);
|
matrixBot.sendMessage(sender + " ha inviato uno sticker " + sticker.getEmoji() + ":", destination);
|
||||||
matrixBot.sendFile(destination, convertedImage, nomeFile, "png");
|
matrixBot.sendFile(destination, convertedImage, nomeFile, "png");
|
||||||
convertedImage.delete();
|
//convertedImage.delete();
|
||||||
|
} catch (IOException | ParseException ex) {
|
||||||
|
ex.printStackTrace(System.err);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
|
||||||
ex.printStackTrace(System.err);
|
//convertedImage.delete();
|
||||||
convertedImage.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,15 +3,25 @@ package com.em.miguelbridge.telegrambot;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class WebPConverter {
|
public class WebPConverter {
|
||||||
public static int convert(String iPath, String oPath) {
|
public static int convert(String iPath, String oPath, boolean macOS) {
|
||||||
|
String binPath;
|
||||||
//the "dwebp"'s path
|
//the "dwebp"'s path
|
||||||
String binPath = "WebPConverter/libwebp-0.4.1-linux-x86-64/bin/dwebp";
|
if (macOS)
|
||||||
|
binPath = "WebPConverter/libwebp-0.4.1-mac-10.8/bin/dwebp";
|
||||||
|
else
|
||||||
|
binPath = "~/WebPConverter/libwebp-0.4.1-linux-x86-32/bin/dwebp";
|
||||||
|
|
||||||
String[] args = new String[]{binPath, iPath, "-o", oPath};
|
String[] args = new String[]{binPath, iPath, "-o", oPath};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(args);
|
//Runtime.getRuntime().exec(args);
|
||||||
} catch (IOException e) {
|
ProcessBuilder pb = new ProcessBuilder(new String[]{
|
||||||
|
"/bin/sh",
|
||||||
|
"-c",
|
||||||
|
String.format("%s %s -o %s", binPath, iPath, oPath)
|
||||||
|
});
|
||||||
|
pb.start().waitFor();
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3,11 +3,12 @@ package test;
|
|||||||
import com.em.miguelbridge.telegrambot.WebPConverter;
|
import com.em.miguelbridge.telegrambot.WebPConverter;
|
||||||
|
|
||||||
public class WebPTest {
|
public class WebPTest {
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) throws InterruptedException {
|
||||||
String iFile = "sticker.webp";
|
String iFile = "sticker.webp";
|
||||||
String oFile = "sticker.png";
|
String oFile = "sticker.png";
|
||||||
|
|
||||||
if (WebPConverter.convert(iFile, oFile) == 0)
|
|
||||||
|
if (WebPConverter.convert(iFile, oFile, true) == 0)
|
||||||
System.out.println("Done");
|
System.out.println("Done");
|
||||||
else
|
else
|
||||||
System.err.println("Error");
|
System.err.println("Error");
|
||||||
|
Loading…
Reference in New Issue
Block a user