Browse Source

please compile

master
alistair 3 years ago
parent
commit
53145b6e71
  1. 3
      .gitmodules
  2. 43
      CMakeLists.txt
  3. 26
      README.md
  4. 1
      spdlog
  5. 231756
      sqlite3.c
  6. 12237
      sqlite3.h
  7. 16
      telegram_bot.cpp

3
.gitmodules vendored

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
[submodule "tgbot-cpp"]
path = tgbot-cpp
url = https://github.com/reo7sp/tgbot-cpp/
[submodule "spdlog"]
path = spdlog
url = https://github.com/gabime/spdlog.git

43
CMakeLists.txt

@ -4,39 +4,27 @@ cmake_minimum_required(VERSION 3.17.0) @@ -4,39 +4,27 @@ cmake_minimum_required(VERSION 3.17.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
#set(BUILD_SHARED_LIBS OFF)
#set(CMAKE_EXE_LINKER_FLAGS "-static")
set (CMAKE_CXX_FLAGS" ${CMAKE_CXX_FLAGS_DEBUG} -static-libasan -g")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS_DEBUG} -static-libasan")
set(CMAKE_BUILD_TYPE "Debug")
set (CMAKE_CXX_FLAGS" ${CMAKE_CXX_FLAGS} -DSPDLOG_COMPILED_LIB -DSQLITE_OMIT_LOAD_EXTENSION -static-libasan -g")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -DSPDLOG_COMPILED_LIB -DSQLITE_OMIT_LOAD_EXTENSION -static-libasan")
include(FetchContent)
FetchContent_Declare(json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.7.3)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_Declare(spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog
)
FetchContent_GetProperties(spdlog)
if(NOT spdlog_POPULATED)
FetchContent_Populate(spdlog)
add_subdirectory(${spdlog_SOURCE_DIR} ${spdlog_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG c8d33915dbd88ad6c92b258869b03aba06587ff9) # the commit hash for 1.5.0
FetchContent_MakeAvailable(cpr)
@ -44,24 +32,27 @@ project(echobot-submodule) @@ -44,24 +32,27 @@ project(echobot-submodule)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
set(Boost_USE_MULTITHREADED ON)
set (OPENSSL_USE_STATIC_LIBS TRUE)
find_package(spdlog REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Boost COMPONENTS system REQUIRED)
include_directories(/usr/local/include ${OPENSSL_INCLUDE_DIR} ${Boost_INCLUDE_DIR})
include_directories(/usr/local/include ${OPENSSL_INCLUDE_DIR}
${Boost_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/spdlog/include
${CMAKE_SOURCE_DIR}/tgbot-cpp/include)
add_subdirectory(tgbot-cpp)
if (CURL_FOUND)
include_directories(${CURL_INCLUDE_DIRS})
add_definitions(-DHAVE_CURL)
endif()
add_executable(telegram_bog telegram_bot.cpp sqlite3.c)
add_executable(telegram_bog telegram_bot.cpp)
#set(OPENSSL_USE_STATIC_LIBS TRUE)
target_link_libraries(telegram_bog PRIVATE TgBot ${CMAKE_THREAD_LIBS_INIT}
target_link_libraries(telegram_bog PRIVATE
${CMAKE_SOURCE_DIR}/tgbot-cpp/build/libTgBot.a ${CMAKE_THREAD_LIBS_INIT}
${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${CURL_LIBRARIES})
target_link_libraries(telegram_bog PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(telegram_bog PRIVATE cpr::cpr)
target_link_libraries(telegram_bog PRIVATE sqlite3)
target_link_libraries(telegram_bog PRIVATE spdlog::spdlog)
target_link_libraries(telegram_bog PRIVATE ${CMAKE_SOURCE_DIR}/spdlog/build/libspdlog.a)

26
README.md

@ -1,19 +1,41 @@ @@ -1,19 +1,41 @@
## Building
1. Install dependencies
### Install dependencies
- g++
- cmake
- boost system
- sqlite3-devel, static
- openssl-static
- zlib-static
2. Clone repo
### Clone repo
```bash
git clone --recurse-submodules https://git.topost.net/alistair/karetele.git
```
or
```bash
git clone https://git.topost.net/alistair/karetele.git
git submodule init
git submodule update
```
### Build libraries
```bash
cd spdlog && mkdir build && cd build
cmake .. && make -j
cd tgbot-cpp
mkdir build && cd build
cmake .. && make -j4
```
3. build
```bash

1
spdlog

@ -0,0 +1 @@ @@ -0,0 +1 @@
Subproject commit ff6e3c95f2dc038c19e220afce1d045137b1cb24

231756
sqlite3.c

File diff suppressed because it is too large Load Diff

12237
sqlite3.h

File diff suppressed because it is too large Load Diff

16
telegram_bot.cpp

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
#include <tgbot/tgbot.h>
#include <cpr/cpr.h>
#include <optional>
#include <sqlite3.h>
#include "sqlite3.h"
#include <cstdlib>
#include <map>
#include <set>
@ -121,8 +121,14 @@ class spotify { @@ -121,8 +121,14 @@ class spotify {
cpr::Response r = cpr::Post(cpr::Url{"https://accounts.spotify.com/api/token"},cpr::Header{{"Authorization", "Basic " + auth_token}}, cpr::Parameters{{"grant_type", "client_credentials"}});
std::istringstream isj {r.text};
json auth_response;
isj >> auth_response;
if (r.status_code == 200) {
isj >> auth_response;
} else {
spdlog::error("Login error {} {}",r.status_code, r.status_line);
}
if (auth_response.count("access_token")) {
access_token = auth_response["access_token"];
@ -886,12 +892,6 @@ int main() { @@ -886,12 +892,6 @@ int main() {
signal(SIGINT, [](int s) {
printf("SIGINT got\n");
exit(0);
});
std::string * a = new std::string("hello world");

Loading…
Cancel
Save