Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bf1a2ea
Первый комит
Jan 23, 2025
a551c78
start work
Meytardzhevtd Feb 10, 2025
45801ad
sdfsdfdsf
Meytardzhevtd Feb 12, 2025
877a02b
create OfficeStaffClass
Meytardzhevtd Feb 13, 2025
41a9cbf
create two functions in main.cpp, good job
Meytardzhevtd Feb 13, 2025
6e3476e
Create Teacher class and main.cpp was redone but note finished
Meytardzhevtd Feb 15, 2025
e66b74f
create tutor interface
Meytardzhevtd Feb 24, 2025
39c2fb1
create sop basic
Meytardzhevtd Feb 24, 2025
e6e5c60
fdsfd
Meytardzhevtd Feb 24, 2025
3e1e8f4
new codestyle
Meytardzhevtd Feb 24, 2025
3cd1c75
create two files
Meytardzhevtd Feb 24, 2025
b09d177
redone README and clang-tidy
Meytardzhevtd Feb 24, 2025
fdbfac1
commit 24.02.37
Meytardzhevtd Feb 24, 2025
30b642d
redone README
Meytardzhevtd Feb 24, 2025
493639b
redone README
Meytardzhevtd Feb 24, 2025
41d12c0
create LICENSE
Meytardzhevtd Feb 25, 2025
19a7b3f
fsdf
Meytardzhevtd Feb 25, 2025
7e92854
modified sop.hpp
Meytardzhevtd Feb 25, 2025
163ed79
I can do itgit add .!
Meytardzhevtd Feb 25, 2025
604cc14
fdfssdf
Meytardzhevtd Feb 25, 2025
bc0b7e8
create .github
Meytardzhevtd Mar 3, 2025
5ce0bf0
create .github
Meytardzhevtd Mar 3, 2025
f740c4f
Resolved merge conflicts
Meytardzhevtd Mar 3, 2025
14a780d
renode .github
Meytardzhevtd Mar 3, 2025
7af99d6
redone .github
Meytardzhevtd Mar 4, 2025
17b2b1a
redone .github
Meytardzhevtd Mar 4, 2025
752ff82
redone .github
Meytardzhevtd Mar 4, 2025
5bee22b
redone .github
Meytardzhevtd Mar 4, 2025
0fef003
redone .github
Meytardzhevtd Mar 4, 2025
dcea22f
redone .github
Meytardzhevtd Mar 4, 2025
ba341bd
redone .github
Meytardzhevtd Mar 4, 2025
7023def
redone .github
Meytardzhevtd Mar 4, 2025
509a936
redone .github
Meytardzhevtd Mar 4, 2025
2ad9e79
redone .github
Meytardzhevtd Mar 4, 2025
10d64b3
redone .github
Meytardzhevtd Mar 4, 2025
fb9be1b
redone .github
Meytardzhevtd Mar 4, 2025
a6709f3
redone .github
Meytardzhevtd Mar 4, 2025
96f2e9e
redone .github
Meytardzhevtd Mar 4, 2025
ea3a1c0
redone .yml
Meytardzhevtd Mar 5, 2025
3bdc9e0
sdfs
Meytardzhevtd Mar 5, 2025
005c914
I can do itgit add .git add .
Meytardzhevtd Mar 5, 2025
9726748
redone cppcheck
Meytardzhevtd Mar 5, 2025
39b3a08
redone cppcheck
Meytardzhevtd Mar 5, 2025
7d66cdf
redone cppcheck
Meytardzhevtd Mar 5, 2025
ab19eff
redone cppcheck
Meytardzhevtd Mar 5, 2025
1f180cc
redone cppcheck
Meytardzhevtd Mar 5, 2025
63e1d05
redone cppcheck
Meytardzhevtd Mar 5, 2025
bfa4221
fdsfdf
Meytardzhevtd Mar 9, 2025
d564748
add library
Meytardzhevtd Mar 9, 2025
d20ed0a
Update CMakeLists.txt
Meytardzhevtd Mar 9, 2025
5e43687
Update CMakeLists.txt
Meytardzhevtd Mar 9, 2025
287527c
Create declaration function
Meytardzhevtd Apr 1, 2025
2f1d4cb
fdfsdfs
Meytardzhevtd May 11, 2025
766a726
Update main.cpp
Meytardzhevtd May 30, 2025
b70e4ff
Update CMakeLists.txt
Meytardzhevtd May 31, 2025
fa6a70c
Update CMakeLists.txt
Meytardzhevtd May 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
BasedOnStyle: Google

