Compare commits

...

2 Commits

Author SHA1 Message Date
4e469cb12c Improved server nickname validation 2022-03-23 23:04:03 -05:00
4e0b013a93 Don't log server updates, way to verbose 2022-03-23 21:34:24 -05:00
3 changed files with 32 additions and 4 deletions

View File

@@ -106,7 +106,6 @@ class W3DHub
logger.debug(LOG_TAG) { "Waiting for data..." } logger.debug(LOG_TAG) { "Waiting for data..." }
while (message = connection.read) while (message = connection.read)
logger.debug(LOG_TAG) { "Sending \"PING\"(?)" } if message.first[:type] == 6
connection.write({ type: 6 }) if message.first[:type] == 6 connection.write({ type: 6 }) if message.first[:type] == 6
if message&.first&.fetch(:type) == 1 if message&.first&.fetch(:type) == 1
@@ -117,7 +116,6 @@ class W3DHub
server = Store.server_list.find { |s| s.id == id } server = Store.server_list.find { |s| s.id == id }
server_updated = server&.update(data) server_updated = server&.update(data)
States::Interface.instance&.update_server_browser(server) if server_updated States::Interface.instance&.update_server_browser(server) if server_updated
logger.debug(LOG_TAG) { "Updated #{server.status.name}" } if server_updated
end end
end end
end end

View File

@@ -448,7 +448,11 @@ class W3DHub
prefill: Store.settings[:server_list_username], prefill: Store.settings[:server_list_username],
accept_callback: accept_callback, accept_callback: accept_callback,
cancel_callback: cancel_callback, cancel_callback: cancel_callback,
valid_callback: proc { |entry| entry.length.positive? } # See: https://gitlab.com/danpaul88/brenbot/-/blob/master/Source/renlog.pm#L136-175
valid_callback: proc do |entry|
entry.length > 1 && entry.length < 30 && (entry =~ /(:|!|&|%| )/i).nil? &&
(entry =~ /[\001\002\037]/).nil? && (entry =~ /\\/).nil?
end
) )
end end

View File

@@ -30,7 +30,7 @@ class W3DHub
stack(width: 0.5) stack(width: 0.5)
button "Accept", width: 0.25 do @accept_button = button "Accept", width: 0.25 do
if @options[:valid_callback]&.call(@prompt_entry.value) if @options[:valid_callback]&.call(@prompt_entry.value)
pop_state pop_state
@options[:accept_callback]&.call(@prompt_entry.value) @options[:accept_callback]&.call(@prompt_entry.value)
@@ -38,6 +38,32 @@ class W3DHub
end end
end end
end end
@prompt_entry.subscribe(:changed) do
if @options[:valid_callback]
if @options[:valid_callback].call(@prompt_entry.value)
c = W3DHub::THEME[:Button][:border_color]
@prompt_entry.style.border_color = c
@prompt_entry.style.default[:border_color] = c
@prompt_entry.style.hover[:border_color] = c
@prompt_entry.style.active[:border_color] = c
@accept_button.enabled = true
else
c = 0xff_ff0000
@prompt_entry.style.border_color = c
@prompt_entry.style.default[:border_color] = c
@prompt_entry.style.hover[:border_color] = c
@prompt_entry.style.active[:border_color] = c
@accept_button.enabled = false
end
@prompt_entry.set_border_color
end
end
end end
def draw def draw