Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/workflows/telebot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: prepare
run: sudo apt install -y pkg-config libcurl4-openssl-dev libjson-c-dev cmake binutils make
- name: cmake
run: sudo apt update && sudo apt install -y pkg-config libcurl4-openssl-dev libjson-c-dev cmake binutils make
- name: cmake
run: mkdir -p build && cd build && cmake ..
- name: make
run: cd build && make
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ build

# CLion projects
.idea

27 changes: 23 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(EXEC_PREFIX "${PREFIX}/bin")
SET(INCLUDEDIR "${PREFIX}/include/${PROJECT_NAME}")
SET(LIBDIR "${PREFIX}/lib")
SET(VERSION 4.7.1)
SET(VERSION 9.4)

SET(CMAKE_MACOSX_RPATH 1)

SET(SRCS
src/telebot-parser.c
src/telebot-core.c
src/telebot.c
src/telebot-inline.c
src/telebot-forums.c
src/telebot-payments.c
src/telebot-passport.c
src/telebot-games.c
)

ADD_DEFINITIONS("-DDEBUG=0")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(DEPENDENTS "libcurl json-c")
INCLUDE(FindPkgConfig)
Expand All @@ -25,7 +29,16 @@ pkg_check_modules(PKGS REQUIRED ${DEPENDENTS})
FOREACH(flag ${PKGS_CFLAGS})
SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}")
ENDFOREACH(flag)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS} -Werror -Wall -Wno-unused-function -O2" )
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS} -Werror -Wall -Wno-unused-function" )

#Debug option
IF(DEBUG)
MESSAGE("Build debug version")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
ADD_DEFINITIONS("-DDEBUG")
ELSE(DEBUG)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
ENDIF(DEBUG)

# libtelebot
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
Expand All @@ -36,7 +49,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION})
# package configuration
CONFIGURE_FILE(telebot.pc.in telebot.pc @ONLY)

# echobot (test)
# testbot (test)
ADD_SUBDIRECTORY(test)

# CMake Policy (CMP0002)
Expand All @@ -50,5 +63,11 @@ INSTALL(FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-methods.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-types.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-core.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-stickers.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-inline.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-forums.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-payments.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-passport.h
${CMAKE_CURRENT_SOURCE_DIR}/include/telebot-games.h
DESTINATION include/telebot/)

6 changes: 3 additions & 3 deletions Doxyconf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Telebot"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 4.7.0
PROJECT_NUMBER = 9.4

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand All @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY = docs

# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -743,7 +743,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = include
INPUT = README.md include

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,32 @@ To build the library run following commands:

```sh
cd [your repository]
mkdir -p Build && cd Build
cmake ../
mkdir -p build && cd build
cmake ..
make
```

For debug build
```sh
mkdir -p build && cd build
cmake .. -DDEBUG=1
make
```

## Testing

Place Telegam Bot API Token in `.token` file in the root folder of the repository, and run as below
```sh
./build/test/testbot
```

<details>
<summary>Sample</summary>

Following sample creates a simple dummy bot which echoes back the messages sent to it.
The [same example](test/echobot.c) is built as `echobot` executable under `Build/test` folder. The
executable expects and reads bot token from `.token` file on the same location.
A more comprehensive [test bot](test/testbot.c) is built as `testbot` executable under `Build/test` folder.
It supports various commands to test APIs, polls, custom keyboards, and multimedia sending.
The executable expects and reads bot token from `.token` file on the same location.

```c
#include <stdio.h>
Expand Down
Loading