svs / telegram-rb

A Ruby wrapper that communicates with the Telegram-CLI.

Home Page:https://github.com/ssut/telegram-rb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Telegram API for Ruby!

DUB Gem Version Code Climate Inline docs

Gitter

A Ruby wrapper that communicates with the Telegram-CLI.

Installation

Requirements

RubyGems

In order to use the telegram-rb you will need to install the gem (either manually or using Bundler), and require the library in your Ruby application:

$ gem install telegram-rb

or in your Gemfile:

# latest stable
gem 'telegram-rb'

# or track master repo
gem 'telegram-rb', :github => 'ssut/telegram-rb'

or install it from a source code checkout:

$ git clone https://github.com/ssut/telegram-rb.git
$ cd telegram-rb
$ bundle install

Usage

You must use eventmachine library for use, so telegram-rb uses callback at all.

require 'eventmachine'
require 'telegram'

EM.run
  telegram = Telegram::Client.new do |cfg|
    cfg.daemon = '/path/to/tg/bin/telegram-cli'
    cfg.key = '/path/to/tg/tg-server.pub'
  end

  telegram.connect do
    # This block will be executed when initialized.
    
    # See your telegram profile
    puts telegram.profile

    telegram.contacts.each do |contact|
      puts contact
    end
    
    telegram.chats.each do |chat|
      puts chat
    end
    
    # Event listeners
    # When you've received a message:
    telegram.on[Telegram::EventType::RECEIVE_MESSAGE] = Proc.new { |event|
      # `tgmessage` is TelegramMessage instance
      puts event.tgmessage
    }
    # When you've sent a message:
    telegram.on[Telegram::EventType::SEND_MESSAGE]= Proc.new { |event|
      puts event
    }
  end
end

Documentation

You can check documentation from here!

My goal is to have the code fully documentated for the project, so developers can use this library easily!

Coverage (TODO)

  • Messaging/Multimedia
    • Send typing signal to specific user or chat
    • Send a message to specific user or chat
    • Send an image to specific user or chat
    • Send a video to specific user or chat
    • Download an image of someone sent
    • Forward a message to specific user
    • Mark as read all received messages
    • Set profile picture
  • Group chat options
    • Add a user to the group
    • Remove a user from the group
    • Leave from the group
    • Create a new group chat
    • Set group chat photo
    • Rename group chat title
  • Search
    • Search for specific message from a conversation
    • Search for specific message from all conversions
  • Secret chat
    • Reply message in secret chat
    • Visualize of encryption key of the secret chat
    • Create a new secret chat
  • Stats and various info
    • Get user profile
    • Get chat list
    • Get contact list
    • Get history and mark it as read
  • Card
    • export card
    • import card

Contributing

If there are bugs or things you would like to improve, fork the project, and implement your awesome feature or patch in its own branch, then send me a pull request here!

License

telegram-rb is licensed under the MIT License.

The MIT License (MIT)

Copyright (c) 2015 SuHun Han

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.

About

A Ruby wrapper that communicates with the Telegram-CLI.

https://github.com/ssut/telegram-rb

License:MIT License


Languages

Language:Ruby 100.0%