AccessModifierOffset: -4

AccessModifierOffset: -2
AlignTrailingComments: true
IndentPPDirectives: AfterHash
IndentWidth: 4
Expand All @@ -15,11 +15,14 @@ BreakBeforeTernaryOperators: true
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: true

IncludeBlocks: Regroup
IncludeBlocks: Regroup

SortIncludes: true

SpaceBeforeParens: ControlStatements
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
...

...

53 changes: 53 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Clang Format Check

on:
push:
branches:
- '**'

jobs:
clang-format:
runs-on: ubuntu-latest

steps:
# Шаг 1: Checkout репозитория
- name: Checkout repository
uses: actions/checkout@v3

# Шаг 2: Установка зависимостей
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-format clang-tidy libboost-all-dev \
libcurl4-openssl-dev libpq-dev \
nlohmann-json3-dev libpqxx-dev

# Шаг 3: Установка TgBot
- name: Install TgBot
run: |
git clone https://github.com/reo7sp/tgbot-cpp.git
cd tgbot-cpp
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install

# Шаг 4: Кэширование директории сборки
- name: Cache Build Directory
uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-

# Шаг 5: Конфигурация CMake
- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTgBot_DIR=/usr/local/lib/cmake/TgBot

# Шаг 6: Запуск Clang Format
- name: Run Clang Format
run: |
find include source -name '*.cpp' -o -name '*.h' | xargs clang-format -i
git diff --exit-code || (echo "Clang format check failed! Run clang-format and commit changes."; exit 1)
64 changes: 64 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Static Analysis Checks

on:
push:
branches:
- '**'

defaults:
run:
working-directory: .

jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-format clang-tidy libboost-all-dev \
libcurl4-openssl-dev libpq-dev \
nlohmann-json3-dev libpqxx-dev

- name: Install TgBot
run: |
git clone https://github.com/reo7sp/tgbot-cpp.git
cd tgbot-cpp
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install

- name: Cache Build Directory
uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTgBot_DIR=/usr/local/lib/cmake/TgBot


clang-tidy:
needs: install-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Restore Cached Build
uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-build-${{ github.sha }}

