mastodon_command 0.1.9 → 4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +4 -4
- data/lib/mastodon_command/{convert.rb → converter.rb} +2 -3
- data/lib/mastodon_command/{convert_lang.rb → lang_converter.rb} +3 -4
- data/lib/mastodon_command/random_converter.rb +7 -0
- data/lib/mastodon_command/statuses_controller_patch.rb +23 -13
- data/lib/mastodon_command/version.rb +1 -1
- data/lib/mastodon_command.rb +6 -17
- data/mastodon_command.gemspec +3 -3
- metadata +12 -12
- data/lib/mastodon_command/convert_random.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1af1e330d3503e6cee6fa7eb39598b350467ab34be10324578e4578d72aa524
|
4
|
+
data.tar.gz: 84c727198d9b53ea9447b7e556e1f77550937fe900434ede12599b01b1e83623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce92c9bebdc36e57ef3e8bcbf3e657e97404e3d42a91b4b11f9f2950188b25d041fed87fb436a442333e80af3593db56b89df0e7621cc02f16a454b944741ae
|
7
|
+
data.tar.gz: 84473e6b6be833308f2fa6e5867ae8b680a6f39e18f988c1f92e8c6f7bbfbb77eadee56cb7f6445b43fc59fed7187a817f802b5a6f1b653e7121da9234f01e4e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# MastodonCommand
|
2
2
|
- おみくじ機能や大阪弁機能などをつけることができます。
|
3
|
-
- ローカルでマストドンのバージョン3.
|
3
|
+
- ローカルでマストドンのバージョン3.5.0にて動作を確認済み
|
4
4
|
(このプログラムを使って問題が起こっても保証はできないので予めご了承ください🙇♂️)
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
8
8
|
```ruby
|
9
|
-
gem 'mastodon_command', '0.1.
|
9
|
+
gem 'mastodon_command', '0.1.10'
|
10
10
|
```
|
11
11
|
|
12
12
|
## Usage
|
@@ -21,11 +21,11 @@ Rails.application.configure do
|
|
21
21
|
config.after_initialize do
|
22
22
|
MastodonCommand.setup do |status|
|
23
23
|
# おみくじ機能
|
24
|
-
fortune = MastodonCommand::
|
24
|
+
fortune = MastodonCommand::RandomConverter.new('[ \n]?#(おみくじ|占い|運勢)[ \n]?', %w(大吉 中吉 小吉 吉 半吉 凶 大凶))
|
25
25
|
status = fortune.convert(status) if fortune.match(status)
|
26
26
|
|
27
27
|
# 大阪弁機能
|
28
|
-
osaka = MastodonCommand::
|
28
|
+
osaka = MastodonCommand::LangConverter.new('[ \n]?#(大阪弁)[ \n]?', [
|
29
29
|
{
|
30
30
|
pattern: 'です',
|
31
31
|
replace: 'やで'
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module MastodonCommand
|
2
|
-
class
|
3
|
-
|
2
|
+
class LangConverter < MastodonCommand::Converter
|
4
3
|
def convert(input)
|
5
|
-
@replaces.each
|
4
|
+
@replaces.each do |replace|
|
6
5
|
input = input.gsub(/#{replace[:pattern]}/, replace[:replace])
|
7
|
-
|
6
|
+
end
|
8
7
|
input
|
9
8
|
end
|
10
9
|
end
|
@@ -2,20 +2,30 @@ module MastodonCommand
|
|
2
2
|
module StatusesControllerPatch
|
3
3
|
def create
|
4
4
|
status = MastodonCommand.convert_toot(status_params[:status])
|
5
|
-
@status = PostStatusService.new.call(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
@status = PostStatusService.new.call(
|
6
|
+
current_user.account,
|
7
|
+
text: status,
|
8
|
+
thread: @thread,
|
9
|
+
media_ids: status_params[:media_ids],
|
10
|
+
sensitive: status_params[:sensitive],
|
11
|
+
spoiler_text: status_params[:spoiler_text],
|
12
|
+
visibility: status_params[:visibility],
|
13
|
+
language: status_params[:language],
|
14
|
+
scheduled_at: status_params[:scheduled_at],
|
15
|
+
application: doorkeeper_token.application,
|
16
|
+
poll: status_params[:poll],
|
17
|
+
allowed_mentions: status_params[:allowed_mentions],
|
18
|
+
idempotency: request.headers['Idempotency-Key'],
|
19
|
+
with_rate_limit: true
|
20
|
+
)
|
21
|
+
|
18
22
|
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
23
|
+
rescue PostStatusService::UnexpectedMentionsError => e
|
24
|
+
unexpected_accounts = ActiveModel::Serializer::CollectionSerializer.new(
|
25
|
+
e.accounts,
|
26
|
+
serializer: REST::AccountSerializer
|
27
|
+
)
|
28
|
+
render json: { error: e.message, unexpected_accounts: unexpected_accounts }, status: 422
|
19
29
|
end
|
20
30
|
end
|
21
31
|
end
|
data/lib/mastodon_command.rb
CHANGED
@@ -1,25 +1,14 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'mastodon_command/version'
|
2
|
+
require 'mastodon_command/converter'
|
3
|
+
require 'mastodon_command/random_converter'
|
4
|
+
require 'mastodon_command/lang_converter'
|
5
|
+
require 'mastodon_command/statuses_controller_patch'
|
6
6
|
|
7
7
|
module MastodonCommand
|
8
8
|
def self.setup(&proc)
|
9
|
-
|
10
|
-
extend self
|
11
|
-
(
|
12
|
-
class << self;
|
13
|
-
self
|
14
|
-
end).module_eval do
|
15
|
-
define_method 'convert_toot', &proc
|
16
|
-
# define_method 'b' do
|
17
|
-
# p 'b'
|
18
|
-
# end
|
19
|
-
end
|
9
|
+
define_singleton_method(:convert_toot, &proc)
|
20
10
|
|
21
11
|
# Monkey patch
|
22
12
|
Api::V1::StatusesController.prepend(MastodonCommand::StatusesControllerPatch)
|
23
13
|
end
|
24
14
|
end
|
25
|
-
|
data/mastodon_command.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
|
-
spec.add_development_dependency "bundler", "~>
|
33
|
-
spec.add_development_dependency "rake", "~>
|
34
|
-
spec.add_development_dependency "rspec", "~> 3
|
32
|
+
spec.add_development_dependency "bundler", "~> 2"
|
33
|
+
spec.add_development_dependency "rake", "~> 13"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3"
|
35
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastodon_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenchiki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3
|
47
|
+
version: '3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3
|
54
|
+
version: '3'
|
55
55
|
description: Mastodon Toot Command.
|
56
56
|
email:
|
57
57
|
- nagai-kj@nagai-galaxy.com
|
@@ -68,9 +68,9 @@ files:
|
|
68
68
|
- bin/console
|
69
69
|
- bin/setup
|
70
70
|
- lib/mastodon_command.rb
|
71
|
-
- lib/mastodon_command/
|
72
|
-
- lib/mastodon_command/
|
73
|
-
- lib/mastodon_command/
|
71
|
+
- lib/mastodon_command/converter.rb
|
72
|
+
- lib/mastodon_command/lang_converter.rb
|
73
|
+
- lib/mastodon_command/random_converter.rb
|
74
74
|
- lib/mastodon_command/statuses_controller_patch.rb
|
75
75
|
- lib/mastodon_command/version.rb
|
76
76
|
- mastodon_command.gemspec
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
95
|
+
rubygems_version: 3.4.19
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Mastodon Toot Command.
|