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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7c783caaed0c590d532335aeea11bea43728cd9
4
- data.tar.gz: 9771f725b49e5aca5f20e60c637afdfa5117ba97
3
+ metadata.gz: cc63f6f21fe9a8ed94ed24c71baa71892838561e
4
+ data.tar.gz: 99fd5f633a9d371c8f44655a8c7f5d521c5219a4
5
5
  SHA512:
6
- metadata.gz: 3363a3588cc5ef5978bbb106752ffd158de63f04242e2b38093f3de8dc25b92873a3cdb22ca994bf5c800676d6ec94d62d6d4ecd61d2cbdb8cea895cb4bc650a
7
- data.tar.gz: 48ab7f8d3be6eae365461c780f9aa0e9bbd333c48ccc33363a54ece2a55d66bdb498d3ac1e2a09e0b9612f440afffc70846806ff1ff4cecf5ef65f1ee4dda912
6
+ metadata.gz: c467c3f6c828bd8d8caeb79a51e0c89058c8d3225adbebaf2e62f7053b6d796324ed98e7b80a3fc8c6cba141e3ac40fd7e34789998dc0d95f3c4c84db097ec46
7
+ data.tar.gz: 19ea126a36e6484cd3600fc9e9255b4f7a7e5e919232c894b6c7b45a1b12854aa197facd14e58c346603a3f00bb113722bf51824459691c507c85e807c295a2d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- boty (0.0.15)
4
+ boty (0.0.16)
5
5
  eventmachine
6
6
  faraday
7
7
  faye-websocket
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
- Boty.locale = ARGV.pop || :en
8
-
9
- bot.desc I18n.t "template.presence", bot_name: bot.name
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
@@ -1,8 +1,7 @@
1
1
  module Boty
2
2
  class Bot
3
3
  include Boty::Logger
4
- attr_accessor :trigger_message
5
- attr_reader :id, :name
4
+ attr_reader :id, :name, :trigger_message
6
5
 
7
6
  def initialize(bot_info, session)
8
7
  Locale.reload
@@ -27,6 +27,10 @@ module Boty
27
27
  @bot.trigger_message
28
28
  end
29
29
 
30
+ def message_from_me?
31
+ message.from? @bot
32
+ end
33
+
30
34
  def hear(*args, &block)
31
35
  match(*args, &block)
32
36
  end
data/lib/boty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Boty
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
data/lib/boty.rb CHANGED
@@ -11,6 +11,7 @@ end
11
11
 
12
12
  require "faye/websocket"
13
13
  require "i18n"
14
+ require "faraday"
14
15
 
15
16
  $:.unshift File.expand_path("../../lib", __FILE__)
16
17
 
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 glad you need my knowlege on %{brain_area}, %{user_asking}.
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
- Que bom que precisa de meus conhecimentos sobre %{brain_area}, %{user_asking}.
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[message.match[1].to_sym][user_about].each do |info| im info end
16
+ im brain[brain_area.to_sym][user_about].reduce("```\n") { |all_about, info|
17
+ all_about << " - #{info}"
18
+ } + "\n```"
17
19
  end
@@ -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
- set_locale ARGV.pop
15
-
16
- bot.desc I18n.t "template.presence", bot_name: bot.name
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Valeriano