tg-bot 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 138aa4dfb58a1e2fef7023fdf389ab3ea6756e057a03f1c37a71212d446c2451
4
- data.tar.gz: c0d174a4e659b6d8b7cb9e863dfd34dd1aeab30c68d67fc8f54f5330769889fd
3
+ metadata.gz: 948ec1f7ca8d968e301a9adf6bb6d6716351ed81dab9a020d2aa7dbfb39b3547
4
+ data.tar.gz: cde58adfb1cc74599daaf2a52448c0f12cc978a7c9ea062b3a6a586a86745693
5
5
  SHA512:
6
- metadata.gz: 3e7a401f78e1121a0f90fa32e2cc56cf77467312a9611c97d16d1e589ee089ae0458a7ae726f0174289dc9799a2a465e3cedab157e510c35b6472799ab2a4755
7
- data.tar.gz: 4874ded1b7678473c11050ac899d6df85c47fdb4bf7dc68f69abc94462f6673e38398e3b1a04c946dd637ddef6bb4103a566e8a3098308fbe189ca88fb8c852d
6
+ metadata.gz: 5aa028c4f2ab9df294b0aa3448dec0224c368fca7e7ba5cf3c13343d4a1b89f99a6ebe79684ef156ffc8036be09350cce5592703b80d949f35a4d97e9163cc79
7
+ data.tar.gz: 4d842828909844db7173758109f91931afd8e98ec04a673d9fb6da795261b345d8024f16c4ade3930e620821cd0ad58912bae94c66c351d87995715e03be20d2
data/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  ```
14
14
  2. Add this gem to your `Gemfile`
15
15
  ```ruby
16
- gem 'tg-bot', '~> 0.0.2'
16
+ gem 'tg-bot'
17
17
  ```
18
18
  3. Setup your Controller
19
19
  > e.g. my webhook is https://xxxxx/telegram
@@ -42,9 +42,80 @@
42
42
  ```
43
43
 
44
44
  # Methods
