Skip to content

Commit

Permalink
Changed model namespacing, added lots of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Watson committed Jun 6, 2019
1 parent 8d09d57 commit e71ab3b
Show file tree
Hide file tree
Showing 170 changed files with 66,230 additions and 3,261 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,4 +1,3 @@
/doc/
/lib/
/bin/
/.shards/
Expand Down
10 changes: 6 additions & 4 deletions README.md
@@ -1,9 +1,11 @@
![Header Image](img/header.png)

[![Travis](https://img.shields.io/travis/watzon/tourmaline.svg)](https://travis-ci.org/watzon/tourmaline) ![Github search hit counter](https://img.shields.io/github/search/watzon/tourmaline/goto.svg) ![license](https://img.shields.io/github/license/watzon/tourmaline.svg)
![Github search hit counter](https://img.shields.io/github/search/watzon/tourmaline/goto.svg) ![license](https://img.shields.io/github/license/watzon/tourmaline.svg)

Telegram Bot (and hopefully soon API) framework for Crystal. Based heavily off of [Telegraf](http://telegraf.js.org) this Crystal implementation allows your Telegram bot to be written in a language that's both beautiful and fast. Benchmarks coming soon.

[Read the docs](https://watzon.github.io/tourmaline)

## Installation

Add this to your application's `shard.yml`:
Expand All @@ -19,7 +21,7 @@ dependencies:
### Basic usage

```crystal
require "tourmaline"
require "tourmaline/bot"
alias TGBot = Tourmaline::Bot
Expand Down Expand Up @@ -82,10 +84,10 @@ Update sub-types:
- Invoice
- SuccessfulPayment

All of which are available through the enum `Tourmaline::Bot::UpdateAction`
All of which are available through the enum `Tourmaline::Bot::UpdateAction`. To avoid having to use the full namespace you can just use a symbol.

```crystal
bot.on(TGBot::UpdateAction::Text) do |update|
bot.on(:text) do |update|
text = update.message.not_nil!.text.not_nil!
puts "TEXT: #{text}"
end
Expand Down
332 changes: 171 additions & 161 deletions docs/Tourmaline.html

Large diffs are not rendered by default.

822 changes: 178 additions & 644 deletions docs/Tourmaline/Bot.html

Large diffs are not rendered by default.

350 changes: 180 additions & 170 deletions docs/Tourmaline/Bot/ChatAction.html

Large diffs are not rendered by default.

591 changes: 301 additions & 290 deletions docs/Tourmaline/Bot/Client.html

Large diffs are not rendered by default.

340 changes: 175 additions & 165 deletions docs/Tourmaline/Bot/CommandHandler.html

Large diffs are not rendered by default.

350 changes: 180 additions & 170 deletions docs/Tourmaline/Bot/CommandMiddleware.html

Large diffs are not rendered by default.

340 changes: 175 additions & 165 deletions docs/Tourmaline/Bot/EventHandler.html

Large diffs are not rendered by default.

336 changes: 173 additions & 163 deletions docs/Tourmaline/Bot/Middleware.html

Large diffs are not rendered by default.

330 changes: 170 additions & 160 deletions docs/Tourmaline/Bot/MiddlewareHandler.html

Large diffs are not rendered by default.

1,027 changes: 1,027 additions & 0 deletions docs/Tourmaline/Bot/Model.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/Animation.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/Audio.html

Large diffs are not rendered by default.

573 changes: 573 additions & 0 deletions docs/Tourmaline/Bot/Model/CallbackGame.html

Large diffs are not rendered by default.

893 changes: 893 additions & 0 deletions docs/Tourmaline/Bot/Model/CallbackQuery.html

Large diffs are not rendered by default.

1,125 changes: 1,125 additions & 0 deletions docs/Tourmaline/Bot/Model/Chat.html

Large diffs are not rendered by default.

1,207 changes: 1,207 additions & 0 deletions docs/Tourmaline/Bot/Model/ChatMember.html

Large diffs are not rendered by default.

703 changes: 703 additions & 0 deletions docs/Tourmaline/Bot/Model/ChatPhoto.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/ChosenInlineResult.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/Contact.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/Document.html

Large diffs are not rendered by default.

741 changes: 741 additions & 0 deletions docs/Tourmaline/Bot/Model/File.html

Large diffs are not rendered by default.

748 changes: 748 additions & 0 deletions docs/Tourmaline/Bot/Model/ForceReply.html

Large diffs are not rendered by default.

855 changes: 855 additions & 0 deletions docs/Tourmaline/Bot/Model/Game.html

Large diffs are not rendered by default.

573 changes: 573 additions & 0 deletions docs/Tourmaline/Bot/Model/GameHighScore.html

Large diffs are not rendered by default.

832 changes: 832 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineKeyboardButton.html

Large diffs are not rendered by default.

778 changes: 778 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineKeyboardMarkup.html

Large diffs are not rendered by default.

841 changes: 841 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQuery.html

Large diffs are not rendered by default.

616 changes: 616 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResult.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultArticle.html

Large diffs are not rendered by default.

1,010 changes: 1,010 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultAudio.html

Large diffs are not rendered by default.

884 changes: 884 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedAudio.html

Large diffs are not rendered by default.

1,010 changes: 1,010 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedDocument.html

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedGif.html

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedMpeg4Gif.html

Large diffs are not rendered by default.

1,010 changes: 1,010 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedPhoto.html

Large diffs are not rendered by default.

884 changes: 884 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedSticker.html

Large diffs are not rendered by default.

1,010 changes: 1,010 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedVideo.html

Large diffs are not rendered by default.

926 changes: 926 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultCachedVoice.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultContact.html

Large diffs are not rendered by default.

1,178 changes: 1,178 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultDocument.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultGif.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultLocation.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultMpeg4Gif.html

Large diffs are not rendered by default.

1,136 changes: 1,136 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultPhoto.html

Large diffs are not rendered by default.

1,178 changes: 1,178 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultVenue.html

Large diffs are not rendered by default.

1,220 changes: 1,220 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultVideo.html

Large diffs are not rendered by default.

968 changes: 968 additions & 0 deletions docs/Tourmaline/Bot/Model/InlineQueryResultVoice.html

Large diffs are not rendered by default.

800 changes: 800 additions & 0 deletions docs/Tourmaline/Bot/Model/InputContactMessageContent.html

Large diffs are not rendered by default.

758 changes: 758 additions & 0 deletions docs/Tourmaline/Bot/Model/InputLocationMessageContent.html

Large diffs are not rendered by default.

580 changes: 580 additions & 0 deletions docs/Tourmaline/Bot/Model/InputMedia.html

Large diffs are not rendered by default.

872 changes: 872 additions & 0 deletions docs/Tourmaline/Bot/Model/InputMediaVideo.html

Large diffs are not rendered by default.

586 changes: 586 additions & 0 deletions docs/Tourmaline/Bot/Model/InputMessageContent.html

Large diffs are not rendered by default.

800 changes: 800 additions & 0 deletions docs/Tourmaline/Bot/Model/InputTextMessageContent.html

Large diffs are not rendered by default.

884 changes: 884 additions & 0 deletions docs/Tourmaline/Bot/Model/InputVenueMessageContent.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/Invoice.html

Large diffs are not rendered by default.

790 changes: 790 additions & 0 deletions docs/Tourmaline/Bot/Model/KeyboardButton.html

Large diffs are not rendered by default.

748 changes: 748 additions & 0 deletions docs/Tourmaline/Bot/Model/LabeledPrice.html

Large diffs are not rendered by default.

715 changes: 715 additions & 0 deletions docs/Tourmaline/Bot/Model/Location.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/MaskPosition.html

Large diffs are not rendered by default.

2,151 changes: 2,151 additions & 0 deletions docs/Tourmaline/Bot/Model/Message.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/MessageEntity.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/OrderInfo.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/PhotoSize.html

Large diffs are not rendered by default.

855 changes: 855 additions & 0 deletions docs/Tourmaline/Bot/Model/PreCheckoutQuery.html

Large diffs are not rendered by default.

857 changes: 857 additions & 0 deletions docs/Tourmaline/Bot/Model/ReplyKeyboardMarkup.html

Large diffs are not rendered by default.

748 changes: 748 additions & 0 deletions docs/Tourmaline/Bot/Model/ReplyKeyboardRemove.html

Large diffs are not rendered by default.

855 changes: 855 additions & 0 deletions docs/Tourmaline/Bot/Model/ShippingAddress.html

Large diffs are not rendered by default.

790 changes: 790 additions & 0 deletions docs/Tourmaline/Bot/Model/ShippingOption.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/ShippingQuery.html

Large diffs are not rendered by default.

931 changes: 931 additions & 0 deletions docs/Tourmaline/Bot/Model/Sticker.html

Large diffs are not rendered by default.

573 changes: 573 additions & 0 deletions docs/Tourmaline/Bot/Model/StickerSet.html

Large diffs are not rendered by default.

893 changes: 893 additions & 0 deletions docs/Tourmaline/Bot/Model/SuccessfulPayment.html

Large diffs are not rendered by default.

1,021 changes: 1,021 additions & 0 deletions docs/Tourmaline/Bot/Model/Update.html

Large diffs are not rendered by default.

880 changes: 880 additions & 0 deletions docs/Tourmaline/Bot/Model/User.html

Large diffs are not rendered by default.

703 changes: 703 additions & 0 deletions docs/Tourmaline/Bot/Model/UserProfilePhotos.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/Venue.html

Large diffs are not rendered by default.

893 changes: 893 additions & 0 deletions docs/Tourmaline/Bot/Model/Video.html

Large diffs are not rendered by default.

817 changes: 817 additions & 0 deletions docs/Tourmaline/Bot/Model/VideoNote.html

Large diffs are not rendered by default.

779 changes: 779 additions & 0 deletions docs/Tourmaline/Bot/Model/Voice.html

Large diffs are not rendered by default.

893 changes: 893 additions & 0 deletions docs/Tourmaline/Bot/Model/WebhookInfo.html

Large diffs are not rendered by default.

334 changes: 172 additions & 162 deletions docs/Tourmaline/Bot/ParseMode.html

Large diffs are not rendered by default.

398 changes: 204 additions & 194 deletions docs/Tourmaline/Bot/UpdateAction.html

Large diffs are not rendered by default.

332 changes: 171 additions & 161 deletions docs/Tourmaline/User.html

Large diffs are not rendered by default.

342 changes: 176 additions & 166 deletions docs/Tourmaline/User/API.html

Large diffs are not rendered by default.

326 changes: 168 additions & 158 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/search-index.js

Large diffs are not rendered by default.

328 changes: 169 additions & 159 deletions docs/toplevel.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/inline_query.cr
Expand Up @@ -4,23 +4,23 @@ bot = Tourmaline::Bot::Client.new(ENV["API_KEY"])

bot.on(Tourmaline::Bot::UpdateAction::InlineQuery) do |update|
query = update.inline_query.not_nil!
results = [] of Tourmaline::Bot::InlineQueryResult
results = [] of Tourmaline::Bot::Model::InlineQueryResult

results << Tourmaline::Bot::InlineQueryResultArticle.new(
results << Tourmaline::Bot::Model::InlineQueryResultArticle.new(
id: "query",
title: "Inline title",
input_message_content: Tourmaline::Bot::InputTextMessageContent.new("Click!"),
input_message_content: Tourmaline::Bot::Model::InputTextMessageContent.new("Click!"),
description: "Your query: #{query.query}",
)

results << Tourmaline::Bot::InlineQueryResultPhoto.new(
results << Tourmaline::Bot::Model::InlineQueryResultPhoto.new(
id: "photo",
caption: "Telegram logo",
photo_url: "https://telegram.org/img/t_logo.png",
thumb_url: "https://telegram.org/img/t_logo.png"
)

results << Tourmaline::Bot::InlineQueryResultGif.new(
results << Tourmaline::Bot::Model::InlineQueryResultGif.new(
id: "gif",
gif_url: "https://telegram.org/img/tl_card_wecandoit.gif",
thumb_url: "https://telegram.org/img/tl_card_wecandoit.gif"
Expand Down
6 changes: 3 additions & 3 deletions examples/kitty_bot.cr
Expand Up @@ -2,7 +2,7 @@ require "../src/tourmaline"

bot = Tourmaline::Bot::Client.new(ENV["API_KEY"])

reply_markup = Tourmaline::Bot::ReplyKeyboardMarkup.new([
reply_markup = Tourmaline::Bot::Model::ReplyKeyboardMarkup.new([
["/kitty"], ["/kittygif"],
])

Expand All @@ -24,10 +24,10 @@ bot.command(["kitty", "kittygif"]) do |message|
cmd = message.text.not_nil!.split(" ")[0]

if cmd == "/kitty"
bot.send_chat_action(message.chat.id, Tourmaline::Bot::ChatAction::UploadPhoto)
bot.send_chat_action(message.chat.id, :upload_photo)
bot.send_photo(message.chat.id, api + "jpg")
else
bot.send_chat_action(message.chat.id, Tourmaline::Bot::ChatAction::UploadDocument)
bot.send_chat_action(message.chat.id, :upload_document)
bot.send_document(message.chat.id, api + "gif")
end
end
Expand Down
4 changes: 2 additions & 2 deletions shard.yml
@@ -1,10 +1,10 @@
name: tourmaline
version: 0.4.0
version: 0.5.0

authors:
- Chris Watson <chris@watzon.me>

crystal: 0.24.1
crystal: 0.28.0

dependencies:
halite:
Expand Down

0 comments on commit e71ab3b

Please sign in to comment.