Giter VIP home page Giter VIP logo

nerzh / telegram-vapor-bot Goto Github PK

View Code? Open in Web Editor NEW
188.0 6.0 26.0 854 KB

🤖 The wrapper for the Telegram Bot API written in Swift with Vapor. It's not a framework. There is no special syntax here. This is a library that implements all Telegram Bot API methods, which is available to you to work with Vapor.

Home Page: https://core.telegram.org/bots/api#available-methods

License: MIT License

Swift 96.65% Ruby 3.35%
telegram telegram-bot telegram-bot-api bot swift server-side-swift vapor async await await-async

telegram-vapor-bot's Issues

Бот перестает реагировать

Привет! Есть ли у бота какой-то таймаут? Такое чувство, что, если не пользоваться им 3-4 часа, он просто перестает реагировать. Причем в консоль ничего не выводится, процесс Vapor запущен и работает, а бот не отвечает. Делал на основе примера.

Предупреждения в файле TelegramController.swift

Постоянно в Xcode висят предупреждения:

  1. "Converting non-sendable function value to '@sendable (Request) async throws -> Bool' may introduce data races".
  2. "Non-sendable type 'any TGConnectionPrtcl' in implicitly asynchronous access to actor-isolated property 'connection' cannot cross actor boundary" - исправляеься заменой "import TelegramVaporBot" на "@preconcurrency import TelegramVaporBot"
    Xcode v.15.3, Swift v.5.10

Thread 76: Fatal error: String index is out of bounds

Когда кто-то из пользователей пересылает в чат длинное сообщение, или перепост, бот падает с ошибкой Fatal error: String index is out of bounds со ссылкой на строку 70 в файле CommandHandler

Снимок экрана 2022-01-12 в 12 04 08

Consider Declarative Syntax

В конце файла Readme.md можно увидеть следующий отрывок кода:

// swift-tools-version:5.8

import PackageDescription

var packageDependencies: [Package.Dependency] = [
    .package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.57.0")),
]

packageDependencies.append(.package(url: "https://github.com/nerzh/telegram-vapor-bot", .upToNextMajor(from: "2.1.0")))


let package = Package(
    name: "Telegram-bot-example",
    platforms: [
        .macOS(.v12)
    ],
    dependencies: packageDependencies,
    targets: [
        .executableTarget(
            name: "Telegram-bot-example",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
                .product(name: "TelegramVaporBot", package: "telegram-vapor-bot"),
            ]
        )
    ]
)

Слайд 58 материала для разработчиков от Apple говорит нам о том, что лучше использовать декларативный синтаксис подразумевая, что вместо отрывка кода выше будет отрывок кода ниже:

// swift-tools-version:5.8

import PackageDescription

let package = Package(
    name: "Telegram-bot-example",
    platforms: [
        .macOS(.v12)
    ],
    dependencies: [
        .package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "4.57.0")),
        .package(url: "https://github.com/nerzh/telegram-vapor-bot", .upToNextMajor(from: "2.1.0"))
    ],
    targets: [
        .executableTarget(
            name: "Telegram-bot-example",
            dependencies: [
                .product(name: "Vapor", package: "vapor"),
                .product(name: "TelegramVaporBot", package: "telegram-vapor-bot"),
            ]
        )
    ]
)

Честно сказать, не знаю как это в теории может повлиять на что-либо, но почему нет :)

Ну и по мелочи можно убрать лишние пробельные символы после всего листинга.

Request support for Concurrency and Web App.

Your project is a great library! It has a lot of fun features when combined with Vapor. The combination with Vapor is also great for making Telegram Web App for Bot.

Request support for these features:

  • async/await makes it easier to read and is now supported by most of the libraries still being updated.
  • Telegram is supporting Web App for Bot this year and we hope to add these features.
    https://core.telegram.org/bots/webapps

Connecting to database.

Can you make a quick explanation on connecting to fluent database? Really appreciate that.

Buttons in place of the keyboard

Hi! Thank you for your work!
Please, show me tan example how to make buttons not in chat, but in place of the keyboard.
Is there any documentation?

Confusing error message

[ com.tgbot ] [ ERROR ] 
>>>Type: server
>>>Description: Response marked as `not Ok`, it seems something wrong with request
Code: 404
Not Found
>>>Reason: 
 (TelegramVaporBot/TGClient.swift:145)
[ codes.vapor.application ] [ DEBUG ] Application shutting down (Vapor/Application.swift:235)
[ codes.vapor.application ] [ TRACE ] Shutting down providers (Vapor/Application.swift:237)
[ codes.vapor.application ] [ TRACE ] Clearing Application storage (Vapor/Application.swift:241)
[ codes.vapor.application ] [ DEBUG ] Shutting down connection pool [ahc-pool-key: https://api.telegram.org:443 TLS-hash: 3820552592687539142 ] (AsyncHTTPClient/HTTPConnectionPool.swift:84)
[ codes.vapor.application ] [ TRACE ] Running on shared EventLoopGroup. Not shutting down EventLoopGroup. (Vapor/Application.swift:247)
[ codes.vapor.application ] [ TRACE ] Application shutdown complete (Vapor/Application.swift:258)
Swift/ErrorType.swift:200: Fatal error: Error raised at top level: TelegramVaporBot.BotError
zs

Is what follows Reason real reason? Or there's no reason here?

buttonsActionHandler does not work

When I trying to use buttons callback as it showed in example, I'm facing problem when bot can't reply to user. It seems because bot somehow forgets chat id. Example does not work too, actually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.