add telegram->mc response for group chats
The telegram bot needs to be put into privacy disabled mode (see #3) Closes #3
This commit is contained in:
parent
27097fae67
commit
cd2d27e8db
@ -81,7 +81,9 @@ public class Telegram {
|
||||
|
||||
if (update.getMessage() != null) {
|
||||
Chat chat = update.getMessage().getChat();
|
||||
|
||||
if (chat.isPrivate()) {
|
||||
// private chat
|
||||
if (!TelegramChat.getBackend().ids.contains(chat.getId()))
|
||||
TelegramChat.getBackend().ids.add(chat.getId());
|
||||
|
||||
@ -99,7 +101,32 @@ public class Telegram {
|
||||
this.sendMsg(chat2);
|
||||
}
|
||||
this.sendMsg(chat.getId(), Utils.formatMSG("can-see-but-not-chat")[0]);
|
||||
} else if (TelegramChat.getBackend().getLinkCodes().containsKey(text)) {
|
||||
} else {
|
||||
handleUserMessage(text, chat);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!chat.isPrivate()) {
|
||||
// group chat
|
||||
int id = chat.getId();
|
||||
if (!TelegramChat.getBackend().ids.contains(id))
|
||||
TelegramChat.getBackend().ids.add(id);
|
||||
|
||||
if (update.getMessage().getText() != null) {
|
||||
String text = update.getMessage().getText();
|
||||
handleUserMessage(text, chat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void handleUserMessage(String text, Chat chat) {
|
||||
if (TelegramChat.getBackend().getLinkCodes().containsKey(text)) {
|
||||
// LINK
|
||||
TelegramChat.link(TelegramChat.getBackend().getUUIDFromLinkCode(text), chat.getId());
|
||||
TelegramChat.getBackend().removeLinkCode(text);
|
||||
@ -119,19 +146,6 @@ public class Telegram {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!chat.isPrivate()) {
|
||||
int id = chat.getId();
|
||||
if (!TelegramChat.getBackend().ids.contains(id))
|
||||
TelegramChat.getBackend().ids.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void sendMsg(int id, String msg) {
|
||||
ChatMessageToTelegram chat = new ChatMessageToTelegram();
|
||||
chat.chat_id = id;
|
||||
|
Loading…
Reference in New Issue
Block a user