45
- ## setWebhook
45
+ ## [SetWebhook](https://github.com/VenseChang/telegram-bot-gem/blob/4b896317db7804cf8f5191974f5e942872300ba3/lib/tg-bot.rb#L25-L28)
46
46
  ```ruby
47
47
  def xxx
48
- Telegram::Bot.SetWebhook(url)
48
+ Telegram::Bot::SetWebhook(url)
49
49
  end
50
- ```
50
+ ```
51
+
52
+ ## [Send Message](https://github.com/VenseChang/telegram-bot-gem/blob/develop/lib/telegram/reply/send_message.rb)
53
+ ```ruby
54
+ def telegram
55
+ telegram = Telegram::Bot.new(params)
56
+ telegram.send_message(
57
+ chat_id: 'chat_id',
58
+ text: 'Enter you want to reply message text',
59
+ parse_mode: 'HTML / Markdown ( Default Setting: HTML )',
60
+ disable_web_page_preview: 'true / false',
61
+ disable_notification: 'true / false',
62
+ reply_to_message_id: 'message_id',
63
+ reply_markup: 'inline keyboard, custom reply keyboard'
64
+ )
65
+ end
66
+ ```
67
+ ||type|memo|
68
+ |---|---|---|
69
+ |chat_id|Integer / String|**Required**<br>Default: chat_id from params|
70
+ |text|String|**Required**<br>Enter reply Message|
71
+ |parse_mode|String|**Optional**<br>Default: `HTML`<br>[HTML](https://core.telegram.org/bots/api#html-style) / [Markdown](https://core.telegram.org/bots/api#markdown-style)|
72
+ |disable_web_page_preview|Boolean|**Optional**<br>true / false|
73
+ |disable_notification|Boolean|**Optional**<br>true / false|
74
+ |reply_to_message_id|Integer|**Optional**<br>Reply sb's message by message_id|
75
+
76
+ ## [Forward Message](https://github.com/VenseChang/telegram-bot-gem/blob/develop/lib/telegram/reply/forward_message.rb)
77
+ ```ruby
78
+ def telegram
79
+ telegram = Telegram::Bot.new(params)
80
+ telegram.forward_message(
81
+ chat_id: 'chat_id',
82
+ from_chat_id: 'chat_id from forward message',
83
+ message_id: 'message_id forward message',
84
+ disable_notification: 'true / false'
85
+ )
86
+ end
87
+ ```
88
+ ||type|memo|
89
+ |---|---|---|
90
+ |chat_id|Integer / String|**Required**<br>Default: chat_id from params|
91
+ |from_chat_id|Integer|**Required**<br>Chat Id from forward message|
92
+ |message_id|String|**Required**<br>Message Id from forward message|
93
+ |disable_notification|Boolean|**Optional**<br>true / false|
94
+
95
+ ## [Send Photo](https://github.com/VenseChang/telegram-bot-gem/blob/develop/lib/telegram/reply/send_photo.rb)
96
+ ```ruby
97
+ def telegram
98
+ telegram = Telegram::Bot.new(params)
99
+ telegram.send_photo(
100
+ chat_id: 'chat_id',
101
+ photo: 'InputFile / File Id(String) / HTTP URL(String)',
102
+ caption: 'Photo caption',
103
+ parse_mode: 'HTML / Markdown ( Default Setting: HTML )',
104
+ disable_notification: 'true / false',
105
+ reply_to_message_id: 'message_id',
106
+ reply_markup: 'inline keyboard, custom reply keyboard'
107
+ )
108
+ end
109
+ ```
110
+ ||type|memo|
111
+ |---|---|---|
112
+ |chat_id|Integer / String|**Required**<br>Default: chat_id from params|
113
+ |photo|InputFile / String|**Required**<br>There's 3 ways to send photo:<br>1. Use `multipart/form-data` to upload new photo.<br>2. If the photo exist on Telegram servers, then pass `file_id` as String to send a photo.<br>3. Pass an HTTP URL as a String for Telegram to get a photo from the Internet.<br>[more](https://core.telegram.org/bots/api#sendphoto)|
114
+ |caption|String|**Optional**<br>Photo caption (may also be used when resending photos by file_id)<br>***maximun characters : 1024***|
115
+ |parse_mode|String|**Optional**<br>Default: `HTML`<br>[HTML](https://core.telegram.org/bots/api#html-style) / [Markdown](https://core.telegram.org/bots/api#markdown-style)|
116
+ |disable_notification|Boolean|**Optional**<br>true / false|
117
+ |reply_to_message_id|Integer|**Optional**<br>Reply sb's message by message_id|
118
+
119
+ # Other
120
+ If you have any questions or better advice for this gem, please use [Issue](https://github.com/VenseChang/telegram-bot-gem/issues/new) to tell me.
121
+ Thanks for using this gem.
@@ -1,5 +1,5 @@
1
1
  module Telegram
2
2
  module Bot
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
data/lib/tg-bot.rb CHANGED
@@ -6,7 +6,7 @@ module Telegram
6
6
  class Bot
7
7
  include Telegram::Reply
8
8
 
9
- attr_reader :user, :forward_from, :chat, :forward_from_chat, :message
9
+ attr_reader :user, :forward_from, :chat, :forward_from_chat, :message, :text
10
10
 
11
11
  def initialize(params)
12
12
  # User
@@ -19,11 +19,14 @@ module Telegram
19
19
 
20
20
  # Message
21
21
  @message = Telegram::Params::Message.new(params)
22
+
23
+ # Text
24
+ @text = @message.text
22
25
  end
23
26
 
24
27
  class << self
25
28
  def SetWebhook(url)
26
- uri = URI("https://api.telegram.org/bot#{ENV['telegram_token']}/setWebhook?url=#{url}")
29
+ uri = URI("https://api.telegram.org/bot#{ENV['telegram_bot_token']}/setWebhook?url=#{url}")
27
30
  Net::HTTP.get(uri)
28
31
  end
29
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tg-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vense Chang