-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathspell.rb
718 lines (641 loc) · 23.6 KB
/
spell.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
# coding: utf-8
Plugin.create(:worldon) do
pm = Plugin::Worldon
# command
custom_postable = Proc.new do |opt|
world, = Plugin.filtering(:world_current, nil)
[:worldon, :portal].include?(world.class.slug) && opt.widget.editable?
end
def visibility2select(s)
case s
when "public"
:"1public"
when "unlisted"
:"2unlisted"
when "private"
:"3private"
when "direct"
:"4direct"
else
nil
end
end
def select2visibility(s)
case s
when :"1public"
"public"
when :"2unlisted"
"unlisted"
when :"3private"
"private"
when :"4direct"
"direct"
else
nil
end
end
command(
:worldon_custom_post,
name: 'カスタム投稿',
condition: custom_postable,
visible: true,
icon: Skin['post.png'],
role: :postbox
) do |opt|
world, = Plugin.filtering(:world_current, nil)
i_postbox = opt.widget
postbox, = Plugin.filtering(:gui_get_gtk_widget, i_postbox)
body = postbox.widget_post.buffer.text
reply_to = postbox.worldon_get_reply_to
dialog "カスタム投稿" do
# オプションを並べる
multitext "CW警告文", :spoiler_text
self[:body] = body
multitext "本文", :body
self[:sensitive] = world.account.source.sensitive
boolean "閲覧注意", :sensitive
visibility_default = world.account.source.privacy
if reply_to.is_a?(pm::Status) && reply_to.visibility == "direct"
# 返信先がDMの場合はデフォルトでDMにする。但し編集はできるようにするため、この時点でデフォルト値を代入するのみ。
visibility_default = "direct"
end
self[:visibility] = visibility2select(visibility_default)
select "公開範囲", :visibility do
option :"1public", "公開"
option :"2unlisted", "未収載"
option :"3private", "非公開"
option :"4direct", "ダイレクト"
end
# mikutter-uwm-hommageの設定を勝手に持ってくる
dirs = 10.times.map { |i|
UserConfig["galary_dir#{i + 1}".to_sym]
}.compact.select { |str|
!str.empty?
}.to_a
fileselect "添付メディア1", :media1, shortcuts: dirs, use_preview: true
fileselect "添付メディア2", :media2, shortcuts: dirs, use_preview: true
fileselect "添付メディア3", :media3, shortcuts: dirs, use_preview: true
fileselect "添付メディア4", :media4, shortcuts: dirs, use_preview: true
end.next do |result|
# 投稿
# まず画像をアップロード
media_ids = []
media_urls = []
(1..4).each do |i|
if result[:"media#{i}"]
path = Pathname(result[:"media#{i}"])
hash = pm::API.call(:post, world.domain, '/api/v1/media', world.access_token, file: path)
if hash.value && hash[:error].nil?
media_ids << hash[:id].to_i
media_urls << hash[:text_url]
else
Deferred.fail(hash[:error] ? hash[:error] : 'メディアのアップロードに失敗しました')
next
end
end
end
# 画像がアップロードできたらcompose spellを起動
opts = {
body: result[:body]
}
if !media_ids.empty?
opts[:media_ids] = media_ids
end
if !result[:spoiler_text].empty?
opts[:spoiler_text] = result[:spoiler_text]
end
opts[:sensitive] = result[:sensitive]
opts[:visibility] = select2visibility(result[:visibility])
compose(world, reply_to, **opts)
if Gtk::PostBox.list[0] != postbox
postbox.destroy
else
postbox.widget_post.buffer.text = ''
end
end
end
command(:worldon_follow_user, name: 'フォローする', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m|
follow?(world, m.user)
}
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
opt.messages.map { |m|
m.user
}.each { |user|
follow(world, user)
}
end
command(:worldon_unfollow_user, name: 'フォロー解除', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m|
unfollow?(world, m.user)
}
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
opt.messages.map { |m|
m.user
}.each { |user|
unfollow(world, user)
}
end
command(:worldon_mute_user, name: 'ミュートする', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m| mute_user?(world, m.user) }
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
users = opt.messages.map { |m| m.user }.uniq
dialog "ミュートする" do
label "以下のユーザーをミュートしますか?"
users.each { |user|
link user
}
end.next do
users.each { |user|
mute_user(world, user)
}
end
end
command(:worldon_block_user, name: 'ブロックする', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m| block_user?(world, m.user) }
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
users = opt.messages.map { |m| m.user }.uniq
dialog "ブロックする" do
label "以下のユーザーをブロックしますか?"
users.each { |user|
link user
}
end.next do
users.each { |user|
block_user(world, user)
}
end
end
command(:worldon_report_status, name: '通報する', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m| report_for_spam?(world, m) }
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
dialog "通報する" do
error_msg = nil
while true
label "以下のトゥートを #{world.domain} インスタンスの管理者に通報しますか?"
opt.messages.each { |message|
link message
}
multitext "コメント(1000文字以内) ※必須", :comment
label error_msg if error_msg
result = await_input
error_msg = "コメントを入力してください。" if (result[:comment].nil? || result[:comment].empty?)
error_msg = "コメントが長すぎます(#{result[:comment].to_s.size}文字)" if result[:comment].to_s.size > 1000
break unless error_msg
end
label "しばらくお待ち下さい..."
results = opt.messages.select { |message|
message.class.slug == :worldon_status
}.map { |message|
message.reblog ? message.reblog : message
}.sort_by { |message|
message.account.acct
}.chunk { |message|
message.account.acct
}.each { |acct, messages|
world.report_for_spam(messages, result[:comment])
}
label "完了しました。"
end
end
command(:worldon_pin_message, name: 'ピン留めする', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m| pin_message?(world, m) }
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
opt.messages.select{ |m|
pin_message?(world, m)
}.each { |status|
world.pin(status)
}
end
command(:worldon_unpin_message, name: 'ピン留めを解除する', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
opt.messages.any? { |m| unpin_message?(world, m) }
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
opt.messages.select{ |m|
unpin_message?(world, m)
}.each { |status|
world.unpin(status)
}
end
command(:worldon_edit_list_membership, name: 'リストへの追加・削除', visible: true, role: :timeline,
condition: lambda { |opt|
world, = Plugin.filtering(:world_current, nil)
[:worldon, :portal].include?(world.class.slug)
}) do |opt|
world, = Plugin.filtering(:world_current, nil)
next unless world
user = opt.messages.first&.user
next unless user
lists = world.get_lists!.inject(Hash.new) do |h, l|
key = l[:id].to_sym
val = l[:title]
h[key] = val
h
end
user_id = pm::API.get_local_account_id(world, user)
result = pm::API.call(:get, world.domain, "/api/v1/accounts/#{user_id}/lists", world.access_token)
membership = result.value.to_a.inject(Hash.new) do |h, l|
key = l[:id].to_sym
val = l[:title]
h[key] = val
h
end
dialog "リストへの追加・削除" do
self[:lists] = membership.keys
multiselect "所属させるリストを選択してください", :lists do
lists.keys.each do |k|
option(k, lists[k])
end
end
end.next do |result|
selected_ids = result[:lists]
selected_ids.each do |list_id|
unless membership[list_id]
# 追加
pm::API.call(:post, world.domain, "/api/v1/lists/#{list_id}/accounts", world.access_token, account_ids: [user_id])
end
end
membership.keys.each do |list_id|
unless selected_ids.include?(list_id)
# 削除
pm::API.call(:delete, world.domain, "/api/v1/lists/#{list_id}/accounts", world.access_token, account_ids: [user_id])
end
end
end
end
# spell系
# 投稿
defspell(:compose, :worldon) do |world, body:, **opts|
if opts[:visibility].nil?
opts.delete :visibility
else
opts[:visibility] = opts[:visibility].to_s
end
if opts[:sensitive].nil? && opts[:media_ids].nil? && opts[:spoiler_text].nil?
opts[:sensitive] = false;
end
result = world.post(message: body, **opts)
if result.nil?
warn "投稿に失敗したかもしれません"
$stdout.flush
nil
else
new_status = pm::Status.build(world.domain, [result.value]).first
Plugin.call(:posted, world, [new_status]) if new_status
Plugin.call(:update, world, [new_status]) if new_status
new_status
end
end
memoize def media_tmp_dir
path = Pathname(Environment::TMPDIR) / 'worldon' / 'media'
FileUtils.mkdir_p(path.to_s)
path
end
defspell(:compose, :worldon, :photo) do |world, photo, body:, **opts|
photo.download.next{|photo|
ext = photo.uri.path.split('.').last || 'png'
tmp_name = Digest::MD5.hexdigest(photo.uri.to_s) + ".#{ext}"
tmp_path = media_tmp_dir / tmp_name
file_put_contents(tmp_path, photo.blob)
hash = pm::API.call(:post, world.domain, '/api/v1/media', world.access_token, file: tmp_path.to_s)
if hash
media_id = hash[:id]
compose(world, body: body, media_ids: [media_id], **opts)
end
}
end
defspell(:compose, :worldon, :worldon_status) do |world, status, body:, **opts|
if opts[:visibility].nil?
opts.delete :visibility
if status.visibility == "direct"
# 返信先がDMの場合はデフォルトでDMにする。但し呼び出し元が明示的に指定してきた場合はそちらを尊重する。
opts[:visibility] = "direct"
end
else
opts[:visibility] = opts[:visibility].to_s
end
if opts[:sensitive].nil? && opts[:media_ids].nil? && opts[:spoiler_text].nil?
opts[:sensitive] = false;
end
result = world.post(to: status, message: body, **opts)
if result.nil?
warn "投稿に失敗したかもしれません"
$stdout.flush
nil
else
new_status = pm::Status.build(world.domain, [result.value]).first
Plugin.call(:posted, world, [new_status]) if new_status
Plugin.call(:update, world, [new_status]) if new_status
new_status
end
end
defspell(:destroy, :worldon, :worldon_status, condition: -> (world, status) {
world.account.acct == status.actual_status.account.acct
}) do |world, status|
status_id = pm::API.get_local_status_id(world, status.actual_status)
if status_id
ret = pm::API.call(:delete, world.domain, "/api/v1/statuses/#{status_id}", world.access_token)
Plugin.call(:destroyed, status.actual_status)
status.actual_status
end
end
# ふぁぼ
defspell(:favorite, :worldon, :worldon_status,
condition: -> (world, status) { !status.actual_status.favorite?(world) }
) do |world, status|
Thread.new {
status_id = pm::API.get_local_status_id(world, status.actual_status)
if status_id
Plugin.call(:before_favorite, world, world.account, status)
ret = pm::API.call(:post, world.domain, '/api/v1/statuses/' + status_id.to_s + '/favourite', world.access_token)
if ret.nil? || ret[:error]
Plugin.call(:fail_favorite, world, world.account, status)
else
status.actual_status.favourited = true
status.actual_status.favorite_accts << world.account.acct
Plugin.call(:favorite, world, world.account, status)
end
end
}
end
defspell(:favorited, :worldon, :worldon_status,
condition: -> (world, status) { status.actual_status.favorite?(world) }
) do |world, status|
Delayer::Deferred.new.next {
status.actual_status.favorite?(world)
}
end
defspell(:unfavorite, :worldon, :worldon_status, condition: -> (world, status) { status.favorite?(world) }) do |world, status|
Thread.new {
status_id = pm::API.get_local_status_id(world, status.actual_status)
if status_id
ret = pm::API.call(:post, world.domain, '/api/v1/statuses/' + status_id.to_s + '/unfavourite', world.access_token)
if ret.nil? || ret[:error]
warn "[worldon] failed to unfavourite: #{ret}"
else
status.actual_status.favourited = false
status.actual_status.favorite_accts.delete(world.account.acct)
Plugin.call(:favorite, world, world.account, status)
end
status.actual_status
end
}
end
# ブースト
defspell(:share, :worldon, :worldon_status,
condition: -> (world, status) { status.actual_status.rebloggable?(world) }
) do |world, status|
world.reblog(status.actual_status).next{|shared|
Plugin.call(:posted, world, [shared])
Plugin.call(:update, world, [shared])
}
end
defspell(:shared, :worldon, :worldon_status,
condition: -> (world, status) { status.actual_status.shared?(world) }
) do |world, status|
Delayer::Deferred.new.next {
status.actual_status.shared?(world)
}
end
defspell(:destroy_share, :worldon, :worldon_status, condition: -> (world, status) { status.actual_status.shared?(world) }) do |world, status|
Thread.new {
status_id = pm::API.get_local_status_id(world, status.actual_status)
if status_id
ret = pm::API.call(:post, world.domain, '/api/v1/statuses/' + status_id.to_s + '/unreblog', world.access_token)
reblog = nil
if ret.nil? || ret[:error]
warn "[worldon] failed to unreblog: #{ret}"
else
status.actual_status.reblogged = false
reblog = status.actual_status.retweeted_statuses.select{|s| s.account.acct == world.user_obj.acct }.first
status.actual_status.reblog_status_uris.delete_if {|pair| pair[:acct] == world.user_obj.acct }
if reblog
Plugin.call(:destroyed, [reblog])
end
end
reblog
end
}
end
# プロフィール更新系
update_profile_block = Proc.new do |world, **opts|
world.update_profile(**opts)
end
defspell(:update_profile, :worldon, &update_profile_block)
defspell(:update_profile_name, :worldon, &update_profile_block)
defspell(:update_profile_biography, :worldon, &update_profile_block)
defspell(:update_profile_icon, :worldon, :photo) do |world, photo|
update_profile_block.call(world, icon: photo)
end
defspell(:update_profile_header, :worldon, :photo) do |world, photo|
update_profile_block.call(world, header: photo)
end
command(
:worldon_update_profile,
name: 'プロフィール変更',
condition: -> (opt) {
world = Plugin.filtering(:world_current, nil).first
[:worldon, :portal].include?(world.class.slug)
},
visible: true,
role: :postbox
) do |opt|
world = Plugin.filtering(:world_current, nil).first
profiles = Hash.new
profiles[:name] = world.account.display_name
profiles[:biography] = world.account.source.note
profiles[:locked] = world.account.locked
profiles[:bot] = world.account.bot
dialog "プロフィール変更" do
self[:name] = profiles[:name]
self[:biography] = profiles[:biography]
self[:locked] = profiles[:locked]
self[:bot] = profiles[:bot]
input '表示名', :name
multitext 'プロフィール', :biography
photoselect 'アイコン', :icon
photoselect 'ヘッダー', :header
boolean '承認制アカウントにする', :locked
boolean 'これは BOT アカウントです', :bot
end.next do |result|
diff = Hash.new
diff[:name] = result[:name] if (result[:name] && result[:name].size > 0 && profiles[:name] != result[:name])
diff[:biography] = result[:biography] if (result[:biography] && result[:biography].size > 0 && profiles[:biography] != result[:biography])
diff[:locked] = result[:locked] if profiles[:locked] != result[:locked]
diff[:bot] = result[:bot] if profiles[:bot] != result[:bot]
diff[:icon] = Pathname(result[:icon]) if result[:icon]
diff[:header] = Pathname(result[:header]) if result[:header]
next if diff.empty?
world.update_profile(**diff)
end
end
# 検索
intent :worldon_tag, label: "Mastodonハッシュタグ(Worldon)" do |token|
Plugin.call(:search_start, "##{token.model.name}")
end
# アカウント
intent :worldon_account, label: "Mastodonアカウント(Worldon)" do |token|
Plugin.call(:worldon_account_timeline, token.model)
end
on_worldon_account_timeline do |account|
acct, domain = account.acct.split('@')
tl_slug = :"worldon-account-timeline_#{acct}@#{domain}"
tab :"worldon-account-tab_#{acct}@#{domain}" do |i_tab|
set_icon account.icon
set_deletable true
temporary_tab
timeline(tl_slug) do
order do |message|
ord = message.created.to_i
if message.is_a? pm::AccountProfile
ord = [5000000000000000, GLib::MAXLONG].min
elsif message.respond_to?(:pinned?) && message.pinned?
bias = 66200000000000
ord = [ord + bias, GLib::MAXLONG - 1].min
end
ord
end
end
end
timeline(tl_slug).active!
profile = pm::AccountProfile.new(account: account)
timeline(tl_slug) << profile
Thread.new do
world, = Plugin.filtering(:world_current, nil)
if [:worldon, :portal].include? world.class.slug
account_id = pm::API.get_local_account_id(world, account)
res = pm::API.call(:get, world.domain, "/api/v1/accounts/#{account_id}/statuses?pinned=true", world.access_token)
if res.value
timeline(tl_slug) << pm::Status.build(world.domain, res.value.map{|record|
record[:pinned] = true
record
})
end
res = pm::API.call(:get, world.domain, "/api/v1/accounts/#{account_id}/statuses", world.access_token)
if res.value
timeline(tl_slug) << pm::Status.build(world.domain, res.value)
end
next if domain == world.domain
end
headers = {
'Accept' => 'application/activity+json'
}
res = pm::API.call(:get, domain, "/users/#{acct}/outbox?page=true", nil, {}, headers)
next unless res[:orderedItems]
res[:orderedItems].map do |record|
case record[:type]
when "Create"
# トゥート
record[:object][:url]
when "Announce"
# ブースト
pm::Status::TOOT_ACTIVITY_URI_RE.match(record[:atomUri]) do |m|
"https://#{m[:domain]}/@#{m[:acct]}/#{m[:status_id]}"
end
end
end.compact.each do |url|
status = pm::Status.findbyurl(url) || pm::Status.fetch(url)
timeline(tl_slug) << status if status
end
end
end
defspell(:search, :worldon) do |world, **opts|
count = [opts[:count], 40].min
q = opts[:q]
if q.start_with? '#'
q = URI.encode_www_form_component(q[1..-1])
resp = Plugin::Worldon::API.call(:get, world.domain, "/api/v1/timelines/tag/#{q}", world.access_token, limit: count)
return nil if resp.nil?
resp = resp.to_a
else
resp = Plugin::Worldon::API.call(:get, world.domain, '/api/v2/search', world.access_token, q: q)
return nil if resp.nil?
resp = resp[:statuses]
end
Plugin::Worldon::Status.build(world.domain, resp)
end
defspell(:follow, :worldon, :worldon_account,
condition: -> (world, account) { !world.following?(account.acct) }
) do |world, account|
world.follow(account)
end
defspell(:unfollow, :worldon, :worldon_account,
condition: -> (world, account) { world.following?(account.acct) }
) do |world, account|
world.unfollow(account)
end
defspell(:following, :worldon, :worldon_account,
condition: -> (world, account) { true }
) do |world, account|
world.following?(account)
end
defspell(:mute_user, :worldon, :worldon_account,
condition: -> (world, account) { !Plugin::Worldon::Status.muted?(account.acct) }
) do |world, account|
world.mute(account)
end
defspell(:unmute_user, :worldon, :worldon_account,
condition: -> (world, account) { Plugin::Worldon::Status.muted?(account.acct) }
) do |world, account|
world.unmute(account)
end
defspell(:block_user, :worldon, :worldon_account,
condition: -> (world, account) { !world.block?(account.acct) }
) do |world, account|
world.block(account)
end
defspell(:unblock_user, :worldon, :worldon_account,
condition: -> (world, account) { world.block?(account.acct) }
) do |world, account|
world.unblock(account)
end
defspell(:report_for_spam, :worldon, :worldon_status) do |world, status, comment: raise|
world.report_for_spam([status], comment)
end
defspell(:report_for_spam, :worldon) do |world, messages:, comment: raise|
world.report_for_spam(messages, comment)
end
defspell(:pin_message, :worldon, :worldon_status,
condition: -> (world, status) {
world.account.acct == status.account.acct && !status.pinned?
# 自分のStatusが(ピン留め状態が不正確になりうるタイミングで)他インスタンスから取得されることはまずないと仮定している
}
) do |world, status|
world.pin(status)
end
defspell(:unpin_message, :worldon, :worldon_status,
condition: -> (world, status) {
world.account.acct == status.account.acct && status.pinned?
# 自分のStatusが(ピン留め状態が不正確になりうるタイミングで)他インスタンスから取得されることはまずないと仮定している
}
) do |world, status|
world.unpin(status)
end
end