README.md in telegram-bot-0.7.4 vs README.md in telegram-bot-0.8.0
- old
+ new
@@ -129,13 +129,14 @@
def start(data = nil, *)
# do_smth_with(data)
# There are `chat` & `from` shortcut methods.
response = from ? "Hello #{from['username']}!" : 'Hi there!'
- # There is `reply_with` helper to set basic fields
- # like `reply_to_message` & `chat_id`.
- reply_with :message, text: response
+ # There is `respond_with` helper to set `chat_id` from received message:
+ respond_with :message, text: response
+ # `reply_with` also sets `reply_to_message_id`:
+ reply_with :photo, photo: File.open('party.jpg')
end
private
def with_locale(&block)
@@ -186,11 +187,11 @@
def write(text = nil, *)
session[:text] = text
end
def read
- reply_with :message, text: session[:text]
+ respond_with :message, text: session[:text]
end
private
# By default it uses bot's username and user's id as a session key.
# Chat's id is used only when `from` field is empty.
@@ -212,27 +213,27 @@
include Telegram::Bot::UpdatesController::MessageContext
def rename(*)
# set context for the next message
save_context :rename
- reply_with :message, text: 'What name do you like?'
+ respond_with :message, text: 'What name do you like?'
end
# register context handlers to handle this context
context_handler :rename do |*words|
update_name words[0]
- reply_with :message, text: 'Renamed!'
+ respond_with :message, text: 'Renamed!'
end
# You can do it in other way:
def rename(name = nil, *)
if name
update_name name
- reply_with :message, text: 'Renamed!'
+ respond_with :message, text: 'Renamed!'
else
save_context :rename
- reply_with :message, text: 'What name do you like?'
+ respond_with :message, text: 'What name do you like?'
end
end
# This will call #rename like if it is called with message '/rename %text%'
context_handler :rename
@@ -380,9 +381,19 @@
To install this gem onto your local machine, run `bundle exec rake install`.
To release a new version, update the version number in `version.rb`,
and then run `bundle exec rake release`, which will create a git tag for the version,
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
+
+### Different Rails versions
+
+To setup development for specific major Rails version use:
+
+```
+RAILS=5 bundle install
+# or
+RAILS=5 bundle update
+```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/telegram-bot-rb/telegram-bot.