GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cat-react-cpp/src/main.cpp at master · tee-community/cat-react-cpp Expand file tree/ Copy pathmain.cppMore file actions 74 lines (63 loc) · 2.65 KB / Copy pathmain.cppFile metadata and controls74 lines (63 loc) · 2.65 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #include <iostream> #include "config.hpp" #include <dpp/dpp.h> #include <format> #define CONFIG_FILE "config.json" template<typename... TArgs> void Log(dpp::loglevel Level, std::format_string<TArgs...> Fmt, TArgs&&... Args) { dpp::log_t Log; Log.severity = Level; Log.message = std::format(Fmt, std::forward<TArgs>(Args)...); dpp::utility::cout_logger()(Log); } int main() { CConfig Config; if (!Config.ConfigFileExists(CONFIG_FILE)) { switch (Config.CreateTemplateConfig(CONFIG_FILE)) { case SUCCESS: Log(dpp::ll_critical, "'{}' not found, created a template", CONFIG_FILE); return 0; case ERROR_OPENING_FILE: Log(dpp::ll_critical, "Can't open '{}' for writing", CONFIG_FILE); return 1; default: Log(dpp::ll_critical, "Unknown error"); return 69; } } if (Config.LoadFromFile(CONFIG_FILE) == ERROR_OPENING_FILE) { Log(dpp::ll_critical, "Can't open '{}' for reading", CONFIG_FILE); return 1; } dpp::cluster Bot(Config.Values().m_Token, dpp::i_default_intents | dpp::i_message_content); const dpp::emoji Emoji(Config.Values().m_EmojiUnicode, Config.Values().m_CustomEmojiId, Config.Values().m_EmojiType == SConfig::CUSTOM_ANIMATED ? dpp::emoji_flags::e_animated : 0); Bot.on_log(dpp::utility::cout_logger()); Bot.on_ready([&Bot](const dpp::ready_t &event) { Bot.log(dpp::ll_info, "Bot online!"); }); Bot.on_message_create([&Bot, &Config, Emoji](const dpp::message_create_t &event) { if (event.msg.channel_id == Config.Values().m_ChannelId && !event.msg.author.is_bot()) { for (auto &attachment: event.msg.attachments) { if (attachment.content_type.starts_with("image") || attachment.content_type.starts_with("video")) { Bot.log(dpp::ll_info, "Got new cat message! (attachment)"); Bot.message_add_reaction(event.msg, Emoji.format()); return; } } for (auto &embed : event.msg.embeds) { if (embed.image.has_value() || embed.thumbnail.has_value()) { Bot.log(dpp::ll_info, "Got new cat message! (embed)"); Bot.message_add_reaction(event.msg, Emoji.format()); return; } } if (!event.msg.stickers.empty()) { Bot.log(dpp::ll_info, "Got new cat message! (sticker)"); Bot.message_add_reaction(event.msg, Emoji.format()); } } }); Bot.start(dpp::st_wait); return 0; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |