cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

sending Msg to the channel #156

Closed pradhans0906 closed 10 years ago

pradhans0906 commented 10 years ago

Hi! i just started using this gem and building a bot on this framework.

Is it possible to make the bot send a message to a channel when anybody joins channel ?

Could anybody help me on this.

cmays90 commented 10 years ago

Use the listen_to :join handler.

Example:

Class GreetOnJoin
    include Cinch::Plugin

    listen_to :join, :method=>:join

    def join(m, *args)
        exit if(m.user == @bot)  #otherwise both greats on entry to a channel
        m.reply "Welcome to #{m.channel}"
    end
end
pradhans0906 commented 10 years ago

Thanks for your response ...

Am trying as follows listen_to :join, method: :on_join def on_join(m) post_message(options(m, opcode: 'join', nick: m.user.nick, line: "#{m.user.nick} use this link to get more info"))

But looks like it doesn't work ..can you please let me know what wrong am doing here ?