template/project/bot.tt in boty-0.0.14 vs template/project/bot.tt in boty-0.0.15
- old
+ new
@@ -1,13 +1,21 @@
#!/usr/bin/env ruby
require "./<%= bot_name %>"
-Boty.locale = ARGV.pop || :en
+def set_locale(locale)
+ begin
+ Boty.locale = locale || :en
+ rescue I18n::InvalidLocale
+ Boty.locale = :en
+ end
+end
session = Boty::Session.new
session.start do |bot|
+ set_locale ARGV.pop
+
bot.desc I18n.t "template.presence", bot_name: bot.name
- bot.message(/#{bot.name}/i) do |message|
+ bot.match(/#{bot.name}/i) do
next if message.from? self
- say I18n.t "template.hello", user_name: message.user.name
+ say I18n.t "template.hello", user_name: user.name
end
end