SHARE
TWEET

Untitled

a guest Aug 12th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. gchat = {
  2. --This determines where things go, obviously. this is safely changeable.
  3. channelmap = {
  4. clt = "Clans",
  5. gnt = "Guild",
  6. gt = "Guild",
  7. gts = "Guild",
  8. cgt = "Org",
  9. ft = "Clans",
  10. ct = "Org",
  11. newbie = "Misc",
  12. market = "Misc",
  13. says = "Says",
  14. tell = "Tells",
  15. shout = "Says",
  16. oto = "Org",
  17. ot = "Org",
  18. oti = "Org"
  19. },
  20. --If true, won't move says from talkers not recognized by NDB into tabbed chat (only effects says, so it won't
  21. --hide things like calls for help.
  22. gagdenizen = true
  23. ,
  24.  
  25. --Everything past here is no longer configs!! Don't change this stuff or you'll probably break things.
  26.  
  27. crossChat = function(event,text)
  28.     if demonnic.chat.config.timestamp then gchat.timestamp(demonnic.chat.config.Alltab) end
  29.     demonnic.chat:decho(demonnic.chat.config.Alltab,text)
  30. end
  31. ,
  32. ansindb = function(text)
  33.     local text = ansi2decho(text)
  34.     color = string.match(text,"^<?r?>?<%d+,%d+,%d+:%d-,?%d-,?%d->")
  35.     local background = color:match(":.->") or ":>"
  36.     local highlighted = {}
  37.     for _, name in pairs(ndb.findnames(text)or {}) do
  38.         if not table.contains(lighted,name) then
  39.             if ndb.getcolor(name)~="" then
  40.                 text = text:gsub(name,string.format("<r><%d,%d,%d",unpack(color_table[string.sub(ndb.getcolor(name),2,-2)]))..background..name..color)
  41.             end
  42.             table.insert(highlighted,name)
  43.         end
  44.     end
  45.     return text
  46. end
  47. ,
  48. gmcpchat = function()
  49.     if gchat.gagdenizen and not ndb.findname(gmcp.Comm.Channel.Text.talker) and gmcp.Comm.Channel.Text.channel == "says" then return end
  50.     if gmcp.Comm.Channel.Text.channel:sub(1,4) =="tell" then gmcp.Comm.Channel.Text.channel = "tell" end
  51.     local chat = gchat.channelmap[gmcp.Comm.Channel.Text.channel:gsub("[0-9]","")] or demonnic.chat.config.Alltab
  52. --  local temptext = gchat.stripAnsi(gmcp.Comm.Channel.Text.text).."\n"
  53.     if demonnic.chat.config.timestamp then gchat.timestamp(chat) end
  54.     demonnic.chat:decho(chat,gchat.ansindb(gmcp.Comm.Channel.Text.text).."\n")
  55.     raiseGlobalEvent("crossChat",gchat.ansindb(gmcp.Comm.Channel.Text.text).."\n")
  56. end,
  57.  
  58. opencomms = function()
  59.     sendGMCP('Core.Supports.Add ["Comm.Channel 1"]')
  60. end,
  61.  
  62. timestamp = function(chat) --Bit of code pulled from YATCO itself for timestamping. Credits go to original author.
  63.     local timestamp = getTime(true, demonnic.chat.config.timestamp)
  64.     local tsfg = {}
  65.     local tsbg = {}
  66.     local colorLeader = ""
  67.     if demonnic.chat.config.timestampCustomColor then
  68.       if type(demonnic.chat.config.timestampFG) == "string" then
  69.         tsfg = color_table[demonnic.chat.config.timestampFG]
  70.       else
  71.         tsfg = demonnic.chat.config.timestampFG
  72.       end
  73.       if type(demonnic.chat.config.timestampBG) == "string" then
  74.         tsbg = color_table[demonnic.chat.config.timestampBG]
  75.       else
  76.         tsbg = demonnic.chat.config.timestampBG
  77.       end
  78.       colorLeader = string.format("<%s,%s,%s:%s,%s,%s>",tsfg[1],tsfg[2],tsfg[3],tsbg[1],tsbg[2],tsbg[3])
  79.    
  80.     local fullstamp = string.format("%s%s",colorLeader,timestamp)
  81.       demonnic.chat.windows[chat]:decho(fullstamp)
  82.       demonnic.chat.windows[chat]:echo(" ")
  83.       if demonnic.chat.config.Alltab and chat~=demonnic.chat.config.Alltab then
  84.         demonnic.chat.windows[demonnic.chat.config.Alltab]:decho(fullstamp)
  85.         demonnic.chat.windows[demonnic.chat.config.Alltab]:echo(" ")
  86.       end
  87.     else
  88.        demonnic.chat.windows[chat]:cecho(format..timestamp)
  89.       demonnic.chat.windows[chat]:echo(" ")
  90.       if demonnic.chat.config.Alltab then
  91.         demonnic.chat.windows[demonnic.chat.config.Alltab]:cecho(format..timestamp)
  92.         demonnic.chat.windows[demonnic.chat.config.Alltab]:echo(" ")
  93.         end
  94.     end
  95. end,
  96.  
  97. }
  98. registerAnonymousEventHandler("gmcp.Comm.Channel.Text","gchat.gmcpchat")
  99. registerAnonymousEventHandler("gmcp.Char.Name","gchat.opencomms")
  100. registerAnonymousEventHandler("crossChat","gchat.crossChat")
RAW Paste Data
Top