1
我們有一個私人聊天服務器在我們擁有的服務器上運行。例如:company.server.com
。我們通過端口5223
與我們的聊天客戶端連接。如何使用jabber-bot連接到聊天服務器
如何讓Jabber-bot連接到此聊天?如果我想連接到某個特定的房間,該怎麼辦?
下面是我有,但它似乎只是掛起,什麼都不做。我相信應該有一個屬性,我應該提供我連接到的服務器的名稱,但我無法在任何地方找到該屬性。
require 'rubygems'
require './jabber/bot'
# Create a public Jabber::Bot
config = {
:jabber_id => '[email protected]',
:password => 'mypassword',
:master => '[email protected]',
:presence => :chat,
}
bot = Jabber::Bot.new(config)
# Give your bot a private command, 'rand'
bot.add_command(
:syntax => 'rand',
:description => 'Produce a random number from 0 to 10',
:regex => /^rand$/
) { rand(10).to_s }
# Bring your new bot to life
bot.connect