- name: Run Clang Tidy
run: |
# Найдем все исходные файлы (.cpp и .h) в нужных папках (source, include), исключая build
clang-tidy source/*.cpp include/*.hpp
27 changes: 27 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CppCheck Analysis

on:
push:
branches:
- '**'

jobs:
cppcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cppcheck

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run CppCheck
run: |
# Указываем CppCheck проверять только исходные файлы в папке source или include
cppcheck --enable=all --inconclusive --quiet --error-exitcode=1 source/ include/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
BotToken.hpp
/build
.vscode/
.idea/
build/

# Prerequisites
*.d

Expand Down
91 changes: 60 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,60 @@
cmake_minimum_required(VERSION 3.10)
project(TelegramBot)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(Boost REQUIRED COMPONENTS system)
find_package(TgBot REQUIRED)

target_include_directories(include)

file(GLOB SOURCES source/*.cpp)

add_executable(my_bot ${SOURCES})

target_link_libraries(my_bot Boost::system TgBot::TgBot)


if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(my_bot PRIVATE
-g
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
target_link_options(my_bot PRIVATE
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
endif()
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(MyProject)

include_directories(include)

file(GLOB SOURCES source/*.cpp)

add_executable(main ${SOURCES})

include(cmake/CPM.cmake)

CPMAddPackage(
NAME Boost
VERSION 1.86.0
URL https://github.com/boostorg/boost/releases/download/boost-1.86.0/boost-1.86.0-cmake.tar.xz
URL_HASH SHA256=2c5ec5edcdff47ff55e27ed9560b0a0b94b07bd07ed9928b476150e16b0efc57
OPTIONS "BOOST_ENABLE_CMAKE ON" "BOOST_SKIP_INSTALL_RULES ON"
"BUILD_SHARED_LIBS OFF" "BOOST_INCLUDE_LIBRARIES system"
)

CPMAddPackage(
NAME TgBot
GIT_REPOSITORY https://github.com/reo7sp/tgbot-cpp.git
GIT_TAG master
)

CPMAddPackage(
NAME nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.2
)

CPMAddPackage(
NAME libcurl
GIT_REPOSITORY https://github.com/curl/curl.git
GIT_TAG curl-8_1_2
OPTIONS "BUILD_CURL_EXE OFF" "BUILD_TESTING OFF"
)

CPMAddPackage(
NAME libpqxx
GIT_REPOSITORY https://github.com/jtv/libpqxx.git
GIT_TAG 7.6.0
)

CPMAddPackage(
NAME fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.2.1 # можно заменить на нужную версию
)

target_link_libraries(main
Boost::system
TgBot
nlohmann_json::nlohmann_json
curl
pqxx
fmt::fmt
)
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Melnikov Kirill

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.7)
set(CPM_HASH_SUM "c0fc82149e00c43a21febe7b2ca57b2ffea2b8e88ab867022c21d6b81937eb50")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
16 changes: 16 additions & 0 deletions include/OfficeStaff.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef OFFECESTAFF_HPP_
#define OFFECESTAFF_HPP_

#include "User.hpp"

namespace mtd {
class OfficeStaff : public User {
public:
OfficeStaff(int64_t chat_id);
TgBot::InlineKeyboardMarkup::Ptr GetInlineKeyboard() override;
TgBot::InlineKeyboardMarkup::Ptr GetMenu() override;
TgBot::InlineKeyboardMarkup::Ptr BackButton() override;
};
} // namespace mtd

#endif
16 changes: 16 additions & 0 deletions include/Student.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef STUDENT_GPP_
#define STUDENT_GPP_

#include "User.hpp"

namespace mtd {
class Student : public User {
public:
Student(int64_t chat_id);
TgBot::InlineKeyboardMarkup::Ptr GetInlineKeyboard() override;
TgBot::InlineKeyboardMarkup::Ptr GetMenu() override;
TgBot::InlineKeyboardMarkup::Ptr BackButton() override;
};
} // namespace mtd

#endif
16 changes: 16 additions & 0 deletions include/Teacher.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef TEACHER_HPP_
#define TEACHER_HPP_

#include "User.hpp"

namespace mtd {
class Teacher : public User {
public:
Teacher(int64_t chat_id);
TgBot::InlineKeyboardMarkup::Ptr GetInlineKeyboard() override;
TgBot::InlineKeyboardMarkup::Ptr GetMenu() override;
TgBot::InlineKeyboardMarkup::Ptr BackButton() override;
};
} // namespace mtd

#endif
16 changes: 16 additions & 0 deletions include/Tutor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef TUTOR_HPP_
#define TUTOR_HPP_

#include "User.hpp"

namespace mtd {
class Tutor : public User {
public:
Tutor(int64_t chat_id);
TgBot::InlineKeyboardMarkup::Ptr GetInlineKeyboard() override;
TgBot::InlineKeyboardMarkup::Ptr GetMenu() override;
TgBot::InlineKeyboardMarkup::Ptr BackButton() override;
};
} // namespace mtd

#endif
Loading
Loading