Ruby で投稿かスレッドかを確認する

Yes, that looks roughly correct. I think you will need to change the two

message

lines to

return message

so that it stops execution of the function at that point.

What are you trying to achieve here? It might be possible to do something using the existing configuration options, rather than maintaining a fork of the plugin.