boty 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/bot +13 -5
- data/lib/boty/bot.rb +1 -2
- data/lib/boty/script_dsl.rb +4 -0
- data/lib/boty/version.rb +1 -1
- data/lib/boty.rb +1 -0
- data/locale/en.yml +1 -3
- data/locale/pt-br.yml +2 -3
- data/script/remember.rb +3 -1
- data/template/project/bot.tt +6 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc63f6f21fe9a8ed94ed24c71baa71892838561e
|
4
|
+
data.tar.gz: 99fd5f633a9d371c8f44655a8c7f5d521c5219a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c467c3f6c828bd8d8caeb79a51e0c89058c8d3225adbebaf2e62f7053b6d796324ed98e7b80a3fc8c6cba141e3ac40fd7e34789998dc0d95f3c4c84db097ec46
|
7
|
+
data.tar.gz: 19ea126a36e6484cd3600fc9e9255b4f7a7e5e919232c894b6c7b45a1b12854aa197facd14e58c346603a3f00bb113722bf51824459691c507c85e807c295a2d
|
data/Gemfile.lock
CHANGED
data/bin/bot
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require "./lib/boty"
|
3
3
|
|
4
|
+
def set_locale(locale)
|
5
|
+
begin
|
6
|
+
Boty.locale = locale || :en
|
7
|
+
rescue I18n::InvalidLocale
|
8
|
+
Boty.locale = :en
|
9
|
+
end
|
10
|
+
Boty::Locale.reload
|
11
|
+
end
|
12
|
+
|
13
|
+
set_locale ARGV.pop
|
4
14
|
|
5
15
|
session = Boty::Session.new
|
6
16
|
session.start do |bot|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
bot.message(/#{bot.name}/i) do |message|
|
11
|
-
next if message.from? self
|
17
|
+
bot.desc bot.name, I18n.t("template.presence", bot_name: bot.name)
|
18
|
+
bot.hear(/#{bot.name}/i) do
|
19
|
+
next if message_from_me?
|
12
20
|
say I18n.t "template.hello", user_name: message.user.name
|
13
21
|
end
|
14
22
|
end
|
data/lib/boty/bot.rb
CHANGED
data/lib/boty/script_dsl.rb
CHANGED
data/lib/boty/version.rb
CHANGED
data/lib/boty.rb
CHANGED
data/locale/en.yml
CHANGED
@@ -14,6 +14,4 @@ en:
|
|
14
14
|
command: "about user [@SOME_USER]"
|
15
15
|
desc: "Retrieves information stored in the brain section :user for \"@SOME_USER\"."
|
16
16
|
response: |
|
17
|
-
I'm
|
18
|
-
I can tell you somethings about %{user_about}.
|
19
|
-
What I know... lets see...
|
17
|
+
%{user_asking}, I'm searching my %{brain_area} database for %{user_about}:
|
data/locale/pt-br.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
pt-br:
|
2
2
|
template:
|
3
3
|
presence: "Responde quando o nome do bot (%{bot_name}) é mencionado em uma mensagem."
|
4
|
+
hello: "Ohay <@%{user_name}>! Estou por aqui, ninguém pode negar."
|
4
5
|
scripts:
|
5
6
|
knows: "Lista os comandos conhecidos por esse bot."
|
6
7
|
pug_me: "Manda um belo pug no canal."
|
@@ -13,6 +14,4 @@ pt-br:
|
|
13
14
|
command: "about user [@SOME_USER]"
|
14
15
|
desc: "Recupera informação na seção :user do cérebro para o usuário \"@SOME_USER\"."
|
15
16
|
response: |
|
16
|
-
|
17
|
-
Acho que posso dizer algumas coisas sobre %{user_about}.
|
18
|
-
O que eu sei?... Vamos ver...
|
17
|
+
%{user_asking}, procurando meus arquivos de %{brain_area} sobre %{user_about}:
|
data/script/remember.rb
CHANGED
@@ -13,5 +13,7 @@ command(/about (\w+\b)(:?) (.+)/i) do |brain_area, _, user_about|
|
|
13
13
|
brain_area: brain_area,
|
14
14
|
user_asking: user.name,
|
15
15
|
user_about: user_about
|
16
|
-
brain[
|
16
|
+
im brain[brain_area.to_sym][user_about].reduce("```\n") { |all_about, info|
|
17
|
+
all_about << " - #{info}"
|
18
|
+
} + "\n```"
|
17
19
|
end
|
data/template/project/bot.tt
CHANGED
@@ -7,15 +7,16 @@ def set_locale(locale)
|
|
7
7
|
rescue I18n::InvalidLocale
|
8
8
|
Boty.locale = :en
|
9
9
|
end
|
10
|
+
Boty::Locale.reload
|
10
11
|
end
|
11
12
|
|
13
|
+
set_locale ARGV.pop
|
14
|
+
|
12
15
|
session = Boty::Session.new
|
13
16
|
session.start do |bot|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
bot.match(/#{bot.name}/i) do
|
18
|
-
next if message.from? self
|
17
|
+
bot.desc bot.name, I18n.t("template.presence", bot_name: bot.name)
|
18
|
+
bot.hear(/#{bot.name}/i) do
|
19
|
+
next if message_from_me?
|
19
20
|
say I18n.t "template.hello", user_name: user.name
|
20
21
|
end
|
21
22
|
end
|