Coder Social home page Coder Social logo

givip / telegrammer Goto Github PK

View Code? Open in Web Editor NEW
289.0 13.0 41.0 682 KB

Telegram Bot - written with Swift 5.2 / NIO, supports Linux, macOS

License: MIT License

Ruby 2.35% Shell 0.01% Swift 95.79% C 1.86%
vapor swift swift-package-manager server-side-swift telegram-bot telegram-bot-api telegram ubuntu swiftnio swift5

telegrammer's People

Contributors

cooloneofficial avatar ferrerohub avatar givip avatar hootigger avatar nerzh avatar nikstar avatar theeshka avatar uetcis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegrammer's Issues

Problem running generate_wrappers.rb

Hi! I wanted to update generated files, but the script crashed on the line below

continue unless text.length != 0

./generate_wrappers.rb:178:in `fetch_description': undefined local variable or method `continue' for main:Object (NameError)

I'm not sure what continue is, but it does not seem to be part of ruby :)

As far as I can tell, commenting out this line does not break anything. Will it be safe to remove it?

Implement Message object helpers

  • caption_html
  • caption_html_urled
  • caption_markdown
  • caption_markdown_urled
  • chat_id
  • delete
  • edit_caption
  • edit_reply_markup
  • edit_text
  • effective_attachment
  • forward
  • parse_caption_entities
  • parse_caption_entity
  • parse_entities
  • parse_entity
  • reply_audio
  • reply_contact
  • reply_document
  • reply_html
  • reply_location
  • reply_markdown
  • reply_media_group
  • reply_photo
  • reply_sticker
  • reply_text
  • reply_venue
  • reply_video
  • reply_video_note
  • reply_voice
  • text_html
  • text_html_urled
  • text_markdown
  • text_markdown_urled

Extra argument 'from' in call

Hello!

First I want to thank you for your amazing library, I find it extremely convenient to work with.
Now back to my issue. I can't build my project if I use the function below

self.dispatcher.remove(handler: handler, from: group)

I get the error
Error:(76, 60) extra argument 'from' in call

I can't understand what's wrong with it. group variable is correct and has type HandlerGroup. I'm using Swift 4.1. Does your project successfully build using the line like this?

Thank you!

Implement Message Queue

Implements callback processing with proper delays to avoid hitting Telegram’s message limits.

Implement Delay Queue

Processes callbacks from queue with specified throughput limits. Creates a separate thread to process callbacks with delays.

Fail update dependency

swift package generate-xcodeproj return error after update to 0.5.4 version.

Console log:

error: multiple products named 'Logging' in: Console, swift-log
error: multiple targets named 'Logging' in: Console, swift-log

Swift version:

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.2.0

Crash on using combined filters (EXC_BAD_ACCESS)

When using a combined filter in a telegrammer-vapor-middleware based app like so (here a 'not'):

        let answerHandler = MessageHandler(filters: !Filters.command,
                                           callback: answerResponse)
        dispatcher.add(handler: answerHandler,to: HandlerGroup.answers)


it results in the following crash on an incoming update:
image

Not only for the logical not (!), but same result for other logical operations (like and: &&, or: ||)
Without logical operations it works like expected.

Language filter implementation

Filters messages to only allow those which are from users with a certain language code.

Note: According to telegrams documentation, every single user does not have the language_code attribute.

Implement Conversation Handler

A handler to hold a conversation with a single user by managing four collections of other handlers. Note that neither posts in Telegram Channels, nor group interactions with multiple users are managed by instances of this class.

Using Telegrammer with Vapor and Fluent (Postgresql)

I've set up a project with Telegrammer and Vapor. I've installed the postgresql driver and registered FluentPostgreSQLProvider, but I'm not sure how to get a database connection in my bot class.

If I have a model called User and I want to query all users, I'd write the following code: User.query(on: conn).all(), where conn is an object that conforms to DatabaseConnectable. I'm not sure where/how I can access this object in my bot class.

Webhook certificate text instead of file path?

First of all, great repo BTW. Thanks for this 🎉

I noticed that the code is expecting the pem certificate's path.

if let publicCert = bot.settings.webhooksPublicCert {
  guard let fileHandle = FileHandle(forReadingAtPath: publicCert) else {
    let errorDescription = "Public key '\(publicCert)' was specified for HTTPS server, but wasn't found"
    log.error(errorDescription.logMessage)
    throw CoreError(identifier: "FileIO", reason: errorDescription)
  }

  cert = InputFile(data: fileHandle.readDataToEndOfFile(), filename: publicCert)
}

Since I'm deploying the bot with Dokku, I don't have too much control on the file system (everything running on containers). I was thinking about an option of getting the certficate's content on another environment variable. What do you think?

Timeout

After an arbitrary number of incoming connections of the web hook, i get a timeout for get updates. Is there an option to reconnect?

[2019-01-14T13:17:07.558Z] [INFO] [BotClient.swift:45 respond(endpoint:body:headers:)] Sending request:
POST https://api.telegram.org:443/bot729517131:AAFH1wdt6_rnVxXFyNmY_jsLLzUmCtJ-P8w/getUpdates HTTP/1.1
Content-Type: application/json
content-length: 14
{"timeout":20}
[2019-01-14T13:17:07.573Z] [INFO] [BotClient.swift:68 send(request:)] Creating new HTTP Client
[2019-01-14T13:17:07.574Z] [INFO] [BotClient.swift:78 send(request:)] Sending request to vapor HTTPClient
[2019-01-14T13:17:27.601Z] [INFO] [BotClient.swift:82 send(request:)] Decoding response from HTTPClient
[2019-01-14T13:17:27.601Z] [VERBOSE] [Bot.swift:59 wrap] 
Received response
Code: 0
Status OK: true
Description: Empty
Result: [
  
]

Create documentation

  • Generation parameters documentation for Telegram models in grenerate_wrappers.rb
  • Documentation for public classes

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.