Jump to content

Archived

This topic is now archived and is closed to further replies.

coders-irc_Bot

Text Color

Recommended Posts

  • Administrators
 Written by Jonesy44, Download alias structure by "FordLawnmower" & "Imk0tter"
; Version 2.05.0
; First Release: 17th August, 2008
; Updated: 8nd August, 2010
; MDX.dll found at: http://wfs.myartsonline.com/downloads/mdx.dll
menu * {
  Text Colors $chr(9) /colors:colors
}
menu channel {
  $ChannelCheck($chan):ChannelCheck
}
alias ChannelCheck {
  if $isid {
    if !%colors.chans { return }
    elseif %colors.chans == 1 {
      if $findtok(%colors.chans.list,$+($network,?,#),44) { set %colors.cmd remove $+($network,?,#) | return Blacklist # colors on $network }
      else { set %colors.cmd add $+($network,?,#) | return Whitelist # colors on $network }
    }
    elseif %colors.chans == 2 {
      if $findtok(%colors.chans.list,$+($network,?,#),44) { set %colors.cmd remove $+($network,?,#) | return Allow # colors on $network }
      else { set %colors.cmd add $+($network,?,#) | return Disallow # colors on $network }
    }
  }
  else {
    echo -a %colors.cmd
    tokenize 32 %colors.cmd
    if $$1 == add { set %colors.chans.list $+(%colors.chans.list,$chr(44),$$2) }
    elseif $$1 == remove { set %colors.chans.list $remtok(%colors.chans.list,$$2,0,44) }
    if $left(%colors.chans.list,1) == $chr(44) { set %colors.chans.list $right(%colors.chans.list,-1) }
    unset %colors.cmd
  }
}
alias Colors {
  if $MDX == -1 { 
    if $input(To use this script you need MDX.dll - Do you want to download it now?,yq,Download MDX?) == $true { GetMDX }
  }
  else { dialog $iif($dialog(colors),-v,-m) Colors Colors }
}
alias MDX { return $iif($isfile($qt(MDX.dll)),$shortfn($qt(MDX.dll)),-1) }
alias ColorsSecondary return $gettok(%colors.sel,2,44)
dialog Colors {
  title "Color Selector [©J44]"
  size -1 -1 100 70
  option dbu
  radio "All text colored", 100, 3 2 54 10
  radio "First letters", 101, 3 12 54 10
  radio "None", 102, 3 22 54 10
  box "", 103, 60 -10 2 45
  box "", 104, 0 31 100 5
  check "Bold", 105, 3 36 54 9
  check "Underline", 106, 3 44 54 9
  box "", 107, 0 50 100 5
  text "Color Code", 200, 65 2 30 9, center
  edit %colors.sel, 201, 65 11 30 10
  text "", 202, 65 23 30 7, center
  button "Set", 300, 2 56 58 13
  button "Cancel", 301, 62 56 36 13
  button "Options", 302, 62 38 36 13
}
on *:Dialog:Colors:*:*: {
  if $devent == init {
    dll $MDX SetMircVersion $version
    dll $MDX MarkDialog $dname
    did -cf colors $iif(!%colors.setting,102,$iif(%colors.setting = 1,100,101))
    did $iif(%colors.bold,-c,-u) Colors 105
    did $iif(%colors.underline,-c,-u) Colors 106
    var %colors = WHITE BLACK D.BLUE D.GREEN RED BROWN PURPLE ORANGE YELLOW L.GREEN S.BLUE L.BLUE D.BLUE PINK D.GREY L.GREY
    did -rae colors 202 $gettok(%colors,$calc($gettok($did(201).text,1,44) +1),32)
    if !$gettok(%colors.sel,2,44) { dll $MDX SetColor 202 text $color($did(201).text) }
    else {
      dll $MDX SetColor 202 text $color($gettok($did(201).text,1,44))
      dll $MDX SetColor 202 background $color($gettok($did(201).text,2,44))
      dll $MDX SetColor 202 textbg $color($gettok($did(201).text,2,44))
    }
    if (!%colors.setting) did -b colors 201,202
  }
  elseif $devent == sclick {
    if $did == 100 {
      did -e colors 201,202,105,106,302
      did $iif($did(201).text isnum 0-15 || ($gettok($did(201).text,1,44) isnum 0-15 && $gettok($did(201).text,2,44) isnum 0-15),-e,-b) colors 300
    }
    elseif $did == 101 {
      did -e colors 201,202,105,106,302
      did $iif($did(201).text isnum 0-15 || ($gettok($did(201).text,1,44) isnum 0-15 && $gettok($did(201).text,2,44) isnum 0-15),-e,-b) colors 300
    }
    elseif $did == 102 {
      did -b colors 201,202,105,106,302
      did -e colors 300
    }
    elseif $did == 105 { set %colors.bold $iif($did(105).state,1,0) }
    elseif $did == 106 { set %colors.underline $iif($did(106).state,1,0) }
    elseif $did == 300 {
      $iif($did(102).state,unset,set) %colors.setting $iif($did(100).state,1,2)
      if $did(100).state || $did(101).state { set %colors.sel $did(201).text }
      dialog -x colors
    }
    elseif $did == 301 { dialog -x colors }
    elseif $did == 302 { dialog $iif($dialog(ColorsOptions),-v,-m ColorsOptions) ColorsOptions }
  }
  elseif $devent == edit {
    if $did == 201 {
      var %colors = WHITE BLACK D.BLUE D.GREEN RED BROWN PURPLE ORANGE YELLOW L.GREEN S.BLUE L.BLUE D.BLUE PINK D.GREY L.GREY
      if !$regex($did(201).text,$chr(44)) {
        did $iif($did(201).text isnum 0-15,-e,-b) colors 300
        did $iif($did(201).text isnum 0-15,-rae,-rb) colors 202 $gettok(%colors,$calc($did(201).text +1),32)
        dll $MDX SetColor 202 text $color($did(201).text)
        dll $MDX SetColor 202 background reset
        dll $MDX SetColor 202 textbg reset
      }
      else {
        if $gettok($did(201).text,1,44) isnum 0-15 && $gettok($did(201).text,2,44) isnum 0-15 {
          did -e colors 300
          did -rae colors 202 $gettok(%colors,$calc($gettok($did(201).text,1,44) +1),32)
          dll $MDX SetColor 202 text $color($gettok($did(201).text,1,44))
          dll $MDX SetColor 202 background $color($gettok($did(201).text,2,44))
          dll $MDX SetColor 202 textbg $color($gettok($did(201).text,2,44))
        }
        else {
          did -b colors 300
          did -rb colors 202
        }
      }
    }
  }
}
dialog ColorsOptions {
  title "Colors Options [©J44]"
  size -1 -1 100 60
  option dbu
  radio "Allow these channels", 101, 3 2 70 10
  radio "Disallow these channels", 102, 3 12 70 10
  radio "Allow all channels", 103, 3 22 70 10
  edit "", 201, 3 33 94 10
  button "Done", 301, 2 45 58 13
  button "?", 302, 62 45 36 13
}
on *:Dialog:ColorsOptions:*:*: {
  if $devent = init {
    did -ra ColorsOptions 201 %colors.chans.list
    if !%colors.chans { did -c ColorsOptions 103 | did -b ColorsOptions 201 }
    elseif %colors.chans == 1 { did -c ColorsOptions 101 }
    elseif %colors.chans == 2 { did -c ColorsOptions 102 }
  }
  elseif $devent = sclick {
    if $did isnum 101-103 {
      if $did == 101 { set %colors.chans 1 | did -e ColorsOptions 201 }
      elseif $did == 102 { set %colors.chans 2 | did -e ColorsOptions 201 }
      else { set %colors.chans 0 | did -b ColorsOptions 201 }
    }
    elseif $did == 301 {
      if $calc($count($did(201).text,$chr(35)) -1) > $count($did(201).text,$chr(44)) {
        if $input(You have specified more channels than comma spaces. If you're sure it's correct press "Yes'". Else you can edit by pressing "No" $crlf $crlf $+ $&
          Each channel must be seperated by a comma. Eg. $+(#123,$chr(44),#xyz,$chr(44),#nmo),yq) == $false {
          halt
        }
      }
      else { 
        %colors.chans.list = $did(201).text
        dialog -x ColorsOptions
      }
    }
    elseif $did == 302 {
      var %msg = Some channels have more strict rules for the text formatting that is used. $&
        Some don't allow colors / bold / underline / backgrounds or a mixture of all of those. $crlf $crlf $+ $&
        In this case select either only the channels you want to use the colored text on or the channels you don't want the colored text to appear on. $crlf $crlf $+ $&
        For the channels use a COMMA to seperate values. 'EzzyChat?#lobby' for server specific or '#lobby' for non-specific $crlf $crlf $+ $&
        Current network is: $network
      noop $input(%msg,io,Information)
    }
  }
}
on *:INPUT:*: {
  if (!$regex($1,/^\//)) && (c !isincs $chan($chan).mode) {
    if %colors.setting {
      var %allow = 0
      if (!%colors.chans) { %allow = 1 }
      else {
        if $findtok(%colors.chans.list,$chan,44) { var %found = 1 }
        elseif $findtok(%colors.chans.list,$+($network,?,$chan),44) { var %found = 1 }
        if %colors.chans == 1 { var %allow = $iif(%found == 1,1,0) }
        elseif %colors.chans == 2 { var %allow = $iif(%found == 1,0,1) }
      }
    }
    if %colors.setting == 1 && %allow = 1 {
      msg $active $+($iif(%colors.bold,),$iif(%colors.underline,),,$base($gettok(%colors.sel,1,44),10,10,2),$iif($regex(%colors.sel,$chr(44)),$chr(44),),$base($gettok(%colors.sel,2,44),10,10,2),$$1-)
      ;enter a custom regex here if you like
      ;if you still want to use the allow/disallow functions
      ;but not only simple coloring.
      halt
    }
    elseif %colors.setting == 2 && %allow = 1 {
      ;first letter of words only msg
      var %txtColored = $regsubex($$1-,/\W(.)/giS,$+($chr(32),,$base($gettok(%colors.sel,1,44),10,10,2),\t,))
      msg $active $+($iif(%colors.bold,),$iif(%colors.underline,),%txtColored)
      halt
    }
  }
}
; Download the MDX.dll file. 
alias GetMDX {
  noop $input(MDX.dll is now downloading. The color selector will open when the download completes. Please wait,io,MDX.dll)
  if ($isfile($qt(MDX.dll))) .remove $qt(MDX.dll)
  sockopen GetMDX wfs.myartsonline.com 80
  sockmark GetMDX $1-
}
on *:sockopen:GetMDX:{
  sockwrite -nt $sockname GET /downloads/mdx.dll HTTP/1.0
  sockwrite -n $sockname Host: wfs.myartsonline.com $+ $crlf $+ $crlf
}
on *:sockread:GetMDX:{
  sockread &GetMDX
  bwrite MDX.dll.tmp -1 -1 &GetMDX
}
on *:sockclose:GetMDX: {
  var %x 1
  bread MDX.dll.tmp 0 $file(MDX.dll.tmp).size &buff
  while ($bvar(&buff,%x,4) != 13 10 13 10) inc %x
  inc %x 4
  bcopy &buffer 1 &buff %x -1
  bwrite MDX.dll -1 -1 &buffer
  .remove MDX.dll.tmp
  Colors
}

 

m_34120_ZWexD19QNMcksd0SJGzniscM9.png

Link to comment
Share on other sites



×
×
  • Create New...