mastodon_command 0.1.3 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -56
- 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 +7 -7
- data/lib/mastodon_command/statuses_controller.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d137a7b69f917c91d0adceb3f8b85674451b3150325a2af385c90ac65f7f88
|
4
|
+
data.tar.gz: d2ee552c7c866da5f0b8cb3210f6758f1f4d35002dbc954c1a0456a1842a135e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec4f12f73bc0535f86f0810f3671ea31c90bea1a819bce3248ef8befd9b13e880c70f71352373b4e01033d76d04b6ed20bb03cc344869d9cc0092da9f462add1
|
7
|
+
data.tar.gz: 14857f581ed5fef4026167d5d0e54cea4a39e997dd729bb03a73f9c63bb6e448a99e4a6c1066d6364ae6222c1805d6f3979be8d1b7d36a91c35de7a590da4f44
|
data/README.md
CHANGED
@@ -1,70 +1,65 @@
|
|
1
1
|
# MastodonCommand
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
2
|
+
- おみくじ機能や大阪弁機能などをつけることができます。
|
3
|
+
- ローカルでマストドンのバージョン3.4.6にて動作を確認済み
|
4
|
+
(このプログラムを使って問題が起こっても保証はできないので予めご了承ください🙇♂️)
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
8
|
```ruby
|
12
9
|
gem 'mastodon_command'
|
13
10
|
```
|
14
11
|
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install mastodon_command
|
22
|
-
|
23
12
|
## Usage
|
24
13
|
|
25
|
-
-
|
26
|
-
|
14
|
+
- 下記に設定ファイルを作成し、マストドンを再起動すると`#おみくじ`などのタグをつけてトゥートすることで動作確認できます
|
15
|
+
|
27
16
|
|
28
17
|
```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
|
-
|
18
|
+
# config\initializers\mastodon_command.rb
|
19
|
+
|
20
|
+
Rails.application.configure do
|
21
|
+
config.after_initialize do
|
22
|
+
MastodonCommand.setup do |status|
|
23
|
+
# おみくじ機能
|
24
|
+
fortune = MastodonCommand::Random.new('[ \n]?#(おみくじ|占い|運勢)[ \n]?', %w(大吉 中吉 小吉 吉 半吉 凶 大凶))
|
25
|
+
status = fortune.convert(status) if fortune.match(status)
|
26
|
+
|
27
|
+
# 大阪弁機能
|
28
|
+
osaka = MastodonCommand::Lang.new('[ \n]?#(大阪弁)[ \n]?', [
|
29
|
+
{
|
30
|
+
pattern: 'です',
|
31
|
+
replace: 'やで'
|
32
|
+
},
|
33
|
+
{
|
34
|
+
pattern: 'する',
|
35
|
+
replace: 'しよる'
|
36
|
+
},
|
37
|
+
{
|
38
|
+
pattern: 'だった',
|
39
|
+
replace: 'やった'
|
40
|
+
},
|
41
|
+
{
|
42
|
+
pattern: 'すごい',
|
43
|
+
replace: 'えらい'
|
44
|
+
},
|
45
|
+
{
|
46
|
+
pattern: '疲れた',
|
47
|
+
replace: 'しんどい'
|
48
|
+
},
|
49
|
+
{
|
50
|
+
pattern: 'ない',
|
51
|
+
replace: 'あれへん'
|
52
|
+
},
|
53
|
+
{
|
54
|
+
pattern: '(バカ|ばか)',
|
55
|
+
replace: 'アホ'
|
56
|
+
},
|
57
|
+
|
58
|
+
])
|
59
|
+
status = osaka.convert(status) if osaka.match(status)
|
60
|
+
status
|
61
|
+
end
|
62
|
+
end
|
68
63
|
end
|
69
64
|
```
|
70
65
|
|
@@ -84,4 +79,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
84
79
|
|
85
80
|
## Contributing
|
86
81
|
|
87
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kenchiki/mastodon_command.
|
@@ -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,14 +1,14 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenchiki
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,13 +71,13 @@ 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/
|
78
78
|
licenses: []
|
79
79
|
metadata: {}
|
80
|
-
post_install_message:
|
80
|
+
post_install_message:
|
81
81
|
rdoc_options: []
|
82
82
|
require_paths:
|
83
83
|
- lib
|
@@ -92,8 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
96
|
-
signing_key:
|
95
|
+
rubygems_version: 3.2.32
|
96
|
+
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Mastodon Toot Command.
|
99
99
|
test_files: []
|
@@ -1,17 +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: status_params[:in_reply_to_id].blank? ? nil : Status.find(status_params[:in_reply_to_id]),
|
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
|
-
idempotency: request.headers['Idempotency-Key'])
|
14
|
-
|
15
|
-
render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer
|
16
|
-
end
|
17
|
-
end
|