Package -


Build Status Swift Version Platforms License

This library wraps the JSON decoding processing, making it easy to decode incoming JSON String to manipulatable objects.

This library wraps the processing of converting objects to Telegram Bot API request parameters and the processing of performing request, making it easy to handle incoming update.


Add this project as a dependency in your Package.swift file.

.package(url: "", from: Version(4, 0, 0))

Quick Start

Checkout the example here: ./Example.

Or you can just put the following code into main.swift of your project.

import ZEGBot

//  Don't forget to fill in your bot token.
let bot = ZEGBot(token: "TYPE YOUR TOKEN HERE") { update, bot in       
  //  Handle updates here...



  • Get text content of the incoming message:

    if let text = update.message?.text {
      // Do something.
  • Get other type of content if exists:

    if let voice = update.message?.voice {
      // Do something.
  • Send a text message to a chat:

    if let message = update.message {
      bot.send(message: "bar", to:
  • Send a silent message with a none-preview markdown link to a chat:

    if let message = update?.message {
      bot.send(message: "[Google](", to:, parseMode: .markdown, disableWebPagePreview: true, disableNotification: true)
  • In all the sending methods, send to a Message Object means reply to this specific message. While Send to a Chat Object means send to this chat without replying to anyone.

    if let message = update?.message {
      /* This sends a message replying to another message. */
      bot.send(message: "bar", to: message)
      /* This doesn't reply to a message. */
      bot.send(message: "bar", to:
  • Send a text message to a channel:

    if let channelPost = update?.channelPost {
      bot.send(message: "bar", to:

Support Types

  • Update
  • Message
  • Chat
  • User
  • MessageEntity
  • Audio
  • Document
  • PhotoSize
  • Sticker
  • Video
  • Voice
  • Contact
  • Location
  • Venue
  • File

Not all the types are supported, checkout more details on Telegram Bot API.

Support Methods

  • sendMessage
  • forwardMessage
  • sendPhoto
  • sendAudio
  • sendDocument
  • sendSticker
  • sendVideo
  • sendVoice
  • sendLocation
  • sendVenue
  • sendContact
  • sendChatAction
  • getFile

Not all the methods are supported, checkout more details on Telegram Bot API.


This project is licensed under Apache License v2.0.