1
1
mirror of https://github.com/ahabhyde/miguelbridge synced 2025-01-25 05:24:19 +01:00

HomeServer in settings

This commit is contained in:
Ahab 2018-04-09 18:13:55 +02:00
parent c51262aa65
commit f5e4f582f8
2 changed files with 15 additions and 4 deletions

View File

@ -1,9 +1,8 @@
{
"tguser": "Telegram user name",
"matrixuser": "Matrix user name",
"tgtoken": "Token key given from BotFather",
"matrixpswd": "Matrix user password",
"matrixhomeserver": "Matrix home server url",
"matrixhomeserver": "https://homeserver.com/_matrix/client/r0",
"rooms": [{
"tgname": "Name of the room in Telegram",

View File

@ -27,8 +27,8 @@ public class MatrixBot {
this.accessToken = accessToken;
}
public MatrixBot() {
homeUrl = "https://maxwell.ydns.eu/_matrix/client/r0";
public MatrixBot() throws IOException, FileNotFoundException, ParseException {
homeUrl = getHomeServer();
}
public static String readBotUserName() throws FileNotFoundException, IOException, ParseException {
@ -55,6 +55,18 @@ public class MatrixBot {
return pswd;
}
public String getHomeServer() throws FileNotFoundException, IOException, ParseException {
FileReader file = new FileReader(Launcher.fileSettings);
BufferedReader in = new BufferedReader(file);
JSONObject obj = (JSONObject) new JSONParser().parse(in);
in.close();
String server = (String) obj.get("matrixhomeserver");
return server;
}
/**
*
* @return Access Token per il bot, da utilizzare nelle prossime richieste HTTP