2014-01-30 44 views
1

我刚开始使用这个cinch gem并使用这个框架来开发一个bot。发送消息到cinch bot框架中的频道

面对这个。我的问题本来是想BOT将消息发送到一个通道时,任何人加入通道

任何人可以帮助我在此。

代码:

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")) 

你能不能请让我知道什么是缺少这一点。

+0

你能不能解释一下什么不顺心时,你试试?我可以看到'def'缺少一个'end',但不知道这是否是您的问题 –

+0

您好,没有任何反应意味着它不会加入。 – phulei

回答

1

我不确定你的post_message命令是什么,但如果它是在Cinch中找到的东西,请不要使用它。相反,使用内置的命令的消息

def on_join(m) 
    # Don't greet the bot. 
    unless m.user == @bot 
    # Reply to the user who joined, the true prepends the line with the user's name 
    m.reply "Use this link to get more info - http://whatever", true 
end 

然后回应:

15:30 -!- Irssi: #bottest: Total of 2 nicks [0 ops, 0 halfops, 0 voices, 2 normal] 
15:30 -!- Channel #bottest created Mon Feb 24 15:30:17 2014 
15:30 < bot> user: Use this link to get more info - http://whatever 
相关问题