Giter Site home page Giter Site logo

kik's Introduction

Kik

Build Kik bots with Ruby

Installation

Add this line to your application's Gemfile:

gem 'kik', git: "git://github.com/muaad/kik"

And then execute:

$ bundle

Or install it yourself as:

$ gem install kik

Usage

Create a Kik bot at dev.kik.com and copy your bot name and API key.

Initialize the Kik::Client

client = Kik::Client.new 'bot_name', 'api_key'

Set webhook

client.set_webhook 'url'

You can specify some settings like whether you want to send/receive read receipts, delivery receipts or typing notification.

client.set_webhook 'url', { "manuallySendReadReceipts" => false, "receiveReadReceipts" => false, "receiveDeliveryReceipts" => false, "receiveIsTyping" => false }

Send messages

Kik requires that a bot doesn't initiate a conversation with a user. When a user sends your bot a message, it will receive the chat_id which you can use to reply to the message.

client.messages.send_text('user_name', 'chat_id', 'message')

You can add a keyboard to your message. Pass in the keyboard as an array containing a list of the elements that make up the keyboard. The boolean argument at the end is for toggling the keyboard ON or OFF.

client.messages.send_text('user_name', 'chat_id', 'Are you a human being?', ["Yes", "No"], true)

Send images

client.messages.send_image 'user_name', 'chat_id', 'path/to/file.png'

Send videos

client.messages.send_video 'user_name', 'chat_id', 'path/to/video/file.png'

You can also set the following properties to determine whether a video should be autoplayed or muted or set the attribution.

client.messages.send_video 'user_name', 'chat_id', 'path/to/video/file.png', muted, autoplay

where muted and autoplay are boolean and both default to false.

Send links

client.messages.send_link 'user_name', 'chat_id', 'url'

Send typing

client.messages.send_typing 'user_name', 'chat_id'

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/muaad/kik.

License

The gem is available as open source under the terms of the MIT License.

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.