diff Devian.lua @ 30:42e74b72726d

Prefix auto-color checks for and deals with color levels that are close to white.
author Nenue
date Fri, 25 Dec 2015 13:56:20 -0500
parents 31ca76e04766
children 6fcfe60bbd0f
line wrap: on
line diff
--- a/Devian.lua	Fri Dec 25 03:33:37 2015 -0500
+++ b/Devian.lua	Fri Dec 25 13:56:20 2015 -0500
@@ -346,12 +346,13 @@
   end
 
   local sendq = {}
-  local tag, id
+  local tag, id, tagged
   local byName = true
   if D.tags[prefix] then
     for _, id in pairs(D.tags[prefix]) do
       if D.console[id] then
         sendq[id] = D.console[id]
+        tagged = true
       end
     end
   end
@@ -360,29 +361,20 @@
     sendq[D.sig[prefix].index] = D.sig[prefix]
   elseif D.console[prefix] then
     sendq[D.console[prefix]] = D.console[prefix]
-  else
+  elseif not tagged then
     sendq[D.primary_channel] = D.console[D.primary_channel]
   end
 
   -- color me timbers
   local pcolor
   if (not db.tagcolor[prefix]) and byName then
-    local c  = {0, 0, 0 }
-    local max = string.len(prefix)
-    for i = 1, max, 3 do
-        for k, v in ipairs(c) do
-          local j = i + (k - 1)
-          c[k] = c[k] + (j <= max and string.byte(prefix,j) or 0)
-        end
+    local c = {
+      math.random(64,255), math.random(64,255), math.random(64,255)
+    }
+    if c[1] > 223 and c[2] > 223 and c[3] > 223 then
+      c[math.random(1,3)] = math.random(64,223)
     end
-    for k,v in ipairs(c) do
-      c[k] = c[k] % 255
-      if c[k] < 64 then
-        c[k] = 0
-      elseif c[k] > 127 then
-        c[k] = 255
-      end
-    end
+
     db.tagcolor[prefix] = string.format('%02X%02X%02X', unpack(c))
   end
   pcolor = db.tagcolor[prefix]
@@ -490,11 +482,11 @@
       dbvars = db.channels[i]
       -- use that as our base vars
     else
-      if db.sig[t_info.signature] then
+      if D.sig[t_info.signature] then
         local sigvar = t_info.signature
         local j = 2
         while D.sig[sigvar] do
-          sigvar = signame .. j
+          sigvar = sigvar .. j
           j = j + 1
         end
         t_info.signature = sigvar