Skip to content
Snippets Groups Projects
Commit dac1ee5e authored by Atanamo's avatar Atanamo
Browse files

Fix: Bot died if something was sent before connected

parent 40f13188
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -409,22 +409,25 @@ class SchizoBot
@botChannelList[ircChannelName] = botChannel
@masterChannelList[ircChannelName] = isMasterBot
 
# Join IRC channel
log.info "Joining bot '#{@nickName}' to channel #{ircChannelName} " +
"(As master: #{isMasterBot}, password: #{(ircChannelPassword or '<none>')})..."
joinExpression = ircChannelName
joinExpression += ' ' + ircChannelPassword if ircChannelPassword?
@client.join joinExpression, =>
# Set channel modes
if ircChannelName.indexOf(Config.IRC_NONGAME_CHANNEL_PREFIX) is 0
@_sendModeSettingToIrcChannel(ircChannelName, '+s') # Set to secret
if ircChannelPassword?
@_sendModeSettingToIrcChannel(ircChannelName, '+k', ircChannelPassword) # Set channel password
# Resolve join
joinDeferred.resolve()
# Join IRC channel (after connect)
promise = @getConnectionPromise()
promise = promise.then =>
log.info "Joining bot '#{@nickName}' to channel #{ircChannelName} " +
"(As master: #{isMasterBot}, password: #{(ircChannelPassword or '<none>')})..."
joinExpression = ircChannelName
joinExpression += ' ' + ircChannelPassword if ircChannelPassword?
@client.join joinExpression, =>
# Set channel modes
if ircChannelName.indexOf(Config.IRC_NONGAME_CHANNEL_PREFIX) is 0
@_sendModeSettingToIrcChannel(ircChannelName, '+s') # Set to secret
if ircChannelPassword?
@_sendModeSettingToIrcChannel(ircChannelName, '+k', ircChannelPassword) # Set channel password
# Resolve join
joinDeferred.resolve()
promise.done()
 
return joinDeferred.promise
 
Loading
Loading
@@ -433,10 +436,15 @@ class SchizoBot
ircChannelName = botChannel.getIrcChannelName()
delete @botChannelList[ircChannelName]
delete @masterChannelList[ircChannelName]
# Part from IRC channel
log.info "Removing bot '#{@nickName}' from channel #{ircChannelName}..."
@client.part ircChannelName, Config.BOT_LEAVE_MESSAGE, ->
partDeferred.resolve()
# Part from IRC channel (after connect)
promise = @getConnectionPromise()
promise = promise.then =>
log.info "Removing bot '#{@nickName}' from channel #{ircChannelName}..."
@client.part ircChannelName, Config.BOT_LEAVE_MESSAGE, ->
partDeferred.resolve()
promise.done()
return partDeferred.promise
 
handleWebChannelMasterNomination: (botChannel) ->
Loading
Loading
@@ -447,7 +455,10 @@ class SchizoBot
handleWebClientMessage: (channelName, senderIdentity, rawMessage) ->
clientNick = senderIdentity.getName()
messageText = "<#{clientNick}>: #{rawMessage}"
@client.say(channelName, messageText)
# Post to IRC, if client is connected
@client.say(channelName, messageText) unless @getConnectionPromise().isPending()
# Mirror to web channel, if no other bot (the master) is triggering the message though observing
@_sendMessageToWebChannel(channelName, @nickName, messageText) if @_isChannelMaster(channelName)
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment