试图将@server变量传递给bot对象,但是它不起作用。我是Ruby的新手,不确定在这里我做错了什么。
require 'cinch'
class ConnectIRC
attr_accessor :server, :channel, :nick, :realname
def initialize(server, channel, nick, realname)
@server = server
@channel = channel
@nick = nick
@realname = realname
end
bot = Cinch::Bot.new do
configure do |c|
c.server = @server
end
end
bot.start
end
答案 0 :(得分:1)
您可以这样做
require 'cinch'
class ConnectIRC
attr_accessor :server, :channel, :nick, :realname
def initialize(server, channel, nick, realname)
@server = server
@channel = channel
@nick = nick
@realname = realname
end
end
@irc = ConneectIRC.new(server,channel,nick,realname)
bot = Cinch::Bot.new do
configure do |c|
c.server = @irc.server
end
end
bot.start