[FrontPage] [TitleIndex] [WordIndex]

dAmn

dAmn/Clients

About

For mIRC, written by IceShaman, second major version.

Woul write here but I'd rather code it than brag about it

Instructions

1) Do not download the source code, instead download the .zip file from the downloads section below.

2) extract the damn folder from the zip to the mIRC directory (all the files are in that folder).

3) In mIRC type in: /load -rs dAmn\dAmn.mrc

4) In mIRC type in /dsettings and fill out the dialog.

5) When you have filled out the options, entered your username and password *and* updated your token, type in /damn.

Commands

/join - dAmn & channel windows

/me or /action - channel windows

*you may use all the deviantart shortcode ie :lol: ... :thumbnail######:*

(to exit a channel, simple right click on the window and select close)

Source Code


;~~~~~~~~~~~~~~~~~~~~;
;dAmIRC - mIRC dAmn  ;
;Version: 0.3        ;
;By IceShaman        ;
;~~~~~~~~~~~~~~~~~~~~;

;#################;a
;# Status Window #;
;#################;

on *:INPUT:@damn: { 
  if ($left($1,1) == /) || ($left($1,1) == $readini(mirc.ini,text,commandchar)) {
    var %command = $right($1,-1)
    if (%command == damn) || (%command == connect) { damn-connect damn }
    elseif (%command == join) || (%command == j) { djoin $2- }
    elseif (%command == part) || (%command == p) { dpart $2- }
    elseif (%command == raw) { draw $2- }
    elseif (%command == raw) { draw $2- }
    elseif (%command == clear) { clear @damn }
    else { halt }
  }
}

