aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore63
-rw-r--r--CMakeLists.txt48
-rw-r--r--Makefile.am5
-rw-r--r--cmake/FindPCRE.cmake37
-rw-r--r--cmake/Findcpr.cmake14
-rw-r--r--cmake/Findcurl.cmake14
-rw-r--r--cmake/Finddpp.cmake14
-rw-r--r--cmake/Findsentry.cmake14
-rw-r--r--cmake/Findspdlog.cmake14
-rw-r--r--cmake/dpp-config.cmake21
-rw-r--r--configure.ac23
-rw-r--r--modules/Makefile.am23
-rw-r--r--modules/stoplight/stoplight.cpp (renamed from modules/stoplight/main.cpp)0
-rw-r--r--src/142bot_config.h.in63
-rw-r--r--src/bot.cpp2
-rw-r--r--src/main.cpp8
16 files changed, 184 insertions, 179 deletions
diff --git a/.gitignore b/.gitignore
index 606405f..55bdfdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,3 +99,66 @@ config.json
.cache/
.sentry-native
*.log
+# Created by https://www.toptal.com/developers/gitignore/api/autotools
+# Edit at https://www.toptal.com/developers/gitignore?templates=autotools
+
+### Autotools ###
+# http://www.gnu.org/software/automake
+
+Makefile.in
+/ar-lib
+/mdate-sh
+/py-compile
+/test-driver
+/ylwrap
+.deps/
+.dirstamp
+
+# http://www.gnu.org/software/autoconf
+
+autom4te.cache
+/autoscan.log
+/autoscan-*.log
+/aclocal.m4
+/compile
+/config.cache
+/config.guess
+**/config.h.in
+/config.log
+/config.status
+/config.sub
+/configure
+/configure.scan
+/depcomp
+/install-sh
+/missing
+/stamp-h1
+
+# https://www.gnu.org/software/libtool/
+
+/ltmain.sh
+
+# http://www.gnu.org/software/texinfo
+
+/texinfo.tex
+
+# http://www.gnu.org/software/m4/
+
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+
+# Generated Makefile
+# (meta build system like autotools,
+# can automatically generate from config.status script
+# (which is called by configure script))
+Makefile
+
+### Autotools Patch ###
+
+# End of https://www.toptal.com/developers/gitignore/api/autotools
+
+include/config.h
+**/stamp-h1
diff --git a/CMakeLists.txt b/CMakeLists.txt
deleted file mode 100644
index 1192b50..0000000
--- a/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-cmake_minimum_required(VERSION 3.0)
-project(onefortytwobot VERSION 0.6 LANGUAGES CXX C)
-
-set(CMAKE_CXX_STANDARD 20 REQUIRED)
-set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE OPT_IN)
-
-list(APPEND CMAKE_MODULE_PATH
- "${CMAKE_SOURCE_DIR}/cmake")
-
-find_package(spdlog REQUIRED)
-find_package(dpp REQUIRED)
-find_package(cpr REQUIRED)
-find_package(sentry REQUIRED)
-find_package(curl)
-
-include(cmake/FindPCRE.cmake)
-
-find_package(fmt)
-
-string(ASCII 27 Esc)
-
-find_library(PQXX_LIB pqxx)
-find_library(PQ_LIB pq)
-
-# Define configuration file
-configure_file(142bot.config.in 142bot_config.h)
-
-include(GNUInstallDirs)
-aux_source_directory("src" coresrc)
-add_executable(142bot ${coresrc})
-
-include_directories("include" ${PROJECT_BINARY_DIR})
-target_link_libraries(142bot PRIVATE clog dpp fmt::fmt spdlog::spdlog pcre
- cpr::cpr ${PQXX_LIB} ${PQ_LIB} sentry)
-
-install(TARGETS 142bot)
-
-set (modules_dir "modules")
-file(GLOB subdirlist ${modules_dir}/*)
-foreach (fullmodname ${subdirlist})
- get_filename_component(modname ${fullmodname} NAME)
- message(STATUS "Found module '${Esc}[1;34mmodule_${modname}${Esc}[m'")
- set (modsrc "")
- aux_source_directory(${modules_dir}/${modname} modsrc)
- add_library(module_${modname} SHARED ${modsrc})
- target_link_libraries(module_${modname} dpp cpr sentry)
- set_target_properties(module_${modname} PROPERTIES PREFIX "")
-endforeach(fullmodname)
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..ac44b92
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,5 @@
+bin_PROGRAMS=142bot
+142bot_SOURCES=src/bot.cpp src/db.cpp src/main.cpp src/modules.cpp src/util.cpp
+142bot_CXXFLAGS = -I ./include -std=c++23
+
+SUBDIRS = . modules
diff --git a/cmake/FindPCRE.cmake b/cmake/FindPCRE.cmake
deleted file mode 100644
index d6a77a5..0000000
--- a/cmake/FindPCRE.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2007-2009 LuaDist.
-# Created by Peter Kapec <kapecp@gmail.com>
-# Redistribution and use of this file is allowed according to the terms of the MIT license.
-# For details see the COPYRIGHT file distributed with LuaDist.
-# Note:
-# Searching headers and libraries is very simple and is NOT as powerful as scripts
-# distributed with CMake, because LuaDist defines directories to search for.
-# Everyone is encouraged to contact the author with improvements. Maybe this file
-# becomes part of CMake distribution sometimes.
-
-# - Find pcre
-# Find the native PCRE headers and libraries.
-#
-# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
-# PCRE_LIBRARIES - List of libraries when using pcre.
-# PCRE_FOUND - True if pcre found.
-
-# Look for the header file.
-FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h)
-
-# Look for the library.
-FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
-
-# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
-
-# Copy the results to the output variables.
-IF(PCRE_FOUND)
- SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
- SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
-ELSE(PCRE_FOUND)
- SET(PCRE_LIBRARIES)
- SET(PCRE_INCLUDE_DIRS)
-ENDIF(PCRE_FOUND)
-
-MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) \ No newline at end of file
diff --git a/cmake/Findcpr.cmake b/cmake/Findcpr.cmake
deleted file mode 100644
index a8aed9d..0000000
--- a/cmake/Findcpr.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-include(FindPackageHandleStandardArgs)
-
-find_library(CPR_LIBRARY NAMES cpr)
-
-find_package_handle_standard_args(cpr REQUIRED_VARS CPR_LIBRARY)
-
-if (CPR_FOUND)
- mark_as_advanced(CPR_LIBRARY)
-endif()
-
-if(CPR_FOUND AND NOT TARGET cpr::cpr)
- add_library(cpr::cpr IMPORTED UNKNOWN)
- set_property(TARGET cpr::cpr PROPERTY IMPORTED_LOCATION ${CPR_LIBRARY})
-endif() \ No newline at end of file
diff --git a/cmake/Findcurl.cmake b/cmake/Findcurl.cmake
deleted file mode 100644
index 3ad12ea..0000000
--- a/cmake/Findcurl.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-include(FindPackageHandleStandardArgs)
-
-find_library(CURL_LIBRARY NAMES curl)
-
-find_package_handle_standard_args(curl REQUIRED_VARS CURL_LIBRARY)
-
-if (CURL_FOUND)
- mark_as_advanced(CURL_LIBRARY)
-endif()
-
-if(CURL_FOUND AND NOT TARGET curl::curl)
- add_library(CURL::libcurl IMPORTED UNKNOWN)
- set_property(TARGET CURL::libcurl PROPERTY IMPORTED_LOCATION ${CURL_LIBRARY})
-endif() \ No newline at end of file
diff --git a/cmake/Finddpp.cmake b/cmake/Finddpp.cmake
deleted file mode 100644
index 92933b8..0000000
--- a/cmake/Finddpp.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-include(FindPackageHandleStandardArgs)
-
-find_library(DPP_LIBRARY NAMES dpp)
-
-find_package_handle_standard_args(dpp REQUIRED_VARS DPP_LIBRARY)
-
-if (DPP_FOUND)
- mark_as_advanced(DPP_LIBRARY)
-endif()
-
-if(DPP_FOUND AND NOT TARGET dpp::dpp)
- add_library(dpp::dpp IMPORTED UNKNOWN)
- set_property(TARGET dpp::dpp PROPERTY IMPORTED_LOCATION ${DPP_LIBRARY})
-endif() \ No newline at end of file
diff --git a/cmake/Findsentry.cmake b/cmake/Findsentry.cmake
deleted file mode 100644
index 3c2b225..0000000
--- a/cmake/Findsentry.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-include(FindPackageHandleStandardArgs)
-
-find_library(SENTRY_LIBRARY NAMES sentry)
-
-find_package_handle_standard_args(sentry REQUIRED_VARS SENTRY_LIBRARY)
-
-if (SENTRY_FOUND)
- mark_as_advanced(SENTRY_LIBRARY)
-endif()
-
-if(SENTRY_FOUND AND NOT TARGET sentry::sentry)
- add_library(sentry::sentry IMPORTED UNKNOWN)
- set_property(TARGET sentry::sentry PROPERTY IMPORTED_LOCATION ${SENTRY_LIBRARY})
-endif() \ No newline at end of file
diff --git a/cmake/Findspdlog.cmake b/cmake/Findspdlog.cmake
deleted file mode 100644
index e286724..0000000
--- a/cmake/Findspdlog.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-include(FindPackageHandleStandardArgs)
-
-find_library(SPDLOG_LIBRARY NAMES spdlog)
-
-find_package_handle_standard_args(spdlog REQUIRED_VARS SPDLOG_LIBRARY)
-
-if (SPDLOG_FOUND)
- mark_as_advanced(SPDLOG_LIBRARY)
-endif()
-
-if(SPDLOG_FOUND AND NOT TARGET spdlog::spdlog)
- add_library(spdlog::spdlog IMPORTED UNKNOWN)
- set_property(TARGET spdlog::spdlog PROPERTY IMPORTED_LOCATION ${SPDLOG_LIBRARY})
-endif() \ No newline at end of file
diff --git a/cmake/dpp-config.cmake b/cmake/dpp-config.cmake
deleted file mode 100644
index dedc62e..0000000
--- a/cmake/dpp-config.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-# dpp-config.cmake - package configuration file
-
-## Get current filesystem path (will a prefixed by where this package was installed)
-get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-
-## Use this directory to include dpp which has the rest of the project targets
-include(${SELF_DIR}/dpp.cmake)
-
-## Set OpenSSl directory for macos. It is also in our main CMakeLists.txt, but this file is independent from that.
-if(APPLE)
- if(CMAKE_APPLE_SILICON_PROCESSOR)
- set(OPENSSL_ROOT_DIR "/opt/homebrew/opt/openssl")
- else()
- set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
- endif()
- find_package(OpenSSL REQUIRED)
-endif()
-
-# Search for libdpp dependencies
-include(CMakeFindDependencyMacro)
-find_dependency(OpenSSL REQUIRED)
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..998b215
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,23 @@
+AC_INIT([142bot], [0.5])
+AM_INIT_AUTOMAKE([-Wall -Werror foreign] subdir-objects)
+AC_PROG_CXX
+AM_PROG_AR
+
+LT_INIT([dlopen])
+
+AC_SEARCH_LIBS([_ZTVN3dpp3banE], [dpp], [], [AC_MSG_ERROR([unable to find dpp])])
+AC_SEARCH_LIBS([sentry_init], [sentry], [], [AC_MSG_ERROR([unable to find sentry])])
+AC_SEARCH_LIBS([_ZN3cpr8ResponseC1EOS0_], [cpr], [], [AC_MSG_ERROR([unable to find cpr])])
+AC_SEARCH_LIBS([curl_global_init], [curl], [], [AC_MSG_ERROR([unable to find curl])])
+AC_SEARCH_LIBS([_ZTVN6spdlog6loggerE], [spdlog], [], [AC_MSG_ERROR([unable to find spdlog])])
+AC_SEARCH_LIBS([_ZN4pqxx10connectingC1ENS_5zviewE], [pqxx], [], [AC_MSG_ERROR([unable to find pqxx])])
+AC_SEARCH_LIBS([PQexec], [pq], [], [AC_MSG_ERROR([unable to find pq])])
+AC_SEARCH_LIBS([pcre_exec], [pcre], [], [AC_MSG_ERROR([unable to find pcre])])
+AC_SEARCH_LIBS([_ZN3fmt2v94file3dupEi], [fmt], [], [AC_MSG_ERROR([unable to find fmt])])
+
+AC_CONFIG_HEADERS([src/142bot_config.h])
+
+AC_CONFIG_FILES([
+ Makefile
+ modules/Makefile])
+AC_OUTPUT
diff --git a/modules/Makefile.am b/modules/Makefile.am
new file mode 100644
index 0000000..edf8278
--- /dev/null
+++ b/modules/Makefile.am
@@ -0,0 +1,23 @@
+pkglib_LTLIBRARIES = module_mmanager.la module_spotify.la module_reactions.la module_mail.la module_stoplight.la
+
+module_mmanager_la_SOURCES = mmanager/mmanager.cpp
+module_mmanager_la_LDFLAGS = -avoid-version -shared -export-dynamic -module
+module_mmanager_la_CXXFLAGS = -I ../include
+
+
+module_spotify_la_SOURCES = spotify/spotify.cpp
+module_spotify_la_LDFLAGS = -avoid-version -shared -export-dynamic -module
+module_spotify_la_CXXFLAGS = -I ../include
+
+
+module_reactions_la_SOURCES = reactions/reactions.cpp
+module_reactions_la_LDFLAGS = -avoid-version -shared -export-dynamic -module
+module_reactions_la_CXXFLAGS = -I ../include
+
+module_mail_la_SOURCES = mail/mail.cpp
+module_mail_la_LDFLAGS = -avoid-version -shared -export-dynamic -module
+module_mail_la_CXXFLAGS = -I ../include
+
+module_stoplight_la_SOURCES = stoplight/stoplight.cpp
+module_stoplight_la_LDFLAGS = -avoid-version -shared -export-dynamic -module
+module_stoplight_la_CXXFLAGS = -I ../include
diff --git a/modules/stoplight/main.cpp b/modules/stoplight/stoplight.cpp
index 8740a12..8740a12 100644
--- a/modules/stoplight/main.cpp
+++ b/modules/stoplight/stoplight.cpp
diff --git a/src/142bot_config.h.in b/src/142bot_config.h.in
new file mode 100644
index 0000000..035955f
--- /dev/null
+++ b/src/142bot_config.h.in
@@ -0,0 +1,63 @@
+/* src/142bot_config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
diff --git a/src/bot.cpp b/src/bot.cpp
index d3bd6b7..35592a0 100644
--- a/src/bot.cpp
+++ b/src/bot.cpp
@@ -352,4 +352,4 @@ void Bot::onSlashCommand(const dpp::slashcommand_t &event) {
void Bot::onFormSubmit(const dpp::form_submit_t &event) {
FOREACH_MOD(I_OnFormSubmit, OnFormSubmit(event));
-} \ No newline at end of file
+}
diff --git a/src/main.cpp b/src/main.cpp
index 6ce5858..b22460c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,13 +1,16 @@
+#include <curl/curl.h>
#include <dpp/dpp.h>
#include <dpp/json.h>
#include <142bot/bot.hpp>
#include <142bot/db.hpp>
+#include <fmt/core.h>
#include <spdlog/spdlog.h>
#include <spdlog/async.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/rotating_file_sink.h>
#include <string>
+#include <fmt/format.h>
#include <sentry.h>
@@ -23,15 +26,16 @@ int main(int argc, char const *argv[]) {
std::ifstream f("config.json");
json cfg = json::parse(f);
+ curl_global_init(CURL_GLOBAL_ALL);
string token = cfg.value("token", "bad-token");
sentry_options_t *options = sentry_options_new();
sentry_options_set_dsn(options, cfg.value("sentry_dsn", "").c_str());
// This is also the default-path. For further information and recommendations:
// https://docs.sentry.io/platforms/native/configuration/options/#database-path
sentry_options_set_database_path(options, ".sentry-native");
- sentry_options_set_release(options, "142bot@" + onefortytwobot_VERSION_MAJOR + '.' + onefortytwobot_VERSION_MINOR);
+ sentry_options_set_release(options, fmt::format("142bot@{}", PACKAGE_VERSION).c_str());
sentry_options_set_debug(options, 0);
- sentry_options_set_environment(options, onefortytwobot_env);
+ sentry_options_set_environment(options, "production");
sentry_options_set_symbolize_stacktraces(options, 1);
sentry_init(options);
dpp::cluster bot(token, dpp::intents::i_all_intents);