Compare commits

..

No commits in common. "23abc5a0aa375c23841d16d23826779d79190a49" and "ea7297fa3772466fcf3839dddfbaddd4a8c9f496" have entirely different histories.

16 changed files with 2456 additions and 241 deletions

View File

@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.15)
# Project name, version and description
project(gbp-bot VERSION 1.0 DESCRIPTION "A discord bot")
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
# Add DPP as dependency
add_subdirectory(libs/DPP)
@ -15,7 +17,7 @@ add_executable(${PROJECT_NAME}
# Linking libraries
target_link_libraries(${PROJECT_NAME}
dpp
curl
Python3::Python
)
# Specify includes

View File

@ -42,6 +42,8 @@ set(CMAKE_MAKEFILE_DEPENDS
"/usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake"
"/usr/share/cmake-3.18/Modules/FindPackageMessage.cmake"
"/usr/share/cmake-3.18/Modules/FindPkgConfig.cmake"
"/usr/share/cmake-3.18/Modules/FindPython/Support.cmake"
"/usr/share/cmake-3.18/Modules/FindPython3.cmake"
"/usr/share/cmake-3.18/Modules/FindThreads.cmake"
"/usr/share/cmake-3.18/Modules/FindZLIB.cmake"
"/usr/share/cmake-3.18/Modules/GNUInstallDirs.cmake"

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@ set(CMAKE_CXX_COMPILER_ID "GNU")
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"../libs/DPP/include"
"/usr/include/python3.9"
)
# Targets to which this target links.

View File

@ -99,6 +99,7 @@ gbp__bot_EXTERNAL_OBJECTS =
gbp-bot: CMakeFiles/gbp-bot.dir/src/main.cpp.o
gbp-bot: CMakeFiles/gbp-bot.dir/build.make
gbp-bot: libs/DPP/libdpp.so.1.0
gbp-bot: /usr/lib/x86_64-linux-gnu/libpython3.9.so
gbp-bot: /usr/lib/x86_64-linux-gnu/libcrypto.so
gbp-bot: /usr/lib/x86_64-linux-gnu/libssl.so
gbp-bot: /usr/lib/x86_64-linux-gnu/libz.so

View File

@ -2,3 +2,150 @@
# Generated by "Unix Makefiles" Generator, CMake Version 3.18
CMakeFiles/gbp-bot.dir/src/main.cpp.o
../libs/DPP/include/dpp/appcommand.h
../libs/DPP/include/dpp/application.h
../libs/DPP/include/dpp/auditlog.h
../libs/DPP/include/dpp/ban.h
../libs/DPP/include/dpp/cache.h
../libs/DPP/include/dpp/channel.h
../libs/DPP/include/dpp/cluster.h
../libs/DPP/include/dpp/commandhandler.h
../libs/DPP/include/dpp/discordclient.h
../libs/DPP/include/dpp/discordevents.h
../libs/DPP/include/dpp/discordvoiceclient.h
../libs/DPP/include/dpp/dispatcher.h
../libs/DPP/include/dpp/dpp.h
../libs/DPP/include/dpp/dtemplate.h
../libs/DPP/include/dpp/emoji.h
../libs/DPP/include/dpp/event.h
../libs/DPP/include/dpp/exception.h
../libs/DPP/include/dpp/export.h
../libs/DPP/include/dpp/guild.h
../libs/DPP/include/dpp/httpsclient.h
../libs/DPP/include/dpp/integration.h
../libs/DPP/include/dpp/intents.h
../libs/DPP/include/dpp/invite.h
../libs/DPP/include/dpp/json_fwd.hpp
../libs/DPP/include/dpp/managed.h
../libs/DPP/include/dpp/message.h
../libs/DPP/include/dpp/misc-enum.h
../libs/DPP/include/dpp/nlohmann/json.hpp
../libs/DPP/include/dpp/once.h
../libs/DPP/include/dpp/presence.h
../libs/DPP/include/dpp/prune.h
../libs/DPP/include/dpp/queues.h
../libs/DPP/include/dpp/role.h
../libs/DPP/include/dpp/scheduled_event.h
../libs/DPP/include/dpp/snowflake.h
../libs/DPP/include/dpp/socket.h
../libs/DPP/include/dpp/sslclient.h
../libs/DPP/include/dpp/stage_instance.h
../libs/DPP/include/dpp/timer.h
../libs/DPP/include/dpp/user.h
../libs/DPP/include/dpp/utility.h
../libs/DPP/include/dpp/version.h
../libs/DPP/include/dpp/voiceregion.h
../libs/DPP/include/dpp/voicestate.h
../libs/DPP/include/dpp/webhook.h
../libs/DPP/include/dpp/win32_safe_warnings.h
../libs/DPP/include/dpp/wsclient.h
/home/seth/documents/programming/discord-bots/gbp/src/commands.cpp
/home/seth/documents/programming/discord-bots/gbp/src/gbp.cpp
/home/seth/documents/programming/discord-bots/gbp/src/main.cpp
/usr/include/python3.9/Python.h
/usr/include/python3.9/abstract.h
/usr/include/python3.9/bltinmodule.h
/usr/include/python3.9/boolobject.h
/usr/include/python3.9/bytearrayobject.h
/usr/include/python3.9/bytesobject.h
/usr/include/python3.9/cellobject.h
/usr/include/python3.9/ceval.h
/usr/include/python3.9/classobject.h
/usr/include/python3.9/code.h
/usr/include/python3.9/codecs.h
/usr/include/python3.9/compile.h
/usr/include/python3.9/complexobject.h
/usr/include/python3.9/context.h
/usr/include/python3.9/cpython/abstract.h
/usr/include/python3.9/cpython/bytearrayobject.h
/usr/include/python3.9/cpython/bytesobject.h
/usr/include/python3.9/cpython/ceval.h
/usr/include/python3.9/cpython/code.h
/usr/include/python3.9/cpython/dictobject.h
/usr/include/python3.9/cpython/fileobject.h
/usr/include/python3.9/cpython/fileutils.h
/usr/include/python3.9/cpython/import.h
/usr/include/python3.9/cpython/initconfig.h
/usr/include/python3.9/cpython/listobject.h
/usr/include/python3.9/cpython/methodobject.h
/usr/include/python3.9/cpython/object.h
/usr/include/python3.9/cpython/objimpl.h
/usr/include/python3.9/cpython/pyerrors.h
/usr/include/python3.9/cpython/pylifecycle.h
/usr/include/python3.9/cpython/pymem.h
/usr/include/python3.9/cpython/pystate.h
/usr/include/python3.9/cpython/sysmodule.h
/usr/include/python3.9/cpython/traceback.h
/usr/include/python3.9/cpython/tupleobject.h
/usr/include/python3.9/cpython/unicodeobject.h
/usr/include/python3.9/descrobject.h
/usr/include/python3.9/dictobject.h
/usr/include/python3.9/enumobject.h
/usr/include/python3.9/eval.h
/usr/include/python3.9/exports.h
/usr/include/python3.9/fileobject.h
/usr/include/python3.9/fileutils.h
/usr/include/python3.9/floatobject.h
/usr/include/python3.9/funcobject.h
/usr/include/python3.9/genericaliasobject.h
/usr/include/python3.9/genobject.h
/usr/include/python3.9/import.h
/usr/include/python3.9/intrcheck.h
/usr/include/python3.9/iterobject.h
/usr/include/python3.9/listobject.h
/usr/include/python3.9/longintrepr.h
/usr/include/python3.9/longobject.h
/usr/include/python3.9/memoryobject.h
/usr/include/python3.9/methodobject.h
/usr/include/python3.9/modsupport.h
/usr/include/python3.9/moduleobject.h
/usr/include/python3.9/namespaceobject.h
/usr/include/python3.9/object.h
/usr/include/python3.9/objimpl.h
/usr/include/python3.9/odictobject.h
/usr/include/python3.9/osmodule.h
/usr/include/python3.9/patchlevel.h
/usr/include/python3.9/picklebufobject.h
/usr/include/python3.9/pyarena.h
/usr/include/python3.9/pycapsule.h
/usr/include/python3.9/pyconfig.h
/usr/include/python3.9/pyctype.h
/usr/include/python3.9/pydebug.h
/usr/include/python3.9/pyerrors.h
/usr/include/python3.9/pyfpe.h
/usr/include/python3.9/pyframe.h
/usr/include/python3.9/pyhash.h
/usr/include/python3.9/pylifecycle.h
/usr/include/python3.9/pymacconfig.h
/usr/include/python3.9/pymacro.h
/usr/include/python3.9/pymath.h
/usr/include/python3.9/pymem.h
/usr/include/python3.9/pyport.h
/usr/include/python3.9/pystate.h
/usr/include/python3.9/pystrcmp.h
/usr/include/python3.9/pystrtod.h
/usr/include/python3.9/pythonrun.h
/usr/include/python3.9/pythread.h
/usr/include/python3.9/pytime.h
/usr/include/python3.9/rangeobject.h
/usr/include/python3.9/setobject.h
/usr/include/python3.9/sliceobject.h
/usr/include/python3.9/structseq.h
/usr/include/python3.9/sysmodule.h
/usr/include/python3.9/traceback.h
/usr/include/python3.9/tracemalloc.h
/usr/include/python3.9/tupleobject.h
/usr/include/python3.9/typeslots.h
/usr/include/python3.9/unicodeobject.h
/usr/include/python3.9/warnings.h
/usr/include/python3.9/weakrefobject.h

View File

@ -1,4 +1,151 @@
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.18
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/appcommand.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/application.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/auditlog.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/ban.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/cache.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/channel.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/cluster.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/commandhandler.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/discordclient.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/discordevents.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/discordvoiceclient.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/dispatcher.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/dpp.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/dtemplate.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/emoji.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/event.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/exception.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/export.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/guild.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/httpsclient.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/integration.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/intents.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/invite.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/json_fwd.hpp
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/managed.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/message.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/misc-enum.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/nlohmann/json.hpp
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/once.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/presence.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/prune.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/queues.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/role.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/scheduled_event.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/snowflake.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/socket.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/sslclient.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/stage_instance.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/timer.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/user.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/utility.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/version.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/voiceregion.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/voicestate.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/webhook.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/win32_safe_warnings.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../libs/DPP/include/dpp/wsclient.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../src/commands.cpp
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../src/gbp.cpp
CMakeFiles/gbp-bot.dir/src/main.cpp.o: ../src/main.cpp
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/Python.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/abstract.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/bltinmodule.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/boolobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/bytearrayobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/bytesobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cellobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/ceval.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/classobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/code.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/codecs.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/compile.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/complexobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/context.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/abstract.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/bytearrayobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/bytesobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/ceval.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/code.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/dictobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/fileobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/fileutils.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/import.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/initconfig.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/listobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/methodobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/object.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/objimpl.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/pyerrors.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/pylifecycle.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/pymem.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/pystate.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/sysmodule.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/traceback.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/tupleobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/cpython/unicodeobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/descrobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/dictobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/enumobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/eval.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/exports.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/fileobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/fileutils.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/floatobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/funcobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/genericaliasobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/genobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/import.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/intrcheck.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/iterobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/listobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/longintrepr.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/longobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/memoryobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/methodobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/modsupport.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/moduleobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/namespaceobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/object.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/objimpl.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/odictobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/osmodule.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/patchlevel.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/picklebufobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyarena.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pycapsule.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyconfig.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyctype.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pydebug.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyerrors.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyfpe.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyframe.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyhash.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pylifecycle.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pymacconfig.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pymacro.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pymath.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pymem.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pyport.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pystate.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pystrcmp.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pystrtod.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pythonrun.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pythread.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/pytime.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/rangeobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/setobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/sliceobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/structseq.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/sysmodule.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/traceback.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/tracemalloc.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/tupleobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/typeslots.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/unicodeobject.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/warnings.h
CMakeFiles/gbp-bot.dir/src/main.cpp.o: /usr/include/python3.9/weakrefobject.h

View File

@ -4,7 +4,7 @@
# compile CXX with /usr/bin/c++
CXX_DEFINES =
CXX_INCLUDES = -I/home/seth/documents/programming/discord-bots/gbp/libs/DPP/include
CXX_INCLUDES = -I/home/seth/documents/programming/discord-bots/gbp/libs/DPP/include -isystem /usr/include/python3.9
CXX_FLAGS = -std=gnu++17

View File

@ -1 +1 @@
/usr/bin/c++ CMakeFiles/gbp-bot.dir/src/main.cpp.o -o gbp-bot -Wl,-rpath,/home/seth/documents/programming/discord-bots/gbp/build/libs/DPP libs/DPP/libdpp.so.1.0 -lcurl /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libsodium.so /usr/lib/x86_64-linux-gnu/libopus.so -lm
/usr/bin/c++ CMakeFiles/gbp-bot.dir/src/main.cpp.o -o gbp-bot -Wl,-rpath,/home/seth/documents/programming/discord-bots/gbp/build/libs/DPP libs/DPP/libdpp.so.1.0 /usr/lib/x86_64-linux-gnu/libpython3.9.so /usr/lib/x86_64-linux-gnu/libcrypto.so /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libz.so /usr/lib/x86_64-linux-gnu/libsodium.so /usr/lib/x86_64-linux-gnu/libopus.so -lm

Binary file not shown.

View File

@ -1,7 +0,0 @@
{
"korol": "%s is well known for murderboning, valid hunting, and power gaming. I especially see them during my timeslot where I am often one of only two or three admins, the EST mornings. During this, regardless of whether or not I'm playing or adminning, I will see %s at the core of the conflict. If they're an antag, then a lot of people are dying/dead. If not, then they are usually one of the biggest threats to the antagonists. It was to absolutely no one's surprise when %s killed virtually everyone during their round in question following the tradition of another killing spree, while only talking to complain about something or to vent their minor irritation in deadchat between revivals as a changeling. This was at both the station and the evac shuttle.",
"mothblocks": "His blant disregard for normal tg servers.\n1) He consistently tells new admin candidates not to play, so how will they know more about a current playerbase if their only interaction is hovering around as a ghost. Why do you think nanites died as they did.\n2)his use of back channels to ensure that notes stick the way that they do, if someone disagree and proves that they are correct in a way. Tough shit, he already communicated with headmins about it before they even communicated to the player.\nAka no reason for headmin ruling.\n3) MSO and server specific playerbases say one thing and they guy with his metagroup still force \"mrp\" policies and code that conflict.\n4)consistently banning Europeans out of discord code channel for bitching about it.\n5)saying that \"playerbase has to make their responsibility of knowing the pipeline changes for github.\" Which I, myself couldn't get a simple poll to see how players actually take the time to look at forums or github. (We both know its real low on that bell curve.)",
"shotgun": "I used the shotgun. You know why? Cause the shot gun doesn't miss: and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang: bang: and they're fucking done. I use four shots just to make damn sure. Because: once again: I'm not there to coddle a bunca criminal scum sucking f------: I'm there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned: which I won't: you can guarantee I will continue to use the shotgun to apprehend criminals. Because it's quick: clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots: which take half a clip just to bring someone down: or with the tazer bolts which are slow as balls: impossible to aim and do about next to jack shit: fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls.",
"meow": "Wowwwww, you meow like a cat! That means you are one, right? Shut the fuck up. If you really want to be put on a leash and treated like a domestic animal then that's called a fetish, not \"quirky\" or \"cute\". What part of you seriously thinks that any part of acting like a felin establishes a reputation of appreciation? Is it your lack of any defining aspect of personality that urges you to restort to shitty representations of cats to create an illusion of meaning in your worthless life? Wearing \"car ears\" in the shape of headbands further notes the complete absence of human attribution to your false sense of personality, such as intelligence or charisma in any form or shape. Where do you think this mindset's gonna lead you? You think you're funny, random, quirky even? What makes you think that acting like a fucking cat will make a goddamn hyena laugh? I, personally, feel extremely sympathetic towards you as your only escape from the worthless thing you call your existence is to pretend to be an animal. But it's not a worthy choice to assert this horrifying fact as a dominant trait, mainly because personality traits require an initial personality to lay their foundation on. You're not worthy of anybody's time, so go fuck off, \"cat-girl\".",
"cobb": "SNIFF SNIFF is that feet I smell? Said Ryan Cobb, as his boner swelled. \"Feet, feet, feet with sweat!\" He chanted loud, like a threat. Fast and nimble quiet as night, Ryan cobb did say with delight: \"YES I SEE THEM, TASTY FEET, SWEATY LARGE AND READY TO EAT!\" He sucked the toes and slurped them down as with horror did watch the clown! He slobbered, swallowed, and sucked with grace as did horror befall our face! The Stun baton swang fast and fleet, so did signal ryan's defeat! But if you see him in the halls, bald head shining off the walls, keep your shoes on, laces knit, lest ryan catch you, and your forced to submit."
}

View File

@ -1,128 +1,258 @@
#include "gbp.cpp"
#include <dpp/dpp.h>
#include <dpp/commandhandler.h>
#include <dpp/message.h>
#include <iostream>
#include <fstream>
#include <dpp/nlohmann/json.hpp>
#include <string>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <time.h>
using json = nlohmann::json;
#define FILE_WARNING "/FILE/"
#define TEMP_FILE_NAME "gbp.txt"
void sanitize_message(std::string &content, dpp::message &msg)
typedef std::string (*vFunc)(void);
typedef std::string (*vecFunc)(std::vector<std::string>);
std::map<std::string, vFunc>noArgs;
std::map<std::string, vecFunc>vecArgs;
/**
* ##commandParse
*
* Uses the given arguments to choose a command to use
*
* Arguments:
* * std::vector<std::string> args - Given arguments, separated into a vector
*/
std::string commandParse(std::vector<std::string> args)
{
if (content.length() < 2000)
return;
std::ofstream file(TEMP_FILE_NAME);
for (int i = 0; i < content.length(); i++) {
if (content[i] != '`')
file << content[i];
auto i1 = noArgs.find(args[0]);
if (i1 != noArgs.end())
return (*i1->second)();
auto i2 = vecArgs.find(args[0]);
if (i2 != vecArgs.end())
return (*i2->second)(args);
return "Invalid command!";
}
std::string sendFile(std::string filePath, std::string fileName = "")
{
if (fileName == "")
fileName = filePath;
/*
* Files are sent with:
* FILE_WARNING $PATH $FILENAME
*
* $FILENAME is the name of the file that will be sent to discord, if you don't want the file sent
* to have the save name as the one on disk, or if you have a custom path for the file, set $FILENAME
*/
return std::string(FILE_WARNING) + " " + filePath + " " + fileName;
}
/**
* printFullGBPList
*
* Returns a path to a file that contains a formatted list of gbp values
*/
std::string printFullGBPList()
{
std::map<unsigned short int, std::pair<int, std::string>> gbp;
gbp = readGBPIntoList();
std::ofstream file;
file.open("temp-GBP");
std::string line;
for (std::map<unsigned short int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
line = std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
file << line;
}
file.close();
content = "";
msg.add_file(TEMP_FILE_NAME, dpp::utility::read_file(TEMP_FILE_NAME));
return sendFile("temp-GBP", "gbp-list.txt");
}
#undef TEMP_FILE_NAME
std::string get_copypasta(std::string msg, std::string in = "")
/**
* ##fetchGBP
*
* Fetches the latest GBP
*/
std::string fetchGBP()
{
json copypasta;
std::ifstream copypasta_file("../copypasta.json");
copypasta_file >> copypasta;
fetchLatestGBP();
return "Fetched latest GBP!";
}
if (copypasta.find(msg) == copypasta.end())
return "";
std::string out = copypasta[msg];
/**
* ##genericResponse
*
* Gives a generic response.
*/
std::string genericResponse()
{
return "Fuck you";
}
int i;
while ((i = out.find("%s")) != -1) {
out.replace(i, 2, in);
}
/**
* ##helpMessage
*
* Return the list of commands.
*/
std::string helpMessage()
{
std::string out;
out = "```\n\
Available Commands: \n\
gbplist (update):\n\
----> Print out the current GBP leaderboard. Add update to fetch the latest page.\n\
findpos (number):\n\
----> Prints out the user at number (number) in the GBP leaderboard.\n\
findgbp (number):\n\
----> Prints out every user with (number) GBP.\n\
findname (username):\n\
----> Prints out the user (username) and their GBP.\n\
```\n";
return out;
}
void init_commands(dpp::commandhandler &command_handler)
std::string hotdogs()
{
command_handler.add_command(
"findname",
{
{"Username", dpp::param_info(dpp::pt_string, false, "The github usename to search for")}
},
[&command_handler](const std::string &command, const dpp::parameter_list_t &parameters, dpp::command_source src) {
std::string username;
if (!parameters.empty())
username = std::get<std::string>(parameters[0].second);
std::string response = find_username(username);
dpp::message msg;
sanitize_message(response, msg);
msg.set_content(response);
command_handler.reply(msg, src);
},
"Finds the github username, and their associated GBP value."
);
command_handler.add_command(
"findgbp",
{
{"GBP Amount", dpp::param_info(dpp::pt_string, false, "Amount of GBP to search for")}
},
[&command_handler](const std::string &command, const dpp::parameter_list_t &parameters, dpp::command_source src) {
int gbp;
if (!parameters.empty())
gbp = std::stoi(std::get<std::string>(parameters[0].second));
std::string response = find_gbp(gbp);
dpp::message msg;
sanitize_message(response, msg);
msg.set_content(response);
command_handler.reply(msg, src);
},
"Finds the users with the amount of GBP provided."
);
command_handler.add_command(
"findpos",
{
{"GBP Amount", dpp::param_info(dpp::pt_string, false, "Amount of GBP to search for")}
},
[&command_handler](const std::string &command, const dpp::parameter_list_t &parameters, dpp::command_source src) {
int pos;
if (!parameters.empty())
pos = std::stoi(std::get<std::string>(parameters[0].second));
std::string response = find_gbp_pos(pos);
dpp::message msg;
sanitize_message(response, msg);
msg.set_content(response);
command_handler.reply(msg, src);
},
"Finds the user at the specified spot on the leaderboard."
);
command_handler.add_command(
"fetchgbp",
{},
[&command_handler](const std::string &command, const dpp::parameter_list_t &parameters, dpp::command_source src) {
fetch_raw_gbp();
command_handler.reply(dpp::message("Fetched latest GBP!"), src);
},
"Fetches the latest GBP."
);
command_handler.add_command(
"copypasta",
{
{"message", dpp::param_info(dpp::pt_string, false, "The copypasta")},
{"replace", dpp::param_info(dpp::pt_string, true, "The string to replace add to the copypasta template")}
},
[&command_handler](const std::string &command, const dpp::parameter_list_t &parameters, dpp::command_source src) {
std::string copypasta_message;
std::string to_replace;
if (!parameters.empty()) {
copypasta_message = std::get<std::string>(parameters[0].second);
to_replace = std::get<std::string>(parameters[1].second);
srand(time(NULL));
std::string hotdogs[4] = {"https://images-ext-1.discordapp.net/external/cV9nyk6KkduZvgBsQftZPyxSlFIt_fPqKyL-7PSFp-Q/%3Fc%3DVjFfZGlzY29yZA/https/media.tenor.com/P0Uf3wpitQoAAAPo/chili-dog-hot-dog.mp4", "https://images-ext-2.discordapp.net/external/cyqxHoBOkEZaf1sDX7R-C45NhQKoOWGYNkBhrptGL9w/%3Fc%3DVjFfZGlzY29yZA/https/media.tenor.com/R1uik9PL17gAAAPo/stormcastle-hotdog-sandwich-dance.mp4", "https://images-ext-2.discordapp.net/external/pLpY735ApiAsCVIUZNf1PWdazjX4QxjnFjde-q6_nkQ/%3Fc%3DVjFfZGlzY29yZA/https/media.tenor.com/8ysdJ5IuTvIAAAPo/hot-dog.mp4", "https://images-ext-2.discordapp.net/external/-w3a7TU1wgDb-4kSorHIVlmuWImGxMb_HbnI8T11w90/%3Fc%3DVjFfZGlzY29yZA/https/media.tenor.com/OVVXYe8yIeUAAAPo/hotdog-dancing.mp4"};
return hotdogs[rand() % 4];
}
/**
* ##findNum
*
* Returns the user + GBP at the given position.
*/
std::string findNum(std::vector<std::string> args)
{
if (args.size() < 2)
return "Invalid command!";
int pos = std::stoi(args[1]);
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
std::string out = "```#" + (std::to_string(pos)) + ": " + gbp[pos].second + " (" + std::to_string(gbp[pos].first) + " GBP)```\n";
return out;
}
/**
* ##findName
*
* Finds the given user, and returns a string with their GBP.
*/
std::string findName(std::vector<std::string> args)
{
if (args.size() < 2)
return "Invalid command!";
std::string username = args[1];
std::string out = "```";
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
for (std::map<unsigned short int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
if (it->second.second.find(username) != -1)
out += "#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
}
std::string response = get_copypasta(copypasta_message, to_replace);
dpp::message msg;
sanitize_message(response, msg);
msg.set_content(response);
command_handler.reply(msg, src);
out += "```";
if (out == "``````")
return "User not found!";
return out;
}
/**
* ##findGBP
*
* Returns a string containing every user with the given gbp.
*/
std::string findGBP(std::vector<std::string> args)
{
if (args.size() < 2)
return "Invalid command!";
int gbpToFind = std::stoi(args[1]);
std::string out = "```";
std::map<unsigned short int, std::pair<int, std::string>> gbp = readGBPIntoList();
for (std::map<unsigned short int, std::pair<int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++)
if (it->second.first == gbpToFind)
out += "#" + std::to_string(it->first) + ": " + it->second.second + " (" + std::to_string(it->second.first) + " GBP)\n";
out += "```";
if (out == "``````")
return "No users found with that GBP!";
return out;
}
/**
* ##copypasta
*
* Print a copypasta from the bank of copypastas
*/
std::string copypasta(std::vector<std::string> args)
{
if (args.size() < 2)
return "Invalid command!";
std::string msg = args[1];
std::string out;
if (msg == "korol") {
std::string username = "";
if (args.size() >= 3)
username = args[2];
out = username + " is well known for murderboning, valid hunting, and power gaming. I especially see them during my timeslot where I am often one of only two or three admins, the EST mornings. During this, regardless of whether or not I'm playing or adminning, I will see " + username + " at the core of the conflict. If they're an antag, then a lot of people are dying/dead. If not, then they are usually one of the biggest threats to the antagonists. It was to absolutely no one's surprise when " + username + " killed virtually everyone during their round in question following the tradition of another killing spree, while only talking to complain about something or to vent their minor irritation in deadchat between revivals as a changeling. This was at both the station and the evac shuttle.";
} else if (msg == "mothblocks") {
out = "His blant disregard for normal tg servers.\n1) He consistently tells new admin candidates not to play, so how will they know more about a current playerbase if their only interaction is hovering around as a ghost. Why do you think nanites died as they did.\n2)his use of back channels to ensure that notes stick the way that they do, if someone disagree and proves that they are correct in a way. Tough shit, he already communicated with headmins about it before they even communicated to the player.\nAka no reason for headmin ruling.\n3) MSO and server specific playerbases say one thing and they guy with his metagroup still force \"mrp\" policies and code that conflict.\n4)consistently banning Europeans out of discord code channel for bitching about it.\n5)saying that \"playerbase has to make their responsibility of knowing the pipeline changes for github.\" Which I, myself couldn't get a simple poll to see how players actually take the time to look at forums or github. (We both know its real low on that bell curve.)";
} else if (msg == "shotgun") {
out = "I used the shotgun. You know why? Cause the shot gun doesn't miss: and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang: bang: and they're fucking done. I use four shots just to make damn sure. Because: once again: I'm not there to coddle a bunca criminal scum sucking f------: I'm there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned: which I won't: you can guarantee I will continue to use the shotgun to apprehend criminals. Because it's quick: clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots: which take half a clip just to bring someone down: or with the tazer bolts which are slow as balls: impossible to aim and do about next to jack shit: fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls.";
} else if (msg == "meow") {
out = "Wowwwww, you meow like a cat! That means you are one, right? Shut the fuck up. If you really want to be put on a leash and treated like a domestic animal then that's called a fetish, not \"quirky\" or \"cute\". What part of you seriously thinks that any part of acting like a felin establishes a reputation of appreciation? Is it your lack of any defining aspect of personality that urges you to restort to shitty representations of cats to create an illusion of meaning in your worthless life? Wearing \"car ears\" in the shape of headbands further notes the complete absence of human attribution to your false sense of personality, such as intelligence or charisma in any form or shape. Where do you think this mindset's gonna lead you? You think you're funny, random, quirky even? What makes you think that acting like a fucking cat will make a goddamn hyena laugh? I, personally, feel extremely sympathetic towards you as your only escape from the worthless thing you call your existence is to pretend to be an animal. But it's not a worthy choice to assert this horrifying fact as a dominant trait, mainly because personality traits require an initial personality to lay their foundation on. You're not worthy of anybody's time, so go fuck off, \"cat-girl\".";
} else if (msg == "cobb") {
out = "SNIFF SNIFF is that feet I smell? Said Ryan Cobb, as his boner swelled. \"Feet, feet, feet with sweat!\" He chanted loud, like a threat. Fast and nimble quiet as night, Ryan cobb did say with delight: \"YES I SEE THEM, TASTY FEET, SWEATY LARGE AND READY TO EAT!\" He sucked the toes and slurped them down as with horror did watch the clown! He slobbered, swallowed, and sucked with grace as did horror befall our face! The Stun baton swang fast and fleet, so did signal ryan's defeat! But if you see him in the halls, bald head shining off the walls, keep your shoes on, laces knit, lest ryan catch you, and your forced to submit.";
}
);
return out;
}
/* Initializes all the commands */
void initCommands()
{
/**
* To make new commands, create a new function that returns std::string
* If you want it to have input, take it to accept std::vector<std::string>
*
* afterwards, add it to the proper map below (noArgs for functions with no args, vecArgs for functions with args)
*
* If your function has args, make sure to check that the size of the arg vector is adequate
*/
noArgs.emplace("hi", &genericResponse);
noArgs.emplace("help", &helpMessage);
noArgs.emplace("gbplist", &printFullGBPList);
noArgs.emplace("fetchgbp", &fetchGBP);
noArgs.emplace("hotdog", &hotdogs);
vecArgs.emplace("findpos", &findNum);
vecArgs.emplace("findgbp", &findGBP);
vecArgs.emplace("findname", &findName);
vecArgs.emplace("copypasta", &copypasta);
}
////finish this, make it return a string
//use THIS to ping the users, and call it from a separate thread
void pingUsers()
{
std::ifstream file;
file.open("toPing.txt");
if (!file) {
file.close();
return;
}
std::string line;
std::string username;
int gbpPos;
std::string toPing;
while(getline(file, line)) {
username = line.substr(0, line.find(" "));
gbpPos = std::stoi(line.substr(line.find(" ") + 1, line.length() - (line.find(" ") + 1)));
toPing = line.substr(line.rfind(" "), line.length() - line.rfind(" "));
}
}

37
src/gbp-leaderboard.py Normal file
View File

@ -0,0 +1,37 @@
"""
Print your own GBP leaderboard!
"""
import requests
#fetch latest gbp
response = requests.get(url = "https://raw.githubusercontent.com/tgstation/tgstation/gbp-balances/.github/gbp-balances.toml")
content = response.text
initial_file = []
line = ""
for char in content: # collect web page into each line
line += char
if char == '\n':
if (ord(line[0]) >= ord('0') and ord(line[0]) <= ord('9')): #make sure it starts with a github ID, else its not a valid line
initial_file.append(line)
line = ""
gbp = []
for line in initial_file: # split this into username and GBP
segments = line.split(" ")
temp = segments[-1]
if temp[-1:] == '\n':
segments[-1] = temp[:-1]
gbp.append([segments[-1], int(segments[2])])
for n in range(len(gbp)-1, 0, -1): #bubble sort
for i in range(n):
if gbp[i][1] < gbp[i + 1][1]:
gbp[i][1], gbp[i+1][1] = gbp[i+1][1], gbp[i][1]
gbp[i][0], gbp[i+1][0] = gbp[i+1][0], gbp[i][0]
with open("balances.txt", 'w') as file: # write to file
i = 1
for item in gbp:
file.write("#" + str(i) + " " + item[0] + " " + str(item[1]) + '\n')
i += 1

View File

@ -1,125 +1,53 @@
#include <curl/curl.h>
#include <curl/easy.h>
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>
#include <Python.h>
#define URL "https://raw.githubusercontent.com/tgstation/tgstation/gbp-balances/.github/gbp-balances.toml"
#define FILE_NAME "gbp"
void fetch_raw_gbp()
{
CURL *curl;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, URL);
FILE* GBP = fopen(FILE_NAME, "w");
curl_easy_setopt(curl, CURLOPT_WRITEDATA, GBP);
curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(GBP);
}
}
std::vector<std::string> parse_raw_gbp()
{
std::ifstream file;
file.open(FILE_NAME);
if (!file) { // if the file doesnt exist, lets force it
fetch_raw_gbp();
file.open(FILE_NAME);
}
std::vector<std::string> out;
std::string line;
while (getline(file, line)) {
if (line[0] >= '0' && line[0] <= '9')
out.push_back(line);
}
return out;
}
std::vector<std::pair<short int, std::string>> fetch_gbp_info()
{
std::vector<std::string> in = parse_raw_gbp();
std::vector<std::pair<short int, std::string>> out;
for (std::vector<std::string>::iterator it = in.begin(); it != in.end(); it++) {
std::string line = (*it);
std::string username = line.substr(line.find("#") + 2, line.length() - (line.find("#") + 1));
int gbp = std::stoi(line.substr(line.find("=") + 2, line.find("#") - 1 - line.find("#")));
std::pair<short int, std::string> info = {gbp, username};
out.push_back(info);
}
return out;
}
std::map<unsigned short int, std::pair<short int, std::string>> fetch_formatted_gbp()
{
std::vector<std::pair<short int, std::string>> in = fetch_gbp_info();
std::sort(in.begin(), in.end(),
[](std::pair<short int, std::string> a, std::pair<short int, std::string> b) { // lambda expression to reverse the compare method
return (a.first > b.first);
}
);
std::map<unsigned short int, std::pair<short int, std::string>> out;
for (int i = 1; i <= in.size(); i++)
out[i] = in[i-1];
return out;
}
#undef URL
#undef FILE_NAME
/*
* Commands
/**
* ##fetchLatestGBP
*
* Uses the python script located in /src/ to fetch the latest GBP and write it to a file
*/
std::string find_gbp_pos(int num_to_find)
void fetchLatestGBP()
{
std::map<unsigned short int, std::pair<short int, std::string>> gbp = fetch_formatted_gbp();
std::map<unsigned short int, std::pair<short int, std::string>>::iterator it = gbp.find(num_to_find);
if (it == gbp.end())
return "Could not find user at that position!";
return "```#" + std::to_string(num_to_find) + ": " + gbp[num_to_find].second+ " (" + std::to_string(gbp[num_to_find].first) + " GBP)```\n";
FILE* fp;
Py_Initialize();
fp = _Py_fopen("../src/gbp-leaderboard.py", "r");
PyRun_SimpleFile(fp, "../src/gbp-leaderboard.py");
Py_Finalize();
}
std::string find_gbp(int gbp_to_find)
/**
* ##readGBPIntoList
*
* Returns a map of containing the contents of the GBP file.
* Formatted as <position (unsigned short int), <gbp amount (int), username (std::string)>>
*/
std::map<unsigned short int, std::pair<int, std::string>>readGBPIntoList()
{
std::string out = "```";
std::map<unsigned short int, std::pair<short int, std::string>> gbp = fetch_formatted_gbp();
for (std::map<unsigned short int, std::pair<short int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
if ((*it).second.first == gbp_to_find)
out += "#" + std::to_string((*it).first) +": " + (*it).second.second + " (" + std::to_string((*it).second.first) + " GBP)\n";
std::map<unsigned short int, std::pair<int, std::string>> GBP;
std::ifstream file;
file.open("balances.txt");
std::string line;
int i = 1;
while(getline(file, line)) {
std::string username = line.substr(line.find(" "), line.rfind(" ") - line.find(" "));
int tGBP = std::stoi(line.substr(line.rfind(" "), line.length() - line.rfind(" ")));
GBP.insert({i, {tGBP, username}});
i++;
}
out += "```";
if (out == "``````")
return "Could not find any user with that amount of GBP!";
return out;
file.close();
return GBP;
}
std::string find_username(std::string username)
/**
* fetches latest GBP, and then reads it into a map
*/
std::map<unsigned short int, std::pair<int, std::string>>fetchAndReadGBP()
{
std::string out = "```";
std::map<unsigned short int, std::pair<short int, std::string>> gbp = fetch_formatted_gbp();
for (std::map<unsigned short int, std::pair<short int, std::string>>::iterator it = gbp.begin(); it != gbp.end(); it++) {
if ((*it).second.second.find(username) != -1)
out += "#" + std::to_string((*it).first) +": " + (*it).second.second + " (" + std::to_string((*it).second.first) + " GBP)\n";
}
out += "```";
if (out == "``````")
return "Could not find any user named " + username + "!";
return out;
fetchLatestGBP();
return readGBPIntoList();
}

View File

@ -1,26 +1,110 @@
#include <cstddef>
#include <dpp/appcommand.h>
#include <dpp/dispatcher.h>
#include <dpp/dpp.h>
#include <dpp/intents.h>
#include <dpp/message.h>
#include <dpp/once.h>
#include <dpp/queues.h>
#include <dpp/nlohmann/json.hpp>
#include <fstream>
#include <bits/stdc++.h>
#include <string>
#include "commands.cpp"
using json = nlohmann::json;
#define BOT_COMMAND "!gbp"
/**
* ##separateArgs
*
* Returns a vector of each word in the given input, split by " "
*
* Arguments:
* * std::string args - The string to split up
*/
std::vector<std::string> separateArgs(std::string args)
{
std::vector<std::string> out;
while (1) {
if (args.find(" ") == -1) {
out.push_back(args);
break;
}
out.push_back(args.substr(0, args.find(" ")));
args = args.substr(args.find(" ") + 1, args.length() - (args.find(" ") + 1));
}
return out;
}
/**
* ##hasCommand
*
* If the given message starts with the bots command BOT_COMMAND, return true
*
* Arguments:
* * dpp::message msg - The message in question
*/
bool hasCommand(dpp::message msg)
{
return msg.content.substr(0, (msg.content.find(" "))) == std::string(BOT_COMMAND);
}
/**
* ##onMessage
*
* Handles message commands
*
* Arguments:
* * dpp::cluster &bot - The discord bot
* * dpp::message msg - The received message
*/
void onMessage(dpp::cluster &bot, dpp::message msg)
{
if (!hasCommand(msg))
return;
int argIdx = msg.content.find(" ") + 1;
std::string argument = msg.content.substr(argIdx, msg.content.length() - argIdx);
/* Parse the command */
std::vector<std::string> args = separateArgs(argument);
std::string msgContent = commandParse(args);
/* Here we check if we should embed a file, or just send a message */
std::vector<std::string> messageArgs = separateArgs(msgContent);
dpp::message toSend;
if (messageArgs[0] == std::string(FILE_WARNING)) {
toSend = dpp::message(msg.channel_id, "");
toSend.add_file(messageArgs[2], dpp::utility::read_file(messageArgs[1]));
} else
toSend = dpp::message(msg.channel_id, msgContent);
/* Send the message */
bot.message_create(toSend);
}
int main()
{
/* Setup the bot **/
json config;
std::ifstream config_file("../config.json");
config_file >> config;
std::ifstream configFile("../config.json");
configFile >> config;
std::string token = config["token"];
dpp::cluster bot(token, dpp::i_default_intents | dpp::i_message_content);
/* Start listening to commands */
bot.on_log(dpp::utility::cout_logger());
initCommands();
dpp::commandhandler command_handler(&bot);
command_handler.add_prefix("!gbp ");
init_commands(command_handler);
bot.on_message_create([&](const dpp::message_create_t &event) {
if (event.msg.author.id != bot.me.id) // don't respond to own messages
onMessage(bot, event.msg);
});
bot.start(false);
return 0;
}

43
src/notify.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <thread>
#include <fstream>
#include <iostream>
#include <vector>
#include "gbp.cpp"
void startScanning()
{
while (1) {
// read from the cached file contianing names to watch, if the gbp their position is > or < what is marked down, Ping the original recpiient that their locatoin has changed and then sleep for an hour,
}
}
void pingUsers()
{
std::ifstream file;
file.open("toPing.txt");
if (!file) {
file.close();
return;
}
std::string line;
std::string username;
int gbpPos;
std::string toPing;
while(getline(file, line)) {
username = line.substr(0, line.find(" "));
gbpPos = std::stoi(line.substr(line.find(" ") + 1, line.length() - (line.find(" ") + 1)));
toPing = line.substr(line.rfind(" "), line.length() - line.rfind(" "));
std::map<unsigned short int, std::pair<int, std::string>> gbp = fetchAndReadGBP();
if (gbp[gbpPos].second == username) {
std::cout << "chungus" << std::endl;
} else {
// message
}
}
}