Need help with Telegrammer?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

givip
270 Stars 35 Forks MIT License 225 Commits 7 Opened issues

Description

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

Services available

!
?

Need anything else?

Contributors list

# 167,708
Swift
Telegra...
swift5
telegra...
171 commits
# 301,832
Atom
swift5
Ubuntu
rss-fee...
3 commits
# 198,523
Rails
gRPC
Telegra...
swift5
2 commits
# 197,833
applesc...
macos-c...
Electro...
Telegra...
2 commits
# 411,849
Telegra...
vapor
swift5
C
1 commit
# 431,109
Dart
vapor
telegra...
swift5
1 commit

SwiftyBot Banner

Telegrammer

Telegram Bot Framework written in Swift 5.1 with SwiftNIO network framework

Build Version Language Platform License

What does it do

Telegrammer is open-source framework for Telegram Bots developers. It was built on top of Apple/SwiftNIO

Join to our Telegram developers chat Join to our Telegrammer channel on Vapor Discord server

The simplest code of Echo Bot looks like this:


main.swift ```swift import Foundation import Telegrammer

do { let bot = try Bot(token: "BOTTOKENHERE")

let echoHandler = MessageHandler { (update, _) in
    _ = try? update.message?.reply(text: "Hello \(update.message?.from?.firstName ?? "anonymous")", from: bot)
}

let dispatcher = Dispatcher(bot: bot) dispatcher.add(handler: echoHandler)

_ = try Updater(bot: bot, dispatcher: dispatcher).startLongpolling().wait()

} catch { exit(1) } ```

Documentation

Usage without Vapor

  • Use the template repository as a example https://github.com/givip/telegrammer-bot-template.git
  • Current repository contains five examples of bot implementation: https://github.com/givip/Telegrammer/tree/master/Sources/DemoEchoBot https://github.com/givip/Telegrammer/tree/master/Sources/DemoHelloBot https://github.com/givip/Telegrammer/tree/master/Sources/DemoSchedulerBot https://github.com/givip/Telegrammer/tree/master/Sources/DemoSpellCheckerBot https://github.com/givip/Telegrammer/tree/master/Sources/DemoWebhooksLocally

Usage with Vapor

Demo bots

All sample bots

  1. Add Telegram Token in Environment Variables, so, either create an environment variable:
    $ export TELEGRAM_BOT_TOKEN='000000000:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
    
  2. Run Bot executable scheme or
    $ swift run
    

EchoBot sources Starts/stops with command "/echo", then simply responds with your message

HelloBot sources Says "Hello" to new users in group. Responds with "hello" message on command "/greet"

SchedulerBot sources Demonstrate Jobs Queue scheduling mechanism. Command "/start X" starts repeatable job, wich will send you a message each X seconds. Command "/once X" will send you message once after timeout of X seconds. Command "/stop" stops JobsQueue only for you. Other users continues to receive scheduled messages.

SpellCheckerBot sources Demonstrate how works InlineMenus and Callback handlers. Command "/start" will start bot. Send any english text to bot and it will be checked for mistakes. Bot will propose you some fixes in case of found mistake.

Requirements

Contributing

See CONTRIBUTING.md file.

Author

Givi Pataridze

[email protected] @givip

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.