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 +4 -4
- data/README.md +75 -4
- data/lib/telegram/version.rb +1 -1
- data/lib/tg-bot.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 948ec1f7ca8d968e301a9adf6bb6d6716351ed81dab9a020d2aa7dbfb39b3547
|
|
4
|
+
data.tar.gz: cde58adfb1cc74599daaf2a52448c0f12cc978a7c9ea062b3a6a586a86745693
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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'
|
|
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
|
-
##
|
|
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
|
|
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.
|
data/lib/telegram/version.rb
CHANGED
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['
|
|
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
|