Skip to content

Commit

Permalink
Add files
Browse files Browse the repository at this point in the history
  • Loading branch information
alllex committed Oct 3, 2023
1 parent 89c5540 commit 55d2671
Show file tree
Hide file tree
Showing 46 changed files with 43,620 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
root = true

[*]
indent_size = 4
indent_style = space
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[gradlew.bat]
end_of_line = crlf

[{*.yaml,*.yml}]
indent_size = 2
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

* text eol=lf

# These are explicitly windows files and should use crlf
*.bat text eol=crlf

# These files are text and should be normalized (Convert crlf => lf)
*.sh text eol=lf

# Mark Gradle wrapper as a binary
gradle/wrapper/gradle-wrapper.jar binary
1 change: 1 addition & 0 deletions .github/workflows/.ci-java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
28 changes: 28 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Check

on:
workflow_dispatch: {}
pull_request: {}
push:
branches: [ main ]
tags: [ 'v*' ]

concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: zulu
java-version-file: .github/workflows/.ci-java-version

- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true
arguments: check
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

on:
workflow_dispatch: {}
push:
tags:
- 'v*'

concurrency:
group: "release"
cancel-in-progress: false

jobs:
gradle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: zulu
java-version-file: .github/workflows/.ci-java-version

- uses: gradle/gradle-build-action@v2
with:
gradle-home-cache-cleanup: true

- name: Publish artifacts
run: ./gradlew :publishToSonatype :closeAndReleaseSonatypeStagingRepository --no-configuration-cache
env:
ORG_GRADLE_PROJECT_signingKeyId: ${{secrets.SIGNING_KEY_ID}}
ORG_GRADLE_PROJECT_signingKey: ${{secrets.SIGNING_KEY}}
ORG_GRADLE_PROJECT_signingPassword: ${{secrets.SIGNING_PASSWORD}}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{secrets.SONATYPE_USERNAME}}
ORG_GRADLE_PROJECT_sonatypePassword: ${{secrets.SONATYPE_PASSWORD}}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Gradle
.gradle
build

# IDEA
.idea
*.iml
out

# Platform-specific
# MacOS
.DS_Store

# Custom development files
/dev
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) 2023 Aleksei Semin

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.
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Telegram Bot API in Kotlin

Idiomatic, fluent and type-safe Kotlin bindings for [Telegram Bot API](https://core.telegram.org/bots/api).

```kotlin
val poller = TelegramBotApiPoller(TelegramBotApiClient(botApiToken))
poller.start(TelegramBotUpdateListener(
onMessage = { message ->
message.reply(
text = "Hello, *${message.from?.firstName ?: "stranger"}*!",
parseMode = ParseMode.MARKDOWN,
replyMarkup = inlineKeyboard {
buttonLink("Telegram", "https://telegram.org")
row {
button("Bot", "bot")
button("API", "api")
}
}
)
},
onCallbackQuery = { callbackQuery ->
when (callbackQuery.data) {
"bot" -> callbackQuery.answer("🤖")
"api" -> callbackQuery.answer("🚀")
else -> callbackQuery.answer("🤷")
}
}
))
```

## Compatibility

The bindings are generated directly from the source-of-truth [Bot API spec](https://core.telegram.org/bots/api).

| Telegram Bot API | tbot-api library |
|------------------|------------------|
| 6.9 | 0.4.0 |


## Developing

### Updating API to a new version of Telegram Bot API

```
./gradlew :buildSrc:updateApiSpec --no-configuration-cache
./gradlew generateTelegramBotApi
./gradlew apiDump
./gradlew check
```

## Roadmap

### Alpha

- [ ] Error handling

### Beta

- [ ] Cleaner package structure
- [ ] Strict library member visibility
- [ ] Forward compatibility: published versions of the library should not break with new API versions (union types and enums)
- [ ] Support for integration tests bots
Loading

0 comments on commit 55d2671

Please sign in to comment.