Skip to content

Commit 490860d

Browse files
committed
fix #221 and some one more crash
1 parent 8ff0853 commit 490860d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

core/pluginbot.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,13 @@ def handle_user_state_changes(msg)
325325
def handle_text_message(msg)
326326
if msg.actor
327327
msg.username = @cli.users[msg.actor].name
328-
msg.userhash = @cli.users[msg.actor].hash.to_sym
328+
329+
if @cli.users[msg.actor].hash.nil?
330+
msg.userhash = "0"
331+
else
332+
msg.userhash = @cli.users[msg.actor].hash.to_sym
333+
end
334+
329335
msg.user_id = @cli.users[msg.actor].user_id
330336
msg.channel_id = @cli.users[msg.actor].channel_id
331337
# else ignore text messages from the server
@@ -486,7 +492,11 @@ def handle_text_message(msg)
486492

487493
# Test whether the given user exists currently on the server
488494
if @cli.find_user(targetuser_name)
489-
targetuser_hash = @cli.find_user(targetuser_name).hash.to_sym
495+
if @cli.find_user(targetuser_name).hash.nil?
496+
targetuser_hash = "0"
497+
else
498+
targetuser_hash = @cli.find_user(targetuser_name).hash.to_sym
499+
end
490500

491501
Conf.svalue("main:user:banned:#{targetuser_hash}", "#{targetuser_name}")
492502
@cli.text_user(msg.actor, I18n.t("ban.active"))

0 commit comments

Comments
 (0)