lita-chengyujielong 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ef159e0c17eba685f186c20e09e131ae3bb4c6d683e283cac63e175cd253dcc6
4
+ data.tar.gz: de91189cb58279a042e2d232f6eaa5745fc9c58ee903f7cfae52b38b44f1d5f1
5
+ SHA512:
6
+ metadata.gz: db5771c813d16bca1b41a627490acd307b4685f2782d16c65f72d3aa59cfc4482d13d9e8cdbd4b2859bbad116a6146bb4fecf2f27fe41ec0da7c586cfff4a1ca
7
+ data.tar.gz: 90bb6b89de734b2e279d6307d8cd33dca45795f7940288098fe926944d056299b9044870e431edd0916bb850deb7e419f1ef75a060ead3650e5fb2d0ae39e285
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # lita-chengyu
2
+ - study lita
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
Binary file
@@ -0,0 +1,34 @@
1
+ #encoding: utf-8
2
+ require 'active_record'
3
+ require 'sqlite3'
4
+
5
+ module Database
6
+ class Chengyu < ActiveRecord::Base
7
+ self.abstract_class = true
8
+ establish_connection(:adapter => "sqlite3", :database => File.expand_path('../../db/chengyus.sqlite3', __FILE__))
9
+ self.table_name = "chengyus"
10
+ end
11
+ end
12
+
13
+ module Lita
14
+ module Handlers
15
+ class Chengyujielong < Handler
16
+ include Database
17
+ # insert handler code here
18
+ route(/./, :test, command: true)
19
+
20
+ def test(response)
21
+ text = response.matches.join
22
+ if Chengyu.exists?(name: text)
23
+ last_word = text[-1]
24
+ reply = Chengyu.where('name like ?', "#{last_word}%").limit(10).pluck(:name).sample
25
+ response.reply(reply.present? ? reply : "无#{last_word}开头的成语")
26
+ else
27
+ response.reply('请输入成语')
28
+ end
29
+ end
30
+
31
+ Lita.register_handler(self)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require_relative "../lib/lita/handlers/chengyujielong"
8
+
9
+ Lita::Handlers::Chengyujielong.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-chengyujielong"
3
+ spec.version = "0.1.1"
4
+ spec.authors = ["yfscret"]
5
+ spec.email = ["305667862@qq.com"]
6
+ spec.description = "lita-study"
7
+ spec.summary = "lita-study"
8
+ spec.homepage = "https://gitee.com/yfscret/lita-study.git"
9
+ spec.license = "MIT"
10
+ spec.metadata = { "lita_plugin_type" => "handler" }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_runtime_dependency "lita", ">= 4.8"
18
+ spec.add_development_dependency "pry-byebug"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rack-test"
21
+ spec.add_development_dependency "rspec", ">= 3.0.0"
22
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,137 @@
1
+ en:
2
+ lita:
3
+ adapters:
4
+ shell:
5
+ startup_message: Type "exit" or "quit" to end the session.
6
+ core:
7
+ register_adapter:
8
+ block_or_class_required: Lita.register_adapter requires a class in its two argument form.
9
+ register_handler:
10
+ block_or_class_required: Lita.register_handler requires a class in its single argument form.
11
+ adapter:
12
+ method_not_implemented: "This adapter has not implemented #%{method}."
13
+ cli:
14
+ no_gemfile_warning: >-
15
+ The default command "start" must be run inside a Lita project. Try running `lita new` to
16
+ generate a new Lita project or `lita help` to see all commands.
17
+ license_notice: >-
18
+ If you plan to release this plugin as open source software, consider adding a LICENSE file
19
+ to the root of the repository.
20
+
21
+ Common open source software licenses can be found at https://choosealicense.com/.
22
+ github_user_question: What is your GitHub username?
23
+ config:
24
+ exception: |
25
+ Lita configuration file could not be processed. The exception was:
26
+ %{message}
27
+ Full backtrace:
28
+ %{backtrace}
29
+ locale_deprecated: >-
30
+ `config.robot.locale` and `config.robot.default_locale` are deprecated and will be removed
31
+ in Lita 6.0. Use the environment variable LC_ALL, LC_MESSAGES, or LANG to set the program's
32
+ locale instead.
33
+ missing_required_adapter_attribute: >-
34
+ Configuration attribute "%{attribute}" is required for "%{adapter}" adapter.
35
+ missing_required_handler_attribute: >-
36
+ Configuration attribute "%{attribute}" is required for "%{handler}" handler.
37
+ type_error: >-
38
+ Configuration type error: "%{attribute}" must be one of: %{types}.
39
+ validation_error: >-
40
+ Validation error on attribute "%{attribute}": %{message}
41
+ handler:
42
+ dispatch: "Dispatching message to %{handler}#%{method}."
43
+ exception: |
44
+ %{handler} crashed. The exception was:
45
+ %{message}
46
+ Full backtrace:
47
+ %{backtrace}
48
+ handlers:
49
+ authorization:
50
+ help:
51
+ add_key: auth add USER GROUP
52
+ add_value: Add USER to authorization group GROUP. Requires admin privileges.
53
+ remove_key: auth remove USER GROUP
54
+ remove_value: Remove USER from authorization group GROUP. Requires admin privileges.
55
+ list_key: "auth list [GROUP]"
56
+ list_value: >-
57
+ List authorization groups and the users in them. If GROUP is supplied,
58
+ only lists that group.
59
+ user_added: "%{user} was added to %{group}."
60
+ user_already_in: "%{user} was already in %{group}."
61
+ user_removed: "%{user} was removed from %{group}."
62
+ user_not_in: "%{user} was not in %{group}."
63
+ empty_state: There are no authorization groups yet.
64
+ empty_state_group: "There is no authorization group named %{group}."
65
+ format: "Format"
66
+ admin_management: Administrators can only be managed via Lita config.
67
+ no_user_found: 'No user was found with the identifier "%{identifier}".'
68
+ help:
69
+ handler_contains: Handler "%{handler}" defines the following commands
70
+ help:
71
+ help_value: Lists help information for terms and command the robot will respond to.
72
+ help_query_key: "help QUERY"
73
+ help_query_value: Lists help information for commands matching QUERY.
74
+ info: >-
75
+ Send the message "%{address}help QUERY" to see matching help messages. QUERY may be the
76
+ name of a handler, text matching a message pattern a handler responds to, or text
77
+ matching the description of a message pattern a handler responds to. The following
78
+ handlers are installed:
79
+ no_help_found: "No matching handlers, message patterns, or descriptions found."
80
+ pattern_or_description_contains: Message patterns or descriptions that match "%{query}"
81
+ unauthorized: " [Unauthorized]"
82
+ info:
83
+ help:
84
+ info_value: Replies with the current version of Lita.
85
+ room:
86
+ help:
87
+ join_key: join ROOM_ID
88
+ join_value: Makes the robot join the room with room ID ROOM_ID.
89
+ part_key: part ROOM_ID
90
+ part_value: Makes the robot part from the room with room ID ROOM_ID.
91
+ users:
92
+ find_empty_state: No matching users found.
93
+ help:
94
+ find_key: users find SEARCH_TERM
95
+ find_value: Find a Lita user by ID, name, or mention name.
96
+ http:
97
+ exception: |
98
+ Lita's built-in web server could not be started. The exception was:
99
+ %{message}
100
+ Full backtrace:
101
+ %{backtrace}
102
+ plugin:
103
+ name_required: Plugins that are anonymous classes must set a namespace or define self.name.
104
+ redis:
105
+ exception: |
106
+ Lita could not connect to Redis. The exception was:
107
+ %{message}
108
+ Full backtrace:
109
+ %{backtrace}
110
+ test_mode_exception: |
111
+ Lita could not connect to Redis. The exception was:
112
+ %{message}
113
+ robot:
114
+ unknown_adapter: "Unknown adapter: :%{adapter}."
115
+ rspec:
116
+ full_suite_required: Lita::RSpec requires both RSpec::Mocks and RSpec::Expectations.
117
+ version_3_required: RSpec::Core 3 or greater is required to use Lita::RSpec.
118
+ rack_test_required: Rack::Test is required to use the `http` method of Lita::RSpec.
119
+ lita_3_compatibility_mode: >-
120
+ WARNING: Lita 3 compatibility mode is deprecated in Lita 5 and will be removed in Lita 6.
121
+ It no longer has any effect. Please remove any calls to `Lita.version_3_compatibility_mode`.
122
+ route_failure: |-
123
+ Expected message "%{message}" to route to :%{route}, but didn't.
124
+ negative_route_failure: |-
125
+ Expected message "%{message}" not to route to :%{route}, but did.
126
+ http_route_failure: |-
127
+ Expected request "%{method} %{path}" to route to :%{route}, but didn't.
128
+ negative_http_route_failure: |-
129
+ Expected request "%{method} %{path}" not to route to :%{route}, but did.
130
+ event_subscription_failure: |-
131
+ Expected triggering event "%{event}" to invoke :%{route}, but didn't.
132
+ negative_event_subscription_failure: |-
133
+ Expected triggering event "%{event}" not to invoke :%{route}, but did.
134
+ source:
135
+ user_or_room_required: Either a user or a room is required.
136
+ template:
137
+ missing_template: Missing template file at %{path}.
@@ -0,0 +1,16 @@
1
+ #encoding: utf-8
2
+ require_relative "../../spec_helper"
3
+
4
+ describe Lita::Handlers::Chengyujielong, lita_handler: true do
5
+ describe ':routing' do
6
+ it '返回成语提示' do
7
+ send_message 'Lita 随便'
8
+ expect(replies.last).to eq('请输入成语')
9
+ end
10
+
11
+ it '返回成语' do
12
+ send_message 'Lita 当仁不让'
13
+ expect(replies.last).to match(/^让.{3}$/)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ require_relative "../../lita-chengyujielong/lib/lita-chengyujielong"
2
+ require "lita/rspec"
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-chengyujielong
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - yfscret
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry-byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 3.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.0.0
83
+ description: lita-study
84
+ email:
85
+ - 305667862@qq.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - lib/lita-chengyujielong.rb
95
+ - lib/lita/db/chengyus.sqlite3
96
+ - lib/lita/handlers/chengyujielong.rb
97
+ - lita-chengyujielong.gemspec
98
+ - locales/en.yml
99
+ - spec/lita/handlers/chengyujielong_spec.rb
100
+ - spec/spec_helper.rb
101
+ - templates/.gitkeep
102
+ homepage: https://gitee.com/yfscret/lita-study.git
103
+ licenses:
104
+ - MIT
105
+ metadata:
106
+ lita_plugin_type: handler
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.1.4
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: lita-study
126
+ test_files:
127
+ - spec/lita/handlers/chengyujielong_spec.rb
128
+ - spec/spec_helper.rb