Coder Social home page Coder Social logo

revskill10 / telegram-rb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ssut/telegram-rb

0.0 1.0 0.0 71 KB

A Ruby wrapper that communicates with the Telegram-CLI.

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

License: MIT License

Ruby 100.00%

telegram-rb's Introduction

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.

telegram-rb's People

Contributors

bartekjacak avatar genius69 avatar revskill10 avatar ssut avatar

Watchers

 avatar

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.