Warning: session_start(): open(/var/lib/php/sessions/sess_uescnh7vvl6g4ec30mpbutojan, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
!include once #1017511 // Telegram Bots
static TelegramLongPollingBot bot;
p {
fS apiToken = telegramBotToken_mandatory();
ApiContextInitializer.init();
bot = new TelegramLongPollingBot {
public S getBotUsername() { ret "HelloComputer_bot"; }
public S getBotToken() { ret apiToken; }
public void onUpdateReceived(Update update) {
pcall {
print("Got update! " + update);
Message msg = update.getMessage(); //update.getChannelPost();
logQuotedWithDate(telegramFullUpdatesLogFile(), str(update));
if (msg != null && msg.hasText()) {
S text = msg.getText();
print("Incoming text: " + text);
Chat chat = msg.getChat();
User from = msg.getFrom();
Map map = litorderedmap(
where := chat == null ? null : chat.getId(),
type := 'heard,
date := localDateWithMilliseconds(),
originalDate := msg.getDate(),
+text);
if (from != null)
putAll(map, litorderedmap(
userID := from.getId(),
userFirstName := from.getFirstName(),
userLastName := from.getLastName()));
logStructure(telegramLogFile(), map);
}
}
}
};
new TelegramBotsApi().registerBot(bot);
watchStructureLog_future(telegramBotToSendLog(), 100, voidfunc(Map map) {
if (eq(map.get('action), 'send))
telegram_sendWithLogging(bot, telegram_chatID(), getString(map, 'text));
});
}