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