on *:CLOSE:@damn: { 
  sockclose damn 
  var %damnchans = $window(@#*,0), %done = 0
  if ((!%damnchans) && ($hget(damn))) { hfree damn }
  while (%done < %damnchans) {
    inc %done
    .signal DAMN-CLOSE-CHAN $window(@#*,%done) EXIT
    close -@ $window(@#*,%done)
  }
}

alias -l damn-status { 
  if ($window(@damn)) { echo @damn $$1- }
}

;###########;
;# Cleanup #;
;###########;

on *:start: { var %x = $findfile(dlls,*.dll,0,damn-cleanup $1-) }
on *:exit: { var %x = $findfile(dlls,*.dll,0,damn-cleanup $1-) }

alias -l damn-cleanup { .dll -u " $+ $$1- $+ " | .remove " $+ $$1- $+ " }

;##############;
;# Connection #;
;##############;

alias damn {
  if (!$hget(damn)) { hmake damn 50 }
  if (!$window(@damn)) { window -aez @damn | var %x = $findfile(dlls,*.dll,0,damn-cleanup $1-) }
  if (!$sock(damn)) { damn-connect damn }
}

alias damn-connect {
  if (!$damn-readsetting(user,username)) { damn-status Please set a username first using /dsettings. } 
  elseif (!$damn-readsetting(user,auth)) { damn-status Cannot find auth code, please get one by using /dsettings. }
  sockopen damn chat.deviantart.com 3900
}

on *:sockopen:damn: { 
  damn-status $status-prefix Connecting...
  damn-packet dAmnClient 0.2\nagent=dAmIRC v0.3\n\0login $damn-readsetting(user,username) $+ \npk= $+ $damn-readsetting(user,auth) $+ \n\0 
}

;reads and groups data using null packets as a delimeter
;also provides support for large messages and topics/titles
on *:sockread:damn: {
  if ($sockerr > 0) { damn-status Error...Die... | return }
  :damn-read
  sockread -f &data
  breplace &data 0 2
  if ($sockbr == 0) {
    while ($bfind(&senddata,1,2) > 0) {
      var %x = $hget(damn,longdata,&longdata)
      if ($bvar(&longdata,0)) {
        bcopy -c &longdata $calc($bvar(&longdata,0) + 1) &senddata 1 -1
        if ($bfind(&longdata,1,10) < 1) { return } 
        hadd -bm damn longdata &longdata 
        if (!$bvar(&senddata,0)) { bunset &longdata }
        else {
          while ($bfind(&longdata,1,2)) {
            if (($gettok($bvar(&longdata,1,100).text,2,10) == p=members) && ($bvar(&longdata,$calc($bvar(&longdata,0) - 1),1) != 0) && ($bvar(&tempdata,0))) {           
              bcopy -c &tempdata 1 &longdata $calc($bfind(&longdata,1,2) + 1) -1
              bcopy -c &longdata 1 &longdata 1 $calc($bfind(&longdata,1,2) -1)
              bcopy -c &longdata $calc($bvar(&longdata,0) + 1) &tempdata 1 -1
              hadd -bm damn longdata &longdata
              damn-parsedata $bvar(&longdata,1,200).text
              bcopy -c &longdata 1 &tempdata 1 -1 | bunset &tempdata 
              continue 
            }
            bcopy -c &tempdata 1 &longdata $calc($bfind(&longdata,1,2) + 1) -1
            bcopy -c &longdata 1 &longdata 1 $calc($bfind(&longdata,1,2) -1)
            hadd -bm damn longdata &longdata
            damn-parsedata $bvar(&longdata,1,800).text
            if (!$bvar(&tempdata,0)) { bunset &longdata | bunset &tempdata | break }
            else { bcopy -c &longdata 1 &tempdata 1 -1 | bunset &tempdata }
          }
        }
        return
      }
      else { 
        if ($bfind(&senddata,1,2) > 400) { hadd -bm damn longdata &senddata | bunset &senddata | bset &senddata 1 2 | goto damn-read }
        else { damn-parsedata $bvar(&senddata,1,$bfind(&senddata,1,2)).text }
      }
      if ($calc($bfind(&senddata,1,2) + 1) < $bvar(&senddata,0)) { bcopy -c &senddata 1 &senddata $calc($bfind(&senddata,1,2) + 1) -1 }
      else { bunset &senddata | break }
    }
    if ($bvar(&senddata,0)) { 
      if ($bvar(&senddata,$calc($bvar(&senddata,0) - 1),1) == 10) { damn-parsedata $bvar(&senddata,1,$bvar(&senddata,0)).text }
      else { 
        var %x = $hget(damn,longdata,&longdata)
        bcopy -c &longdata $calc($bvar(&longdata,0) + 1) &senddata 1 -1
        hadd -bm damn longdata &longdata
      }
    }
    return
  }
  while ($bvar(&data,0)) {
    bset &senddata $calc($bvar(&senddata,0) + 1) $bvar(&data,1,200)
    if ($bvar(&data,0) > 200) { bcopy -c &data 1 &data 201 -1 }
    else { bunset &data }
  }
  goto damn-read
}
on *:sockclose:damn: { damn-status $status-prefix Disconnected | hdel -w damn channel:*:topic* | hdel -w damn channel:*:title* }

;converts text with \0 \n \t etc into binary packets and sends them off
alias damn-packet {
  var %packet = $1-
  while ($regex(%packet,(.*?)\\0)) {
    bset -t &packet $calc($bvar(&packet,0) + 1) $replace($regml(1),\n,$chr(10),\t,$chr(9),\/,\)
    bset &packet $calc($bvar(&packet,0) + 1) 0
    %packet = $right(%packet,- $+ $calc($len($regml(1)) + 2))
  }
  if (%packet) { bset -t &packet $calc($bvar(&packet,0) + 1) $replace(%packet,\n,$chr(10),\t,$chr(9)) }
  if ($bvar(&damn-truemsg,0)) {
    bcopy -c &packet $calc($bvar(&packet,0) + 1) &damn-truemsg 1 -1
    bset &packet $calc($bvar(&packet,0) + 1) 0
    bunset &damn-truemsg
  }
  if (!$sock(damn)) { damn-status $status-prefix Error: no connection | return }
  damn-packetsend
  halt
}
alias damn-packetsend { sockwrite damn &packet | halt }

;parses all incoming data
alias -l damn-parsedata {
  echo data: $1-
  var %cmd = $gettok($1-,1,10)
  if ($damn-readsetting(settings,debug)) { 
    if ($remove($1,$chr(10)) != ping) || ($damn-readsetting(settings,pingpong) == 1) { damn-status $1- }
  }
  if (%cmd == dAmnServer 0.2) { damn-status $status-prefix Authenticating... }
  elseif ($gettok(%cmd,1,32) == login) { 
    if ($gettok($1-,2,10) == e=ok) { damn-status $status-prefix Connected }
    elseif ($left($gettok($1-,2,10),2) == e=) { damn-status $status-prefix Connection error: $right($gettok($1-,2,10),-2) }
  }  
  elseif (%cmd == ping) { damn-packet pong\n\0 }
  elseif ($gettok(%cmd,1,61) == usericon) {
    var %addnum = 2, %addtotal = $numtok($1-,2)
    while (%addnum < %addtotal) { 
      var %addsetting = $gettok($1-,%addnum,2)
      damn-add user $+ : $+ $damn-read(nick) $+ : $+ $gettok(%addsetting,1,61) $gettok(%addsetting,2-,61)
      inc %addnum
    }
  }
  elseif ($gettok(%cmd,1,32) == join) { 
    var %chan = $gettok($gettok(%cmd,2,32),2,58) 
    if ($gettok($1-,2,10) == e=ok) { damn-makechan %chan }
    else { damn-status $status-prefix $chr(91) $+ $chr(35) $+ %chan $+ $chr(93) $gettok($gettok($1-,2,10),2-,61) }
  } 
  elseif ($gettok(%cmd,1,32) == part) { 
    var %chan = $gettok($gettok(%cmd,2,32),2,58) 
    if ($gettok($1-,2,10) == e=ok) { damn-closechan $chr(35) $+ %chan }
    else { damn-status $status-prefix $chr(91) $+ $chr(35) $+ %chan $+ $chr(93) $gettok($gettok($1-,2,10),2-,61) }
  } 
  elseif ($gettok(%main,1,32) == kicked) {
    ;not implemented as of yet, so sue me
  } 
  elseif ($gettok(%cmd,1,58) == property chat) {
    if ($gettok($1-,2,10) == p=topic) || ($gettok($1-,2,10) == p=title) {
      var %toptit = $right($gettok($1-,2,10),-2)
      var %x = $hget(damn,longdata,&longdata), %chgt = $iif($damn-read(channel $+ : $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit $+ by),edit,new) 
      if (%chgt == new) { damn-addline $window(@ $+ $chr(35) $+ $gettok(%cmd,2,58)).hwnd <null> %chan }      
      if ($bvar(&longdata,0)) { 
        if (($bvar(&longdata,0) < 199) && (($bfind(&longdata,1,2) < 200) || (!$bfind(&longdata,1,2)))) { goto altt }
        var %chop = 5
        while (%chop) { bcopy -c &longdata 1 &longdata $calc($bfind(&longdata,1,10) + 1) -1 | dec %chop }

        hadd -bm damn channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit &longdata
        damn-add channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit $+ by $gettok($gettok($1-,3,10),2,61)
        damn-add channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit $+ ts $gettok($gettok($1-,4,10),2,61)            
        damn-chgt %toptit %chgt $chr(35) $+ $gettok(%cmd,2,58) $gettok($gettok($1-,3,10),2,61) <jt> $checktabs($bvar(&longdata,1,200).text)

        while ($bvar(&longdata,0)) { damn-chgt %toptit more $chr(35) $+ $gettok(%cmd,2,58) $gettok(%cmd,2,58) $gettok($gettok($1-,4,10),2,61) $iif($bvar(&longdata,0) <= 200,<last>) $checktabs($bvar(&longdata,1,200).text) }
        hdel damn longdata
      }
      else { 
        :altt
        damn-add channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit  $remove($gettok($1-,5,10),$chr(2)) 
        damn-add channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit $+ by $gettok($gettok($1-,3,10),2,61)
        damn-add channel: $+ $chr(35) $+ $gettok(%cmd,2,58) $+ : $+ %toptit $+ ts $gettok($gettok($1-,4,10),2,61)       
        damn-chgt %toptit %chgt $chr(35) $+ $gettok(%cmd,2,58) $gettok($gettok($1-,3,10),2,61) $gettok($gettok($1-,4,10),2,61) $remove($gettok($1-,5,10),$chr(2))
      }
    }
    elseif ($gettok($1-,2,10) = p=members) {
      echo HERE
      var %x = $hget(damn,longdata,&longdata) 
      if (!$bvar(&longdata,0)) { bset -t &longdata 1 $gettok($1-,1-,2) }

      var %chan = $chr(35) $+ $gettok($gettok($bvar(&longdata,1,200).text,1,10),2,58), %chop = 3
      while (%chop) { bcopy -c &longdata 1 &longdata $calc($bfind(&longdata,1,10) + 1) -1 | dec %chop }

      while ($bvar(&longdata,0)) {
        echo HMMMMMMMMMMMM: $bvar(&longdata,1,500).text
        if ($bvar(&longdata,1,1) == 2) { bunset &longdata | break }
        elseif ($bvar(&longdata,1,9).text == typename=) { bunset &longdata | break } 
        var %line = $gettok($bvar(&longdata,1,200).text,1-7,10), %chop = 8

        while (%chop) { 
          if ($bvar(&longdata,0) <= 1) || ($bfind(&longdata,1,10) == $bfind(&longdata,$calc($bfind(&longdata,1,10) + 1),10)) { bunset &longdata | break }  
          echo of course: $bvar(&longdata,1,500).text :: $bvar(&longdata,$bvar(&longdata,0),1)
          bcopy -c &longdata 1 &longdata $calc($bfind(&longdata,1,10) + 1) -1
          dec %chop 
        } 
        var %name = $gettok($gettok(%line,1,10),2,32), %line = $gettok(%line,2-,10)
        if (%line) { var %addtrue = true }
        while (%line) {
          damn-add user: $+ %name $+ : $+ $gettok($gettok(%line,1,10),1,61) $gettok($gettok(%line,1,10),2-,61)
          %line = $gettok(%line,2-,10)
        }
        if (%addtrue) { echo added user %name | damn-adduser %chan %name | var %addtrue }
      }
      hdel damn longdata
    }
    elseif ($gettok($1-,2,10) = p=privclasses) {
      var %toadd = $gettok($1-,3-,10)
      while ((%toadd) && (%toadd != $chr(2))) {
        damn-add stats: $+ $gettok($gettok(%toadd,1,10),2,58) $gettok($gettok(%toadd,1,10),1,58)
        %toadd = $gettok(%toadd,2-,10)
      }
    }
  }
  elseif ($gettok(%cmd,1,58) == recv chat) {
    if ($regex($gettok($gettok($1-,2,10),1,32),/^(join|part)$/i)) { damn- $+ $iif($regml(1) == join,adduser,deluser) $chr(35) $+ $gettok(%cmd,2,58) $gettok($gettok($1-,2,10),2-,32) $iif($regml(1) == join,noburst) $+ $iif(($regml(1) != join) && ($left($gettok($3-,2,10),2) == r=),$right($gettok($3-,2,10),-2)) }  
    elseif ($regex($gettok($1-,2,10),/^(msg|action) main$/i)) {
      var %x = $hget(damn,longdata,&longdata), %msgact = $regml(1)
      if (!$bvar(&longdata,0)) { bset -t &longdata 1 $gettok($1-,1-,2) }

      var %chan = $chr(35) $+ $gettok($gettok($bvar(&longdata,1,200).text,1,10),2,58), %from = $gettok($gettok($bvar(&longdata,1,200).text,3,10),2,61), %chop = 5
      while (%chop) { bcopy -c &longdata 1 &longdata $calc($bfind(&longdata,1,10) + 1) -1 | dec %chop }

      var %msg = $damn-parsemsg($checktabs($bvar(&longdata,1,200).text))
      damn-addline $window(@ $+ %chan).hwnd $iif(%msgact == msg,$iif(%from == $damn-readsetting(user,username),&lt;<font color="brown"> $+ %from $+ </font>&gt;,&lt; $+ %from $+ &gt;),<font color="purple">* %from) %msg 

      while ($bvar(&longdata,0)) {
        %msg = $damn-parsemsg($checktabs($bvar(&longdata,1,200).text))
        damn-addline $window(@ $+ %chan).hwnd <custom> %msg
      }
      hdel damn longdata
    }
    if ($gettok($gettok($1-,2,10),1,32) == privchg) { damn-privchg $chr(35) $+ $gettok(%cmd,2,58) $gettok($gettok($1-,2,10),2,32) $right($gettok($1-,3,10),-3) $right($gettok($1-,4,10),-3) }
  }
  else { hdel damn longdata }
}

;cleans up socket data ready for next data session
alias damn-cleanup { bunset &senddata | bunset &longdata | hdel damn longdata }

;recoded message parses to find 'tablumps' and special characters etc and render them in the channel window
;thanks to bzed for some help with the logic behind this ^_^
alias damn-parsemsg {
  var %text = $replacex($1-,<,&lt;,>,&gt;,&b $+ $chr(9),<b>,&/b $+ $chr(9),</b>,&u $+ $chr(9),<u>,&/u $+ $chr(9),</u>,&i $+ $chr(9),<i>,&/i $+ $chr(9),</i>, $& 
    &ul $+ $chr(9),<ul>,&/ul $+ $chr(9),</ul>,&li $+ $chr(9),<li>,&/li $+ $chr(9),</li>,&s $+ $chr(9),<strike>,&/s $+ $chr(9),</strike>,&sub $+ $chr(9),<sub>, $& 
    &/sub $+ $chr(9),</sub>,&sup $+ $chr(9),<sup>,&/sup $+ $chr(9),</sup>,&sup $+ $chr(9),<sup>,&/sup $+ $chr(9),</sup>,&code $+ $chr(9),<code>,&/code $+ $chr(9),</code>, $&
    &/a $+ $chr(9),</a>,&br $+ $chr(9),<br>,&/acro $+ $chr(9),</acronym>) 

  while ($regex(tablumps,%text,(.*?)&((?:[^\t\&]+\t+)+|(?:\t)))) {
    var %line = $regml(tablumps,2)
    if ($gettok(%line,1,9) == nbsp;) { var %skip = 2 | var %tempsay = &nbsp; } 
    elseif ($gettok(%line,1,9) == emote) { var %skip = 7 | var %tempsay = <acronym title=" $+ $gettok(%line,5,9) $+ "> $+ $iif($damn-readsetting(settings,smilies) == 1,<img src=" $+ http://e.deviantart.com/emoticons/ $+ $iif($chr(47) isin $gettok(%line,6,9),$gettok(%line,6,9),0.gif) $+ ">,$gettok($gettok(%line,5,9),1,32))</acronym> }
    elseif ($gettok(%line,1,9) == iframe) { var %skip = 6 | var %tempsay = <acronym title=" $+ $gettok(%line,2,9) $+ "><a href=" $+ $gettok(%line,2,9) $+ ">[iframe]</a></acronym> }
    elseif ($gettok(%line,1,9) == link) { var %skip = 5 | var %tempsay = <a target="_blank" href=" $+ $gettok(%line,2,9) $+ "> $+ $iif($gettok(%line,3,9),$ifmatch,[link]) $+ </a> }
    elseif ($gettok(%line,1,9) == a) { var %skip = 3 | var %tempsay = <a target="_blank" href=" $+ $gettok(%text,2,9) $+ "> }
    elseif ($gettok(%line,1,9) == img) { var %skip = 3 | var %tempsay = $iif($damn-readsetting(settings,images) == 1,<img src=" $+ $gettok(%line,2,9) $+ " alt=" $+ $gettok(%line,2,9) $+ ">,<a href=" $+ $gettok(%line,2,9) $+ ">[image]</a>) }
    elseif ($gettok(%line,1,9) == avatar) { var %skip = 4 | var %tempsay = <acronym title=" $+ $gettok(%line,2,9) $+ "><a target="_blank" href="http:// $+ $gettok(%line,2,9) $+ .deviantart.com"><img src=" $+ $iif($gettok(%line,3,9) == 0,http://a.deviantart.com/avatars/default.gif,http://a.deviantart.com/avatars/ $+ $left($gettok(%line,2,9),1) $+ / $+ $mid($gettok(%line,2,9),2,1) $+ / $+ $gettok(%line,2,9) $+ $replace($gettok(%line,3,9),1,.gif,2,.jpg,3,.png)) $+ "></a></acronym> }
    elseif ($gettok(%line,1,9) == dev) { var %skip = 4 | var %tempsay = <acronym title="http:// $+ $gettok(%line,3,9) $+ .deviantart.com"><a target="_blank" href="http:// $+ $gettok(%line,3,9) $+ .deviantart.com"> $+ $gettok(%line,2,9) $+ $gettok(%line,3,9) $+ </a></acronym> }
    elseif ($gettok(%line,1,9) == thumb) { 
      var %skip = 9
      if ($damn-readsetting(settings,thumbnails) != 1) { var %tempsay = <acronym title=" $+ $gettok(%phrase,3,9) by $gettok(%phrase,4,9) $+ $chr(44) $gettok(%phrase,5,9) $+ "><a target="_blank" href="http://t $+ $iif($gettok(%phrase,6,9) != 3,n $+ $ifmatch,$ifmatch) $+ .deviantart.com/100/ $+ %urlrep $+ ">[thumnbnail]</a></acronym> }
      else {  
        if ($gettok(%line,5,9) == 0x0) { var %tempsay = <acronym title=" $+ $gettok(%line,3,9) by $gettok(%line,4,9) $+ $chr(44) $gettok(%line,5,9) $+ "><a target="_blank" href="http://www.deviantart.com/view/ $+ $gettok(%line,2,9) $+ ">[picture (no thumbnail)]</a></acronym> }
        if ($left($gettok(%line,7,9),2) == fs) { var %x = $regsub($gettok(%line,7,9),^(fs[0-9]):, \1.deviantart.com/, %fsurl1) | var %fsurl = %fsurl1 | unset %fsurl1 }
        else { }
        if ($gettok($gettok(%line,5,9),1,120) < 100) { var %tempsay = <acronym title=" $+ $gettok(%line,3,9) by $gettok(%line,4,9) $+ $chr(44) $gettok(%line,5,9) $+ "><a target="_blank" href="http://www.deviantart.com/view/ $+ $gettok(%line,2,9) $+ "><img src="http:// $+ %fsurl $+ "></a></acronym> }
        else { var %tempsay = <acronym title=" $+ $gettok(%line,3,9) by $gettok(%line,4,9) $+ $chr(44) $gettok(%line,5,9) $+ "><a target="_blank" href="http://www.deviantart.com/view/ $+ $gettok(%line,2,9) $+ "><img src="http:// $+ $iif($gettok(%line,6,9) == 3,t3,tn $+ $ifmatch) $+ .deviantart.com/100/ $+ %fsurl $+ "></a></acronym> }
      }
    }
    var %say = %say $+ $regml(tablumps,1) $+ %tempsay, %text = $gettok(%text,%skip $+ -,9) $+ $chr(9), %skip
  }
  var %say = %say $+ %text
  return $damn-colourparse($remove(%say,$chr(9),$chr(2)))
}

;checks messages for broken tablumps so chunked data can be sent to addline
alias -l checktabs {
  var %text = $1-, %last = $pos(%text,$chr(38),$count(%text,$chr(38))), %tablump = $mid(%text,%last,999)
  if (!$count($left(%tablump,25),$chr(9))) || ($left(%tablump,4) == &amp) { var %tabnum = 0 }
  elseif ($left(%tablump,6) == &emote) { var %tabnum = 6 }
  elseif ($left(%tablump,7) == &iframe) { var %tabnum = 5 }
  elseif ($left(%tablump,5) == &link) || ($left(%tablump,7) == &avatar) || ($left(%tablump,4) == &dev) { var %tabnum = 3 }
  elseif ($left(%tablump,2) == &a) || ($left(%tablump,4) == &img) { var %tabnum = 4 }
  elseif ($left(%tablump,6) == &thumb) { var %tabnum = 8 }
  if ($bvar(&longdata,0) > 200) { bcopy -c &longdata 1 &longdata 201 -1 }
  else { bunset &longdata }  
  if (($count(%tablump,$chr(9)) < %tabnum) && ($left(%tablump,2) != $chr(38) $+ $chr(9))) {
    ;prepend the tablump to &longdata for reparsing
    bset -t &longdata2 1 %tablump 
    bcopy &longdata $calc($bvar(&longdata2,0) + 1) &longdata 1 -1
    bcopy &longdata 1 &longdata2 1 -1
    var %text = $left(%text,$calc(%last -1))
    bunset &longdata2
  }
  return %text
}

;###########;
;# Channel #;
;###########;

alias damn-makechan {
  var %chan = $chr(35) $+ $1-
  if (!$window(@ $+ %chan)) {
    damn-add channel: $+ %chan $+ :status online
    window -k0Sl12emRvz @ $+ %chan 
    damn-add channel $+ : $+ %chan $+ :id $window(@ $+ %chan).hwnd
    if (!$exists(" $+ $scriptdir $+ dlls $+ ")) { mkdir " $+ $scriptdir $+ dlls $+ " }
    .copy -o " $+ $scriptdir $+ smilesview.dll $+ " " $+ $scriptdir $+ dlls\smiley- $+ $window(@ $+ %chan).hwnd $+ .dll $+ "
    .dll " $+ $scriptdir $+ dlls\smiley- $+ $window(@ $+ %chan).hwnd $+ .dll $+ " attach $window(@ $+ %chan).hwnd
    .dll " $+ $scriptdir $+ dlls\smiley- $+ $window(@ $+ %chan).hwnd $+ .dll $+ " navigate about:blank
  }
  else { dline -l @ $+ %chan 1- }
  damn-addline $window(@ $+ %chan).hwnd <font color="green">*** Now talking in %chan
}

on *:INPUT:$(@#* $+ ): { 
  if (($left($1,1) != $chr(47)) && ($left($1,1) != $readini(mirc.ini,text,commandchar))) || ($ctrlenter) || ($left($1,3) == /me) || ($left($1,7) == /action) {  
    if ($right($1,-1) == me) || ($right($1,-1) == action) { var %msgact = action }
    else { var %msgact = msg }
    if ($len($iif(%msgact == msg,$$1-,$$2-) > 200)) {
      var %done = 201
      bset -t &damn-msg 1 $left($iif(%msgact == msg,$$1-,$$2-),200)
      while (%done < $len($iif(%msgact == msg,$$1-,$$2-))) { bset -t &damn-msg %done $mid($iif(%msgact == msg,$$1-,$$2-),%done,200) | var %done = $calc(%done + 201) }
    }
    else { bset -t &damn-msg 1 $iif(%msgact == msg,$$1-,$$2-) }
    damn-messagesend %msgact $right($target,-2) 
  }
  else {
    var %command = $right($1,-1)
    if (%command == join) || (%command == j) { djoin $2- }
    elseif (%command == part) || (%command == p) { dpart $iif($2,$2-,$right($target,-1)) }
    elseif (%command == hop) || (%command == cycle) { var %chan = $right($active,-1) | dhop $iif($2,$2-,$right($target,-1)) } 
    elseif (%command == promote) || (%command == demote) { dpriv $right($target,-1) %command $2- }
    elseif (%command == topic) { dtopic $right($target,-1) $2- }
    elseif (%command == clear) { .dll " $+ $scriptdir $+ dlls\smiley- $+ $window($target).hwnd $+ .dll $+ " navigate about:blank } 
    else { halt }
  }
}

on *:CLOSE:$(@#* $+ ): { damn-closechan $right($target,-1) | dpart $right($target,-1) }
on *:SIGNAL:DAMN-CLOSE-CHAN: { damn-closechan $1- }

alias damn-closechan {
  var %winid = $damn-read(channel: $+ $$1 $+ :id)
  if ((!$damn-read(dhop)) && ($exists(" $+ $scriptdir $+ dlls\ $+ smiley- $+ %winid $+ .dll $+ "))) { 
    .dll -u " $+ $scriptdir $+ dlls\ $+ smiley- $+ %winid $+ .dll $+ "
    .remove " $+ $scriptdir $+ dlls\ $+ smiley- $+ %winid $+ .dll $+ "
    if ($window(@ $+ $$1)) { window -c @ $+ $$1 }
  }
  elseif ($damn-read(dhop)) { hdel damn dhop }
  if ($damn-read(channel: $+ $$1 $+ :status)) { hdel -w damn channel: $+ $$1 $+ :* | damn-add channel: $+ $$1 $+ :status online }
  elseif (($2 == EXIT) && $hget(damn)) { hfree damn }
}

alias damn-addline { 
  var %cmd = dll " $+ $scriptdir $+ dlls\smiley- $+ $$1 $+ .dll $+ " writeln <basefont color="black" size=2 face=Tahoma Border=5>
  var %highlight = <span style="background-color: lightgrey">, %nohighlight = <span style="background-color: white">
  if ($2 == <custom>) { var %prefix = $damn-colourparse($$2-) | tokenize 32 $1 $3- }
  else { var %prefix = <br> $+ $damn-colourparse($timestamp $$2-) }
  %cmd = %cmd $+ %nohighlight
  if ($2 == <null>) { %cmd $+ <br> $+ $damn-colourparse($timestamp) $chan-prefix }
  else { %cmd $+ %prefix }
}

alias -l damn-adduser {
  var %status = $damn-read(user: $+ $$2 $+ :pc)
  damn-add user: $+ $$2 $+ :prefix $replace(%status,Guests,$null,Members,+,Helpers,%,Operators,@,Founders,&)
  if ($fline(@ $+ $$1,$iif($damn-read(user: $+ $$2 $+ :prefix),?,$null) $+ $$2,1,1)) || ($fline(@ $+ $$1,$iif($damn-read(user: $+ $$2 $+ :prefix),?,$null) $+ $$2 $+ $chr(91) $+ ? $+ $chr(93),1,1)) { var %line = $ifmatch }
  if ($line(@ $+ $$1,%line,1)) {
    var %name = $ifmatch
    if (($chr(91) isin $right(%name,3)) && ($chr(93) isin $right(%name,3))) { var %clones = $calc($remove($right(%name,3),$chr(91),$chr(93)) + 1) }
    else { var %clones = 2 }
  }
  if (($3 == noburst) && ($damn-readsetting(settings,joinpart))) { damn-addline $window(@ $+ $$1).hwnd <font color="green">*** $$2 has joined $$1 $iif(%clones,<b>Clones</b>: %clones) }
  $iif(%clones,rline -l @ $+ $$1 %line,aline -l @ $+ $$1) $damn-read(user: $+ $$2 $+ :prefix) $+ $$2 $+ $iif(%clones,$chr(91) $+ %clones $+ $chr(93),$null)
  window -S @ $+ $$1
}

alias -l damn-deluser { 
  if ($damn-readsetting(settings,joinpart)) { damn-addline $window(@ $+ $$1).hwnd <font color="green">*** $$2 has left $$1 $iif($3,$chr(40) $+ $3- $+ $chr(41)) $+ </font> }
  if ($fline(@ $+ $$1,$iif($damn-read(user: $+ $$2 $+ :prefix),?,$null) $+ $$2 $+ $chr(91) $+ ? $+ $chr(93),1,1)) { 
    var %line = $ifmatch
    var %clones = $iif($calc($remove($line(@ $+ $$1,$ifmatch,1),$$2,$chr(91),$chr(93)) - 1) == 1,0,$ifmatch)
    rline -l @ $+ $$1 %line $damn-read(user: $+ $$2 $+ :prefix) $+ $$2 $+ $iif(%clones,$chr(91) $+ %clones $+ $chr(93),$null)
  }
  else { dline -l @ $+ $$1 $fline(@ $+ $$1,$iif($damn-read(user: $+ $$2 $+ :prefix),?,$null) $+ $$2,1,1) | hdel -w damn user: $+ $$2 $+ :* }
  window -S @ $+ $$1
}

alias -l damn-privchg {
  if ($damn-readsetting(settings,userstatus)) { damn-addline $window(@ $+ $$1).hwnd <b>* $+ $$2 has been made a member of <u> $+ $$4 $+ </u> by $$3 $+ *</b> }
  else { var %modes = $iif($fline(@ $+ $$1,/ $+ $$2 $+ (\[[0-9]+\]|)$/i,0,3),$replace($hget(damn,user: $+ $$2 $+ :pc),founders,-a,operators,-o,helpers,-h,members,-v,banned,-b,guests,$null),$iif($$4 == guests,-aov)) $+ $replace($$4,founders,+a,operators,+o,helpers,+h,members,+v,banned,+b,guests,$null) | damn-addline $window(@ $+ $$1).hwnd <font color="green"> *** $$3 sets mode: %modes $iif(- isin %modes && + isin %modes,$$2 $$2,$$2) }
  if ($fline(@ $+ $$1,$iif($hget(damn,user: $+ $$2 $+ :prefix),?,$null) $+ $$2,1,1)) || ($fline(@ $+ $$1,$iif($hget(damn,user: $+ $$2 $+ :prefix),?,$null) $+ $$2 $+ $chr(91) $+ * $+ $chr(93),1,1)) { var %line = $ifmatch }
  if ($line(@ $+ $$1,%line,1)) {
    var %name = $ifmatch
    if ($hget(damn,user: $+ $$2 $+ :prefix)) { var %name = $right(%name,-1) }
    damn-add user: $+ $$2 $+ :pc $$4 | damn-add user: $+ $$2 $+ :prefix $replace($$4,founders,&,operators,@,helpers,%,members,+,guests,$null)
    if ($$4 == banned) { damn-addline $window(@ $+ $$1).hwnd <font color="green">*** $$2 was kicked by $$3 (banned) | dline -l @ $+ $$1 %line }
    else { rline -l @ $+ $$1 %line $replace($$4,founders,&,operators,@,helpers,%,members,+,guests,$null) $+ %name }
  }
}

alias -l damn-chgt {
  if ($2 == new) {
    damn-addline $window(@ $+ $$3).hwnd $chan-prefix($$3) $1 $+ - ' $+ $damn-parsemsg($6-) $+ $iif($5 != <jt>,',$null) 
    if ($5 != <jt>) { damn-addline $window(@ $+ $$3).hwnd $chan-prefix($$3) $1 $+ - set by <b> $+ $$4 $+ </b> ( $+ $asctime($$5,ddd ddoo mmm yyyy hh:mmtt) $+ ) }
  }
  elseif ($2 == edit) { 
    damn-addline $window(@ $+ $$3).hwnd <font color="green">*** $$4 changes topic to ' $+ $damn-parsemsg($6-) $+ $iif($5 != <jt>,',$null) 
    if ($5 == <jt>) { damn-add chgttype edit }
  }
  elseif ($2 == more) { 
    if ($6 == <last>) { 
      damn-addline $window(@ $+ $$3).hwnd <custom> <nohighlight> <font color=" $+ $iif($damn-read(chgttype) == edit,green $+ "> $damn-parsemsg($$7-) $+ ',darkblue $+ "> $+ $damn-parsemsg($$7-) $+ ')
      if ($damn-read(chgttype) != edit) { damn-addline $window(@ $+ $$3).hwnd <nohighlight> $chan-prefix($$3) $1 $+ - set by <b> $+ $$4 $+ </b> $chr(40) $+ $asctime($$5,ddd ddoo mmm yyyy hh:mmtt) $+ $chr(41) }
      hdel damn chgttype
    }
    else { damn-addline $window(@ $+ $$3).hwnd <custom> <nohighlight> <font color=" $+ $iif($damn-read(chgttype) == edit,green,darkblue) $+ "> $+ $damn-parsemsg($$6-) }
  }
}

;parsed mesage before sending (parses mIRC details like bold and underline into dAmn equivalents)
alias -l damn-messagesend {
  while ($bvar(&damn-msg,0)) {
    if ($bvar(&damn-msg,1,1) == 2) {
      if (!%bold-num) { var %bold-num = 1 }
      else { var %bold-num }
      bset -t &damn-truemsg $calc($bvar(&damn-truemsg,0) + 1) $chr(60) $+ $iif(!%bold-num,/,$null) $+ b $+ $chr(62)
    }
    elseif ($bvar(&damn-msg,1,1) == 31) {
      if (!%under-num) { var %under-num = 1 }
      else { var %under-num }
      bset -t &damn-truemsg $calc($bvar(&damn-truemsg,0) + 1) $chr(60) $+ $iif(!%under-num,/,$null) $+ u $+ $chr(62)
    }
    elseif ($bvar(&damn-msg,1,1) == 32) { bset &damn-truemsg $calc($bvar(&damn-truemsg,0) + 1) 32 }
    elseif ($bvar(&damn-msg,1,1) == 92) { bset -t &damn-truemsg $calc($bvar(&damn-truemsg,0) + 1) \/ } 
    else { bset &damn-truemsg $calc($bvar(&damn-truemsg,0) + 1) $bvar(&damn-msg,1,1) }
    if ($bvar(&damn-msg,0) > 1) { bcopy -c &damn-msg 1 &damn-msg 2 -1 }
    else { bunset &damn-msg }
  }
  damn-packet send chat: $+ $$2 $+ \n\n $+ $1 main $+ \n\n
}

alias djoin {
  var %chan = $damn-chanparse($1)
  damn-packet join chat: $+ %chan $+ \n\0
}

alias dpart {
  var %chan = $damn-chanparse($1)
  damn-packet part chat: $+ %chan $+ \n\0
}

alias dhop {
  var %chan = $damn-chanparse($1)
  .timer 1 1 damn-packet join chat: $+ %chan $+ \n\0
  damn-addline $window(@# $+ %chan).hwnd <font color="darkblue">* Attempting to rejoin channel $chr(35) $+ %chan
  damn-add dhop true  
  damn-packet part chat: $+ %chan $+ \n\0
}

alias dpriv {  
  var %chan = $damn-chanparse($1)
  damn-packet send chat: $+ %chan $+ \n\n $+ $2 $3 $+ \n $+ $iif($4,pc= $+ $4 $+ \n\0,\0)
}

alias dtopic {
  var %chan = $damn-chanparse($1)
  if ($2) { damn-packet set chat: $+ %chan $+ \n $+ p=topic $+ \n\n $+ $2- $+ \0 }
  elseif ($damn-read(channel: $+ $chr(35) $+ %chan $+ :topicby)) {
    damn-addline $window(@ $+ $chr(35) $+ %chan).hwnd <null> %chan
    damn-addline $window(@ $+ $chr(35) $+ %chan).hwnd $chan-prefix(%chan) Requesting topic...
    var %x = $hget(damn,channel: $+ $chr(35) $+ %chan $+ :topic,&longdata)

    if ($bvar(&longdata,0) <= 200) { damn-chgtopic new $chr(35) $+ %chan $damn-read(channel: $+ $chr(35) $+ %chan $+ :topicby) $damn-read(channel: $+ $chr(35) $+ %chan $+ :topicts) $checktabs($bvar(&longdata,1,200).text) | damn-addline $window(@ $+ $chr(35) $+ %chan).hwnd <null> }
    else { damn-chgtopic new $chr(35) $+ %chan $damn-read(channel: $+ $chr(35) $+ %chan $+ :topicby) <jtopic> $checktabs($bvar(&longdata,1,200).text) }

    while ($bvar(&longdata,0)) { damn-chgtopic more $chr(35) $+ %chan $damn-read(channel: $+ $chr(35) $+ %chan $+ :topicby) $damn-read(channel: $+ $chr(35) $+ %chan $+ :topicts) $iif($bvar(&longdata,0) <= 200,<last>) $checktabs($bvar(&longdata,1,200).text) }
  } 
  else { damn-addline $window(@ $+ $chr(35) $+ %chan).hwnd $chan-prefix(%chan) No topic... }
  halt
}

;see the readme
alias draw { damn-packet $1- }

;#########;
;# Menus #;
;#########;

menu @#* {
  Kick { }
  Ban { }
  whois { 
    var %nicks = $sline($active,0), %done = 0
    while (%done < %nicks) { inc %done | damn-whois $sline($active,%done) }
  }
}

;#############;
;# Functions #;
;#############;

alias -l damn-add { hadd -m damn $$1 $2- }
alias -l damn-read { return $hget(damn,$$1-) }
alias -l damn-addsetting { if ($$1) { writeini " $+ $scriptdir $+ \damn.ini $+ " $1- } }
alias -l damn-readsetting { return $replace($readini(" $+ $scriptdir $+ \damn.ini $+ ",$$1,$$2),<null>,$null) }
alias -l damn-chanparse { return $iif($left($1,1) == $chr(35),$iif($left($1,2) == $chr(35) $+ $chr(35),$1,$right($1,-1)),$1) }
alias -l damn-num2colour { return $replace($$1-,10,cyan,11,lightcyan,12,lightblue,13,pink,14,grey,15,lightgrey,0,white,1,black,2,darkblue,3,green,4,red,5,brown,6,purple,7,orange,8,yellow,9,lightgreen) }
alias -l status-prefix { return $timestamp 12•2•1•2 }
alias -l chan-prefix { return <font color="lightblue">• <font color="darkblue">• <font color="black">• <font color="darkblue"> $iif($1,$+ $chr(91) $+ <font color="black"> $+ $iif($left($1,1) != $chr(35),$chr(35) $+ $$1,$$1) $+ <font color="darkblue"> $+ $chr(93)) }

alias damn-colourparse { 
  var %damn-colours, %x = $regsub($$1-,(.*) $+ $chr(3) $+ (.*)? $+ $chr(44) $+ (?(1)([0-9]+))(.*),\1 $+ $damn-colourreg $+ \4,%damn-colours) 
  return %damn-colours
}

alias -l damn-colourreg {
  var %done = 2
  while (%done < 4) {
    if ($left($regml(%done),2) isnum) || ($left($regml(%done),1) isnum) { 
      var %say = %say $+ $iif(%done < 3,<font color=",<body bgcolor=") $+ $damn-num2colour($left($regml(%done),$iif($left($regml(%done),2) isnum,2,1))) $+ "> $+ $right($regml(%done),- $+ $iif($len($regml(%done)) > 2,2,0)) 
      if ((%done < 3) && ($len($regml(%done)) > 2)) { var %say = %say $+ $chr(44) $+ $regml(3) | break }
    }
    else { var %say = %say $regml(%done) }
    inc %done
  }
  return %say
}

;###########;
;# Dialogs #;
;###########;

alias dsettings { dialog -dm damn damn }

dialog damn {
  title "dAmIRC v0.3 by IceShaman"
  size -1 -1 190 99
  option dbu
  box "Authorization", 1, 2 3 99 50
  edit "", 2, 37 13 59 10
  text "Username:", 3, 6 14 28 8
  text "Password:", 4, 6 26 28 8
  edit "", 5, 37 25 58 10, pass
  button "Update", 6, 32 37 37 12
  box "Settings", 23, 103 3 85 50
  check "Show joins/parts", 24, 107 10 77 10
  check "Enable highlighting", 26, 107 20 56 10
  check "Debug mode", 27, 107 30 50 10
  check "Show ping/pong", 28, 107 40 50 10
  button "", 3000, 0 0 0 0, hide ok
  button "Ok", 36, 69 85 37 12, ok
  button "Cancel", 37, 151 85 37 12, cancel
  button "Apply", 38, 110 85 37 12
  box "Whois", 7, 2 54 99 29
  radio "mIRC style whois window", 8, 6 62 91 10, group
  radio "Open userinfo page in browser", 9, 6 71 91 10
  box "Promotion/Demotion", 10, 103 54 85 29
  radio "Use mIRC style changes", 11, 107 62 78 10, group
  radio "Use dAmn style changes", 12, 107 71 78 10
}

dialog damn-getauth {
  title "Auth Code Retriever v0.1"
  size -1 -1 139 63
  option dbu
  edit "", 1, 18 33 101 10, read limit 32
  edit "", 2, 3 3 133 25, read multi return
  button "Close", 3, 48 47 37 12, ok
}

on *:dialog:damn:init:*: {
  did -a $dname 2 $damn-readsetting(user,username) 
  did -a $dname 5 $damn-readsetting(user,password) 
  did $iif($damn-readsetting(settings,joinpart) == 1,-c,-u) $dname 24
  did $iif($damn-readsetting(settings,highlighting) == 1,-c,-u) $dname 26
  did $iif($damn-readsetting(settings,debug) == 1,-c,-u) $dname 27
  did $iif($damn-readsetting(settings,pingpong) == 1,-c,-u) $dname 28
  did -c $dname $iif($damn-readsetting(settings,whois) == 1,9,8)
  did -c $dname $iif($damn-readsetting(settings,userstatus) == 1,12,11)
}


on *:dialog:damn:sclick:36,38: {
  damn-addsetting user username $iif($did($dname,2).text,$ifmatch,<null>)
  damn-addsetting user password $iif($did($dname,5).text,$ifmatch,<null>)
  damn-addsetting settings joinpart $did($dname,24).state
  damn-addsetting settings highlighting $did($dname,26).state
  damn-addsetting settings debug $did($dname,27).state
  damn-addsetting settings pingpong $did($dname,28).state
  damn-addsetting settings whois $did($dname,9).state
  damn-addsetting settings userstatus $did($dname,12).state
}

on *:dialog:damn:sclick:6: { 
  damn-addsetting user username $iif($did($dname,2).text,$ifmatch,<null>)
  damn-addsetting user password $iif($did($dname,5).text,$ifmatch,<null>)
  damn-getauth 
}

;#######################;
;# Auth Code Retriever #;
;#######################;

alias damn-getauth { 
  sockopen damn_getauth www.deviantart.com 80 
  dialog -am damn-getauth damn-getauth
}

alias -l damn-getauth_send { 
  if ($dialog(damn-getauth)) { did -i damn-getauth 2 $did(damn-getauth,2).lines $$1- | did -f damn-getauth 2 } 
  else { sockclose damn_getauth | return }
}

alias -l damn-gotauth { 
  if ($dialog(damn-getauth)) {
    did -a damn-getauth 1 $$1 
    damn-addsetting user auth $$1 
    damn-getauth_send Retrieved authcode, socket closed.
  } 
}

on *:sockopen:damn_getauth: {
  damn-getauth_send Contacting server...
  if ($sockerr > 0) { damn-status Error: unable to contact server }
  var %post = username= $+ $damn-readsetting(user,username) $+ & $+ password= $+ $damn-readsetting(user,password) $+ & $+ reusetoken=1
  sockwrite -tn $sockname POST /users/login HTTP/0.9
  sockwrite -tn $sockname Host: www.deviantart.com
  sockwrite -tn $sockname User-Agent: dAmIRC/0.3
  sockwrite -tn $sockname Accept: text/html
  sockwrite -tn $sockname Cookie: skipintro=1
  sockwrite -tn $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -tn $sockname Content-Length: $len(%post)
  sockwrite -tn $sockname
  sockwrite -tn $sockname %post
  damn-getauth_send Sending data...
}

on *:sockread:damn_getauth: {
  if ($sockerr > 0) { damn-getauth_send An error has occured. }
  var %damn-authdata
  sockread %damn-authdata
  if (authtoken isin %damn-authdata) { damn-gotauth $left($right($gettok(%damn-authdata,1,59),41),32) | sockclose $sockname }
  elseif (http://www.deviantart.com/users/wrong-password isin %damn-authdata) { damn-getauth_send Wrong password. | sockclose $sockname }
}

on *:sockclose:damn-getauth: { damn-getauth_send Socket closed by server. }

;EOF

Downloads

Screenshots


2013-03-28 12:59