Skip to content

Commit 629532f

Browse files
committed
Базовые функции для работы с Max
1 parent 690a9b8 commit 629532f

257 files changed

Lines changed: 4476 additions & 6977 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ycm_extra_conf.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
from distutils.sysconfig import get_python_inc
2+
import platform
3+
import os
4+
import subprocess
5+
import ycm_core
6+
7+
DIR_OF_THIS_SCRIPT = os.path.abspath( os.path.dirname( __file__ ) )
8+
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
9+
10+
flags = [
11+
'-Wall',
12+
'-Wextra',
13+
'-Werror',
14+
'-x',
15+
'c++',
16+
'-std=c++23',
17+
'-I', DIR_OF_THIS_SCRIPT + '/include',
18+
'-I', '/usr/include',
19+
]
20+
21+
22+
23+
# Set this to the absolute path to the folder (NOT the file!) containing the
24+
# compile_commands.json file to use that instead of 'flags'. See here for
25+
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
26+
#
27+
# You can get CMake to generate this file for you by adding:
28+
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
29+
# to your CMakeLists.txt file.
30+
#
31+
# Most projects will NOT need to set this to anything; you can just change the
32+
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
33+
compilation_database_folder = ''
34+
35+
if os.path.exists( compilation_database_folder ):
36+
database = ycm_core.CompilationDatabase( compilation_database_folder )
37+
else:
38+
database = None
39+
40+
41+
def IsHeaderFile( filename ):
42+
extension = os.path.splitext( filename )[ 1 ]
43+
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
44+
45+
46+
def FindCorrespondingSourceFile( filename ):
47+
if IsHeaderFile( filename ):
48+
basename = os.path.splitext( filename )[ 0 ]
49+
for extension in SOURCE_EXTENSIONS:
50+
replacement_file = basename + extension
51+
if os.path.exists( replacement_file ):
52+
return replacement_file
53+
return filename
54+
55+
56+
def Settings( **kwargs ):
57+
if kwargs[ 'language' ] == 'cfamily':
58+
# If the file is a header, try to find the corresponding source file and
59+
# retrieve its flags from the compilation database if using one. This is
60+
# necessary since compilation databases don't have entries for header files.
61+
# In addition, use this source file as the translation unit. This makes it
62+
# possible to jump from a declaration in the header file to its definition
63+
# in the corresponding source file.
64+
filename = FindCorrespondingSourceFile( kwargs[ 'filename' ] )
65+
66+
if not database:
67+
return {
68+
'flags': flags,
69+
'include_paths_relative_to_dir': DIR_OF_THIS_SCRIPT,
70+
'override_filename': filename
71+
}
72+
73+
compilation_info = database.GetCompilationInfoForFile( filename )
74+
if not compilation_info.compiler_flags_:
75+
return {}
76+
77+
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
78+
# python list, but a "list-like" StringVec object.
79+
final_flags = list( compilation_info.compiler_flags_ )
80+
81+
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
82+
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
83+
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
84+
try:
85+
final_flags.remove( '-stdlib=libc++' )
86+
except ValueError:
87+
pass
88+
89+
return {
90+
'flags': final_flags,
91+
'include_paths_relative_to_dir': compilation_info.compiler_working_dir_,
92+
'override_filename': filename
93+
}
94+
return {}
95+

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ option(BUILD_SHARED_LIBS "Build maxbot-cpp shared/static library." OFF)
1111
option(BUILD_DOCUMENTATION "Build doxygen API documentation." OFF)
1212

1313
# sources
14-
set(CMAKE_CXX_STANDARD 17)
14+
set(CMAKE_CXX_STANDARD 20)
1515
set(CMAKE_CXX_STANDARD_REQUIRED ON)
16-
set(CMAKE_CXX_EXTENSIONS OFF)
16+
set(CMAKE_CXX_EXTENSIONS ON)
1717
if(WIN32)
1818
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
1919
add_definitions(-D_WIN32_WINNT=0x0601)
@@ -30,6 +30,8 @@ set(SRC_LIST
3030
src/EventHandler.cpp
3131
src/BotException.cpp
3232
src/BotTypeParser.cpp
33+
src/BotTypeParserBase.cpp
34+
src/BotTypeParserUpdates.cpp
3335
src/net/BoostHttpOnlySslClient.cpp
3436
src/net/CurlHttpClient.cpp
3537
src/net/HttpParser.cpp
@@ -46,7 +48,6 @@ set(SRC_LIST
4648
src/types/InputMessageContent.cpp
4749
src/types/MenuButton.cpp
4850
src/types/MessageOrigin.cpp
49-
src/types/PassportElementError.cpp
5051
src/types/ReactionType.cpp)
5152

5253
# libs
@@ -63,6 +64,7 @@ include_directories(${OPENSSL_INCLUDE_DIR})
6364
## curl
6465
find_package(CURL 7.58.0)
6566
if (CURL_FOUND)
67+
message("CURL available")
6668
include_directories(${CURL_INCLUDE_DIRS})
6769
add_definitions(-DHAVE_CURL)
6870
endif()
@@ -159,5 +161,5 @@ if(BUILD_DOCUMENTATION)
159161
endif()
160162

161163
if(BUILD_SHARED_LIBS)
162-
add_definitions(-DTGBOT_DLL)
164+
add_definitions(-DMAXBOT_DLL)
163165
endif()

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ Simple echo bot which sends everything it receives:
2323
```cpp
2424
#include <stdio.h>
2525
#include <maxbot/maxbot.h>
26+
#include <maxbot/net/CurlHttpClient.h>
2627

2728
int main() {
28-
MaxBot::Bot bot("PLACE YOUR TOKEN HERE");
29+
30+
CurlHttpClient client("PLACE YOUR TOKEN HERE");
31+
MaxBot::Bot bot(client);
2932
bot.getEvents().onCommand("start", [&bot](MaxBot::Message::Ptr message) {
3033
bot.getApi().sendMessage(message->chat->id, "Hi!");
3134
});
@@ -163,9 +166,9 @@ g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lMaxBot -
163166
### Build options
164167

165168
```
166-
-DTGBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm'
167-
-DTGBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion
168-
-DTGBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion
169+
-DMAXBOT_DISABLE_NAGLES_ALGORITHM # Disable 'Nagle's algorithm'
170+
-DMAXBOT_CHANGE_SOCKET_BUFFER_SIZE # Socket Buffer Size Expansion
171+
-DMAXBOT_CHANGE_READ_BUFFER_SIZE # Read Buffer Size Expansion
169172
```
170173

171174

0 commit comments

Comments
 (0)