4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mastodonで不穏な単語をにゃーんに変えるGemを作ってみた

Last updated at Posted at 2018-04-08

はじめに

Mastodon では非公開や未収載などの機能を使うことでLTLを不穏な空気にしなくて済むことが可能です。

ただ、どうしてもフォローしている人には不穏な単語を見られてしまいます。

そこで、指定の単語を自動的に「にゃーん」という鳴き声に変換してくれるGemを作ってみました。

作ったもの

作ったものはこちらになります。

Nyaaaan

ソースはこちらになります。

実際の使い方

Mastodon のGemfileに以下のように追加

gem 'nyaaaan', '~> 0.1.2'

その後、config/initializers内にnyaaaan.rbを作成し、下記のように変換したい単語を登録していきます。

nyaaaan.rb
Nyaaaan.setup do |status|	
  	
    # 社会性フィルター機能	
    nyaaaan = Nyaaaan::Lang.new('[  \n]?#(社会性フィルター)[  \n]?', [	
      {	
        pattern: '死ね',	
        replace: 'にゃーん'	
      },	
  	
    ])	
    status = nyaaaan.convert(status) if nyaaaan.match(status)	
    status	
end

インストールはこれで終了です。

あとは、#社会性フィルターというハッシュタグを追加してつぶやくだけで指定の単語が置き換わるようになっています。

終わりに

Nyaaaanを使うことでより優しいMastodonライフを送れるようになれればなと思います。

追記

諸事情により公開停止しました。

参考

mastodon_command

Nyaaaan制作にあたって参考にさせていただきました。
誠にありがとうございます。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?