1
1
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:
Ahab Hyde 2018-07-16 17:12:25 +02:00
parent ff563363da
commit 9a27f18ca8
38 changed files with 37 additions and 18 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,5 +1,5 @@
<!-- 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

View File

@ -1,5 +1,5 @@
<!-- 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

View File

@ -1,5 +1,5 @@
<!-- 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

View File

@ -1,5 +1,5 @@
<!-- 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

View File

@ -1,5 +1,5 @@
<!-- 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"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

Binary file not shown.

View File

@ -26,6 +26,7 @@ import org.telegram.telegrambots.TelegramBotsApi;
*/
public class Launcher {
public final static String fileSettings = "files/botsettings.json";
private final static int sleepTime = 750;
public static void main(String[] args) {
// Inizializza il context delle API Telegram (richiesto)
@ -64,7 +65,7 @@ public class Launcher {
while (true) {
//Main loop del bot di matrix
Thread.sleep(500);
Thread.sleep(sleepTime);
rooms = getRooms();
for (int roomNumber=0; roomNumber<rooms.size(); roomNumber++) {
JSONObject room = (JSONObject) rooms.get(roomNumber);

View File

@ -70,6 +70,8 @@ public class TGBot extends TelegramLongPollingBot {
if (destination == null)
throw new Exception();
matrixBot.sendMessage(sender + ":\n" + testoMessaggio, destination);
} catch (IOException | ParseException ex) {
ex.printStackTrace(System.err);
} catch (Exception ex) {
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
}
@ -122,9 +124,10 @@ public class TGBot extends TelegramLongPollingBot {
throw new Exception();
matrixBot.sendMessage(sender + " ha inviato una foto:", destination);
matrixBot.sendFile(destination, downloadedFile, null, "jpg");
} catch (IOException | ParseException ex) {
ex.printStackTrace(System.err);
} catch (Exception ex) {
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();
matrixBot.sendMessage(sender + " ha inviato un file:", destination);
matrixBot.sendFile(destination, downloadedFile, nomeFile, "file");
} catch (IOException | ParseException ex) {
ex.printStackTrace(System.err);
} catch (Exception ex) {
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
ex.printStackTrace(System.err);
}
}
/*
//Sticker
else if (update.hasMessage()) {
String chat_id = "" + update.getMessage().getChatId();
@ -205,7 +210,7 @@ public class TGBot extends TelegramLongPollingBot {
// Download the file calling AbsSender::downloadFile method
downloadedFile = downloadFile(filePath);
if (WebPConverter.convert(downloadedFile.getAbsolutePath(), nomeFile) == 0) {
if (WebPConverter.convert(downloadedFile.getAbsolutePath(), "./" + nomeFile, false) == 0) {
System.out.println("Done converting");
convertedImage = new File(nomeFile);
}
@ -223,13 +228,15 @@ public class TGBot extends TelegramLongPollingBot {
throw new Exception();
matrixBot.sendMessage(sender + " ha inviato uno sticker " + sticker.getEmoji() + ":", destination);
matrixBot.sendFile(destination, convertedImage, nomeFile, "png");
convertedImage.delete();
//convertedImage.delete();
} catch (IOException | ParseException ex) {
ex.printStackTrace(System.err);
} catch (Exception ex) {
cEcho(chat_id, "Errore: questa chat non è collegata a matrix.");
ex.printStackTrace(System.err);
convertedImage.delete();
//convertedImage.delete();
}
}
*/
}
@Override

View File

@ -3,15 +3,25 @@ package com.em.miguelbridge.telegrambot;
import java.io.IOException;
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
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};
try {
Runtime.getRuntime().exec(args);
} catch (IOException e) {
//Runtime.getRuntime().exec(args);
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
e.printStackTrace(System.err);
return 1;

View File

@ -3,11 +3,12 @@ package test;
import com.em.miguelbridge.telegrambot.WebPConverter;
public class WebPTest {
public static void main(String args[]) {
public static void main(String args[]) throws InterruptedException {
String iFile = "sticker.webp";
String oFile = "sticker.png";
if (WebPConverter.convert(iFile, oFile) == 0)
if (WebPConverter.convert(iFile, oFile, true) == 0)
System.out.println("Done");
else
System.err.println("Error");