2024-03-30 22:44:52 -03:00
|
|
|
// SPDX-FileCopyrightText: 2024 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#include "jay.h"
|
|
|
|
#include "logger.h"
|
|
|
|
|
|
|
|
#include <string>
|
2025-02-21 23:01:11 +02:00
|
|
|
#include <sstream>
|
2024-03-30 22:44:52 -03:00
|
|
|
#include <iostream>
|
|
|
|
|
2025-02-21 23:01:11 +02:00
|
|
|
std::string readEnv(const std::string& key, const std::string& defaultValue = "") {
|
|
|
|
const char* val = std::getenv(key.data());
|
|
|
|
if (val)
|
|
|
|
return std::string(val);
|
|
|
|
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2024-03-30 22:44:52 -03:00
|
|
|
int main(int argc, char** argv) {
|
2025-02-21 23:01:11 +02:00
|
|
|
std::string jid = readEnv("JID");
|
|
|
|
std::string password = readEnv("PASSWORD");
|
2024-03-30 22:44:52 -03:00
|
|
|
|
2025-02-21 23:01:11 +02:00
|
|
|
if (jid.empty() || password.empty()) {
|
|
|
|
std::cout << "You need to provide JID and PASSWORD environment variables" << std::endl;
|
|
|
|
return - 1;
|
|
|
|
}
|
2024-03-30 22:44:52 -03:00
|
|
|
|
|
|
|
Jay bot(jid, password);
|
|
|
|
bot.addLogger(gloox::LogLevelDebug);
|
|
|
|
|
2025-02-21 23:01:11 +02:00
|
|
|
std::string owners = readEnv("OWNERS");
|
|
|
|
std::stringstream ss(owners);
|
|
|
|
std::string owner;
|
|
|
|
while (std::getline(ss, owner, ','))
|
|
|
|
bot.addOwner(owner);
|
|
|
|
|
2024-03-30 22:44:52 -03:00
|
|
|
bot.run();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|