mastodon_command 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -39
- data/lib/mastodon_command/statuses_controller_patch.rb +21 -0
- data/lib/mastodon_command/version.rb +1 -1
- data/lib/mastodon_command.rb +2 -2
- metadata +2 -2
- data/lib/mastodon_command/statuses_controller.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f9df536d012c24316faebd31dd03b170bb62bc2c14058019c8009856356bb56
|
4
|
+
data.tar.gz: 3f142dbc786397eb0d1e6b154d483bb28154f2be5799598cedadb0245f15f215
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6344aa5de07261c5e0c763906778d5c9c2762be39ee3f9acb00115909d2541dab3acbe3fb0a003e55f586d0f09cf10ee37732e991c6da67dcf7421361b3ff8b8
|
7
|
+
data.tar.gz: 6b01354099cbaefba9c71fa0ab64abbb9aa7145d3c6928df13967c4af04f43de749f3f93f21b480e5c0d47506a63af269dc7e6f0e091ee50c631ba8a45ec9380
|
data/README.md
CHANGED
@@ -26,45 +26,49 @@ Or install it yourself as:
|
|
26
26
|
config\initializers\mastodon_command.rb
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
29
|
+
Rails.application.configure do
|
30
|
+
config.after_initialize do
|
31
|
+
MastodonCommand.setup do |status|
|
32
|
+
# おみくじ機能
|
33
|
+
fortune = MastodonCommand::Random.new('[ \n]?#(おみくじ|占い|運勢)[ \n]?', %w(大吉 中吉 小吉 吉 半吉 凶 大凶))
|
34
|
+
status = fortune.convert(status) if fortune.match(status)
|
35
|
+
|
36
|
+
# 大阪弁機能
|
37
|
+
osaka = MastodonCommand::Lang.new('[ \n]?#(大阪弁)[ \n]?', [
|
38
|
+
{
|
39
|
+
pattern: 'です',
|
40
|
+
replace: 'やで'
|
41
|
+
},
|
42
|
+
{
|
43
|
+
pattern: 'する',
|
44
|
+
replace: 'しよる'
|
45
|
+
},
|
46
|
+
{
|
47
|
+
pattern: 'だった',
|
48
|
+
replace: 'やった'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
pattern: 'すごい',
|
52
|
+
replace: 'えらい'
|
53
|
+
},
|
54
|
+
{
|
55
|
+
pattern: '疲れた',
|
56
|
+
replace: 'しんどい'
|
57
|
+
},
|
58
|
+
{
|
59
|
+
pattern: 'ない',
|
60
|
+
replace: 'あれへん'
|
61
|
+
},
|
62
|
+
{
|
63
|
+
pattern: '(バカ|ばか)',
|
64
|
+
replace: 'アホ'
|
65
|
+
},
|
66
|
+
|
67
|
+
])
|
68
|
+
status = osaka.convert(status) if osaka.match(status)
|
69
|
+
status
|
70
|
+
end
|
71
|
+
end
|
68
72
|
end
|
69
73
|
```
|
70
74
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MastodonCommand
|
2
|
+
module StatusesControllerPatch
|
3
|
+
def create
|
4
|
+
status = MastodonCommand.convert_toot(status_params[:status])
|
5
|
+
@status = PostStatusService.new.call(current_user.account,
|
6
|
+
text: status,
|
7
|
+
thread: @thread,
|
8
|
+
media_ids: status_params[:media_ids],
|
9
|
+
sensitive: status_params[:sensitive],
|
10
|
+
spoiler_text: status_params[:spoiler_text],
|
11
|
+
visibility: status_params[:visibility],
|
12
|
+
scheduled_at: status_params[:scheduled_at],
|
13
|
+
application: doorkeeper_token.application,
|
14
|
+
poll: status_params[:poll],
|
15
|
+
idempotency: request.headers['Idempotency-Key'],
|
16
|
+
with_rate_limit: true)
|
17
|
+
|
18
|
+
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/mastodon_command.rb
CHANGED
@@ -2,7 +2,7 @@ require "mastodon_command/version"
|
|
2
2
|
require "mastodon_command/convert"
|
3
3
|
require "mastodon_command/convert_random"
|
4
4
|
require "mastodon_command/convert_lang"
|
5
|
-
require "mastodon_command/
|
5
|
+
require "mastodon_command/statuses_controller_patch"
|
6
6
|
|
7
7
|
module MastodonCommand
|
8
8
|
def self.setup(&proc)
|
@@ -19,7 +19,7 @@ module MastodonCommand
|
|
19
19
|
end
|
20
20
|
|
21
21
|
# Monkey patch
|
22
|
-
Api::V1::StatusesController.prepend(
|
22
|
+
Api::V1::StatusesController.prepend(MastodonCommand::StatusesControllerPatch)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mastodon_command
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenchiki
|
@@ -71,7 +71,7 @@ files:
|
|
71
71
|
- lib/mastodon_command/convert.rb
|
72
72
|
- lib/mastodon_command/convert_lang.rb
|
73
73
|
- lib/mastodon_command/convert_random.rb
|
74
|
-
- lib/mastodon_command/
|
74
|
+
- lib/mastodon_command/statuses_controller_patch.rb
|
75
75
|
- lib/mastodon_command/version.rb
|
76
76
|
- mastodon_command.gemspec
|
77
77
|
homepage: http://nagai-galaxy.com/
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module ApiV1StatusesControllerPatch
|
2
|
-
def create
|
3
|
-
status = MastodonCommand.convert_toot(status_params[:status])
|
4
|
-
@status = PostStatusService.new.call(current_user.account,
|
5
|
-
text: status,
|
6
|
-
thread: @thread,
|
7
|
-
media_ids: status_params[:media_ids],
|
8
|
-
sensitive: status_params[:sensitive],
|
9
|
-
spoiler_text: status_params[:spoiler_text],
|
10
|
-
visibility: status_params[:visibility],
|
11
|
-
scheduled_at: status_params[:scheduled_at],
|
12
|
-
application: doorkeeper_token.application,
|
13
|
-
poll: status_params[:poll],
|
14
|
-
idempotency: request.headers['Idempotency-Key'],
|
15
|
-
with_rate_limit: true)
|
16
|
-
|
17
|
-
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
18
|
-
end
|
19
|
-
end
|