/lib/plugins/addspace.rb
Ruby | 27 lines | 17 code | 2 blank | 8 comment | 0 complexity | efea3d8f04f3d7a1201a637625df0ce2 MD5 | raw file
- # -*- coding: utf-8 -*-
- config.plugins.addspace.set_default( :before, [ %r{https?://} ] )
- config.plugins.addspace.set_default( :after, %w{ ★ ☆ △ ▽ … })
- module Termtter::Client
- add_filter do |statuses, event|
- statuses.each do |s|
- config.plugins.addspace.before.each do |c|
- s.text.gsub!(/(?<=\S)(#{c})/, ' \1' )
- end
- end
- statuses.each do |s|
- config.plugins.addspace.after.each do |c|
- s.text.gsub!(/(#{c})(?=\S)/, '\1 ' )
- end
- statuses
- end
- end
- end
- # addspace
- # add space before or after specified words.
- # example:
- # before: ABCDEhttp://~~~
- # after: ABCDE http://~~~
- # before: ★★★
- # after: ★ ★ ★