[FrontPage] [TitleIndex] [WordIndex]

you will need to set %danickname, %pk and %channel

#relay on
alias curdamnchan {
  return @ $+ %damnchannel
}
alias damn {
  ;;;PREPARING VARS AND STUFF
  {
    window -c @damn
    ;;;CACHERESET
    damn-cachereset
    ;;;CHANNEL INFO RESET
    %damnchannel = damn
    ;;;CLOSE SOCKET
    sockclose damn
  }
  ;;;PREPARING INFO
  {
    window -e @damn @damn
    ;;window -el10S @damn @damn
    font @damn 12 tahoma
    sockopen damn chat.deviantart.com 3900
    echo @damn 4Initializing chat.deviantart.com:3900
    window -a @damn @damn
  }
}
on *:sockopen:damn:{
  if ($sockerr) { aline -a Error! | return }
  echo @damn 4Connection initialized
  ;;; HANDSHAKE
  damn-packet dAmnClient 0.2\nagent=relaybot\n\0login %danickname $+ \npk= $+ %pk $+ \n\0
  echo @damn 4Sending handshake
  ;;; LOGIN INFO
  echo @damn 4Sending login info ( $+ %danickname$+ : $+ %pk + )
}
on *:sockclose:damn:{
  ;write -c damndump.txt
  ;write -c damnlist.txt
  ;write -c damndump.ini
  echo @damn 4damn socket got closed.
}
alias setpk {
  %pk = $?="Pk?"
}
alias damncode {
  unset %dec
  bset &nul 1 0
  %dec = $replace($1-,\n,$chr(10),\t,$chr(09))
  return %dec
}
on *:sockread:damn:{
  ;On stock l'information dans la variable %a (qui est une variable global)
  :damnread
  sockread -f %a
  if (%a = property c) { %a = property chat:devart }
  if (%a = hat:devart) { %a = property chat:devart }
  %ba = %a $+ %b
  if ($sockbr == 0) { return }
  if (%a != $null) {
    ;echo @damn RECV: %a
    write -a damndump.txt %a
    write -a damndumpbinary &a
    parsetextformat %a
    parseicon %a
    parsedev %a
    parsethumb %a
    parseurl %a
    parseurl2 %a
    parseurl3 %a
    parsesmileys %a
    %a = $remove(%a,    )
    %a = $remove(%a,&/a)
    ;echo @damn PARSED: %a
    %a = $replace(%a,¤and¤,$chr(38))
    damnparse %a

  }
  goto damnread

}
alias parsetextformat {
  %a = $1-
  %a = $replace(%a,&b   ,)
  %a = $replace(%a,&/b  ,)
  %a = $replace(%a,&u   ,)
  %a = $replace(%a,&/u  ,)
  %a = $replace(%a,Ø,$chr(248))
  %a = $replace(%a,å,$chr(229))
  %a = $replace(%a,&,¤and¤)
  %a = $replace(%a,<,$chr(60))
  %a = $replace(%a,>,$chr(62))
  %a = $replace(%a,&i   ,")
  %a = $replace(%a,&/i  ,")
  %a = $remove(%a,&a;)
  %a = $remove(%a,&/a;)
  %a = $remove(%a,/a;)
  %a = $remove(%a,&code )
  %a = $remove(%a,&/code        )
  %a = $replace(%a,",")
}
alias parsethumb {
  %a = $1-
  %count = 1
  if ($chr(38) $+ thumb !isin %a) { goto thumb-skip } 
  :thumb-redo 
  inc %count
  if (%count == 40) { goto thumb-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&thumb) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),8))
  %data = %rep
  %filter = &thumb $+ $chr(9) $+ £thumbnumber£ $+ $chr(9) $+ £thumbname£ $+ $chr(9) $+ £thumbusername£ $+ $chr(9) $+ £resolution£ $+ $chr(9) $+ £unknown£ $+ $chr(9) $+ £thumburl£ $+ $chr(9) $+ £stats£ $+ $chr(9) 
  parse
  %a = $replace(%a,%rep,$chr(91) $+ THUMB: %thumbname %resolution by %thumbusername - http://www.deviantart.com/view/ $+ %thumbnumber $+ $chr(93))
  if ($chr(38) $+ thumb isin %a) { goto thumb-redo }
  :thumb-skip
}
alias parseicon {
  %a = $1-
  %count = 1
  if ($chr(38) $+ avatar !isin %a) { goto avatar-skip } 
  :avatar-redo 
  inc %count
  if (%count == 40) { goto avatar-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&avatar) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),3))
  %data = %rep
  %filter = &avatar $+ $chr(9) $+ £username£ $+ $chr(9) $+ £number£ $+ $chr(9)
  parse
  %a = $replace(%a,%rep,$chr(91) $+ Avatar $readini(damndump.ini,%username,symbol) $+ %username $+ : http://a.deviantart.com/avatars/ $+ $left(%username,1) $+ / $+ $right($left(%username,2),1) $+ / $+ %username $+ .gif $+ $chr(93))
  if ($chr(38) $+ avatar isin %a) { goto avatar-redo }
  :avatar-skip
  %lastavatar = http://a.deviantart.com/avatars/ $+ $left(%username,1) $+ / $+ $right($left(%username,2),1) $+ / $+ %username $+ .gif
}
alias parsedev {
  %a = $1-
  %count = 1
  if ($chr(38) $+ dev !isin %a) { goto dev-skip } 
  :dev-redo 
  inc %count
  if (%count == 40) { goto dev-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&dev) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),3))
  %data = %rep
  %filter = &dev $+ $chr(9) $+ £symbol£ $+ $chr(9) $+ £username£ $+ $chr(9)
  parse
  %a = $replace(%a,%rep,$chr(91) $+ %symbol $+ %username $+ : http:// $+ %username $+ .deviantart.com $+ $chr(93))
  if ($chr(38) $+ a isin %a) { goto dev-redo }
  :dev-skip
}
alias parseurl {
  %a = $1-
  %b = %a
  %a = %b
  %count = 1
  if ($chr(38) $+ a !isin %a) { goto link-skip } 
  :link-redo 
  inc %count
  if (%count == 40) { goto link-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&a) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),4))
  %data = %rep
  %filter = &a $+ $chr(9) $+ £link£ $+ $chr(9) $+ $chr(9) $+ £linkname£&/a      
  parse
  %a = $replace(%a,%rep,$chr(91) $+ %linkname $+ : %link $+ $chr(93))
  if ($chr(38) $+ a isin %a) { goto link-redo }
  :link-skip
}
alias parseurl2 {
  %a = $1-
  if ($chr(38) $+ link !isin %a) { goto url-skip }
  :url-redo
  inc %count
  if (%count == 40) { goto url-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&link) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),4))
  %data = %rep
  %filter = &link $+ $chr(9) $+ £link£ $+ $chr(9) $+ £linkname£ $+ $chr(9) $+ & $+ $chr(9)
  parse
  %a = $replace(%a,%rep,$chr(91) $+ %linkname $+ : %link $+ $chr(93))
  if ($chr(38) $+ a isin %a) { goto url-redo }
  :url-skip
}
alias parseurl3 {
  %a = $1-
  if ($chr(38) $+ link !isin %a) { goto url-skip }
  :url-redo
  inc %count
  if (%count == 40) { goto url-skip }
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&link) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),3))
  %data = %rep
  %filter = &link $+ $chr(9) $+ £link£ $+ $chr(9) $+ & $+ $chr(9)
  parse
  %a = $replace(%a,%rep,$chr(91) $+ link $+ : %link $+ $chr(93))
  if ($chr(38) $+ a isin %a) { goto url-redo }
  :url-skip
}
alias damnparse {
  if ($gettok($1-,1,58) = property chat) %damnchannel = $gettok($1-,2,58)
  if ($gettok($1-,1,58) == recv chat) {
    %recvchat = $gettok($1-,2,58)
  }
  if ($1 == part) && (chat: !isin $2) { 
    msg $chr(35) $+ %recvchat $2 has left %recvchat $+ .
    echo @damn- $+ %recvchat $timestamp 3* $2 has left $chr(35) $+ %recvchat
    dline -l @damn- $+ %recvchat $fline(@damn- $+ %recvchat,$2,1,1)     
  }
  if ($1 == part) && (chat: isin $2) {
    echo @damn 4You have parted $chr(35) $+ $gettok($1-,2,58)
  }
  ;;;Messages 
  if ($1- == msg main) {
    %msg = on
  }
  if (%msg = on) {
    if (%msg-from != $null) && (%msg-from !isin %daignored) {
      {
        if ($1 = !dacomment) {
          if ($3 != $null) {
            dacomment $2 %msg-from $3- 
            damnmsg %recvchat %msg-from $+ : Comment added to queue
          }
          else { amnmsg %recvchat %msg-from $+ : Correct syntax: !dacomment deviationnumber comment here }
        }
        if ($1 = !danote) {
          if ($numtok($2-,124) >= 3) {
            danote $gettok($2-,1,124) $+ $chr(124) $+ %msg-from $+ $chr(124) $+ $gettok($2-,2,124) $+ $chr(124) $+ $gettok($2-,3,124) 
            damnmsg %recvchat %msg-from $+ : Message added to queue
          }
          else { damnmsg %recvchat %msg-from $+ : Correct syntax: !danote recipient|subject|message }
        }
        if (!note == $1) {
          %a = $writenote($2,%msg-from,$3-)
          if (%a == error) { damnmsg %recvchat %msg-from $+ : There was an error while writing the note. Please make sure you provided enough parameters }
          if (%a == done) { damnmsg %recvchat %msg-from $+ : Your note for: $2 was written successfully. }
          unset %a
        }
        if (?note == $1) {
          if ($2 == $null) {
            unset %a
            %a = $checknote(%msg-from)
            if (%a != $null) { damnmsg %recvchat %msg-from $+ : You have %a notes. Use ?note <number> to read them. }
            if (%a == $null) { damnmsg %recvchat %msg-from $+ : You don't have any notes. }
            unset %a
          }
          if ($2 != $Null) {
            if ($2 != -e) {
              %a = $checknote(%msg-from,$2)
              %sender = $gettok(%a,1,32)
              %ago = $duration($calc($ctime - $gettok(%a,2,32)))
              %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
              unset %a
              damnmsg %recvchat %msg-from $+ : Note from %sender $+ , %ago ago. ( $+ %msg $+ )
              unset %sender
              unset %ago
              unset %msg
            }
            if ($2 == -e) {
              if ($3 == all) {
                %b = $checknote(%msg-from)
                %a = $erasenote(%msg-from,all)
                damnmsg %recvchat %msg-from $+ : All notes were erased ( $+ %b notes $+ )
                unset %b
                unset %a
              }
              if ($3 != all) {
                %a = $checknote(%msg-from,$3)
                %sender = $gettok(%a,1,32)
                %ago = $duration($calc($ctime - $gettok(%a,2,32)))
                %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
                unset %a
                %a = $erasenote(%msg-from,$3)
                damnmsg %recvchat %msg-from $+ : Note from %sender $+ , %ago ago. ( $+ %msg $+ ) (erased)

                unset %sender
                unset %ago
                unset %msg
              }
            }
          }
        }
        if (!list != $1-) && (!note != $1) && (?note != $1) && (%msg-from != %danickname) && (!l != $1) && (!away != $1) msg $chr(35) $+ %recvchat < $+ %msg-from $+ > $1-
        if (!list = $1-) && (%msg-from != %danickname) {
          unset %who
          %a = 1
          :redo
          while (%a <= $nick($chr(35) $+ %recvchat,0)) {
            %who = %who $nick($chr(35) $+ %recvchat,%a).pnick
            inc %a
            goto redo
          }
          %stop = true
          damnmsg %recvchat (list) %who
        }
        if (!away = $1) {
          %away = $readini(lastdamn.ini,%msg-from,away)
          if (%away == $null) {
            if ($2 != $null) {
              writeini lastdamn.ini %msg-from away $2-
              damnmsg %recvchat %msg-from $+ : away message set to: $2-
            }
            if ($2 == $null) {
              writeini lastdamn.ini %msg-from away No message specified
              damnmsg %recvchat %msg-from $+ : away set
            }
          }
          if (%away != $null) {
            remini lastdamn.ini %msg-from away
            damnmsg %recvchat %msg-from $+ : away unset
          }
        }
        if (!away? = $1) {
          %away = $readini(lastdamn.ini,$2,away)
          if (%away == $null) {
            damnmsg %recvchat %msg-from $+ : $2 is currently not away
          }
          if (%away != $null) {
            damnmsg %recvchat %msg-from $+ : $2 is away ( $+ %away $+ )
          }
        }
        if (!whois == $1) {
          damnwhois4 $2 %recvchat
        }
        if ($1 == !google) {
          if ($2 != $null) {
            set %google3 $chr(35) $+ %recvchat
            googlesearch google3 $2-
          }
          if ($2 == $null) {
            msg $chr(35) $+ %recvchat %msg-from $+ : Please provide a research using the !google command
            damnmsg %recvchat %msg-from $+ : Please provide a research using the !google command
          }
        }
        if (!list != $1) && (%msg-from != %danickname) && (!l = $1) && (!whois != $1) {
          %time = $gettok($readini(lastdamn.ini,$2,lastline),2,32)
          %type = $gettok($readini(lastdamn.ini,$2,lastline),1,32)
          %msg = $gettoK($readini(lastdamn.ini,$2,lastline),3- $+ $numtok($readini(lastdamn.ini,$2,lastline),32),32)
          if (%type = msg) {
            damnmsg %recvchat Last message from: $2 $duration($calc($ctime - %time)) ago ( $+ - $+ $2 $+ - %msg $+ )
          }
          if (%type = action) {
            damnmsg %recvchat Last action from: $2 $duration($calc($ctime - %time)) ago ( $+ - $+ $2 $+ - %msg $+ )
          }
          if (%type == $null) {
            damnmsg %recvchat No last message/action recorded from $2
          }
        }
        writeini lastdamn.ini %msg-from lastline msg $ctime $1-
      }
      if (%msg-from !isin %daignored) {
        if (%msg-from isin $1-) echo @damn- $+ %recvchat $timestamp 4< $+ %msg-from $+ > $1-
        if (%msg-from !isin $1-) && (%msg-from !isin %dawatched) echo @damn- $+ %recvchat $timestamp < $+ %msg-from $+ > $1-
        if (%msg-from isin %dawatched) && (%msg-from !isin $1-) {
          echo @damn- $+ %recvchat $timestamp 12< $+ %msg-from $+ > $1-
        }
      }
      unset %msg
      unset %msg-from
    }
    if ($left($1-,5) = from=) {
      %msg-from = $gettok($1,2,61)
    }

  }
  ;;;Actions
  if ($1- == action main) {
    %action = on
  }
  if (%action = on) {
    if (%action-from != $null) {
      if (%action-from != %danickname) echo @damn- $+ %recvchat $timestamp 6* %action-from $1-
      msg $chr(35) $+ %recvchat * $+ %action-from $1-
      writeini lastdamn.ini %action-from lastline action $ctime $1-
      unset %action
      unset %action-from
    }
    if ($left($1-,5) = from=) {
      %action-from = $gettok($1,2,61)
    }

  }
  ;;;PING
  if ($1 == ping) {
    bset &null 1 0
    sockwrite damn pong $+ $chr(10)
    sockwrite damn &null
    ;echo @damn 4PING? PONG!
  }
  ;;;DAMNSERVER
  if ($1- == damnserver 0.1) {
    echo @damn 4Received handshake from the server
  }
  ;;;LOGIN xxxxxx
  if ($1- == login %danickname) {
    echo @damn 4Received login confirmation
    %login = true
  }
  ;;;JOING CHAT
  if ($1- = join chat: $+ %damnchannel) {
    echo @damn 4Received joinning confirmation
    %joinning = true
  }
  ;;;Errors
  ;;;;;E=
  if ($left($1,2) == e=) {
    ;;LOGIN ERRORS
    if (%login = true) {
      if ($1 == e=ok) {
        echo @damn 4Login successfull
        damnjoin %channel
        join $chr(35) $+ %channel
        unset %login
      }
      if ($1- == e=authentication failed) {
        echo @damn 4Login failed (Wrong username/pk, update your info using /authtoken)
        sockclose @damn
        unset %login
      }
    }
    ;;JOIN ERRORS
    if (%joinning = true) {
      if ($1 == e=ok) {
        window -c @damn- $+ %damnchannel
        window -el10S @damn- $+ %damnchannel @damn- $+ %damnchannel
        font @damn- $+ %damnchannel  12 tahoma
        echo @damn- $+ %damnchannel 4Joinning %damnchannel successfull
        unset %joinning
      }
    }
  }
  ;;;JOINS
  if ($1 = join) && (%joinning = $null) && ($gettok($1-,1,58) != join chat) && ($numtok($1-,32) = 2) {
    %j = on
    %j-nick = $2
  }
  if (%j = on)  {
    If ($left($1,2) = pc) {
      writeini damndump.ini %j-nick pc $gettok($1,2,61)
    }
    if ($left($1,8) = usericon) {
      writeini damndump.ini %j-nick usericon $gettok($1,2,61)
    }
    if ($left($1,6) = symbol) {
      if ($gettok($1,2,61) == $chr(35)) { writeini damndump.ini %j-nick symbol $chr(35) | goto 11 }
      writeini damndump.ini %j symbol $gettok($1,2,61)
      :11
      %j-symbol = $gettok($1,2,61)
    }
    if ($left($1,1) = l) {
      if ($gettok($1,2,61) == $chr(35)) { writeini damndump.ini %j-nick symbol $chr(35) | goto 22 }
      if ($readini(damndump.ini,%j-nick,symbol) == $null) writeini damndump.ini %j-nick symbol $replace($gettok($1,2,61),$chr(35),$chr(35))
      :22
      %j-symbol = $gettok($1,2,61)
    }
    if ($left($1,8) = realname) {
      if ($right($1-,$calc($len($1-) - 9)) != $null) writeini damndump.ini %j-nick realname $right($1-,$calc($len($1-) - 9))
    }
    if ($left($1,8) = typename) {
      writeini damndump.ini %j-nick typename $right($1-,$calc($len($1-) - 9))
      ;aline -l @damn- $+ %damnchannel $readini(damndump.ini,%j-nick,symbol) $+ %j-nick
      if (%j-nick != $null) aline -l @damn- $+ %recvchat %j-nick
      msg $chr(35) $+ %recvchat %j-nick just joined %recvchat $+ .
      echo @damn- $+ %recvchat $timestamp 3* %j-nick has joined $chr(35) $+ %recvchat
      unset %a
      %a = $checknote(%j-nick)
      if (%a != $null) { damnmsg %recvchat %j-nick $+ : You have %a notes. Use ?note <number> to read them. }
      unset %a
      unset %j
      unset %j-nick
    }
  }

  ;;;USERS

  if ($1 = member) && ($2 != $null) {
    %member = on
    %member-nick = $2
  }
  if (%member = on)  {
    If ($left($1,2) = pc) {
      writeini damndump.ini %member-nick pc $gettok($1,2,61)
    }
    if ($left($1,8) = usericon) {
      writeini damndump.ini %member-nick usericon $gettok($1,2,61)
    }
    if ($left($1,6) = symbol) {
      if ($gettok($1,2,61) == $chr(35)) { writeini damndump.ini %member-nick symbol $chr(35) | goto 1 }
      writeini damndump.ini %member-nick symbol $gettok($1,2,61)
      :1
      %member-symbol = $gettok($1,2,61)
    }
    if ($left($1,1) = l) {
      if ($gettok($1,2,61) == $chr(35)) { writeini damndump.ini %member-nick symbol $chr(35) | goto 2 }
      if ($readini(damndump.ini,%member-nick,symbol) == $null) writeini damndump.ini %member-nick symbol $replace($gettok($1,2,61),$chr(35),$chr(35))
      :2
      %member-symbol = $gettok($1,2,61)
    }
    if ($left($1,8) = realname) {
      if ($right($1-,$calc($len($1-) - 9)) != $null) writeini damndump.ini %member-nick realname $right($1-,$calc($len($1-) - 9))
    }
    if ($left($1,8) = typename) {
      writeini damndump.ini %member-nick typename $right($1-,$calc($len($1-) - 9))
      ;aline -l @damn- $+ %damnchannel $readini(damndump.ini,%member-nick,symbol) $+ %member-nick
      aline -l @damn- $+ %damnchannel %member-nick
      unset %a
      %a = $checknote(%member-nick)
      if (%a != $null) { damnmsg %recvchat %member-nick $+ : You have %a notes. Use ?note <number> to read them. }
      unset %a
      unset %member
      unset %member-nick
    }
  }

  ;;;PROPERTIES
  if ($left($1,2) == p=) {
    if ($1 = p=title) {
      if (%topic-content == $null) && (%topic-did != on) {
        echo @damn- $+ %damnchannel $timestamp 3* No topic set
        unset %topic
      }
      unset %topic-did
    }
    if ($1 = p=topic) {
      %topic = on
    }
  }
  if (%topic = on) {
    ;;echoes
    if (%topic-writer != $null) && (%topic-ts != $null) {
      set %topic-content $1-
      echo @damn- $+ %damnchannel $timestamp 3* Topic is ' $+ %topic-content $+ '
      echo @damn- $+ %damnchannel $timestamp 3* Set by %topic-writer on %topic-ts
      unset %topic-write
      unset %topic-ts
      unset %topic-content
      unset %topic
      %topic-did = on
    }
    ;;writer
    if ($left($1,3) = by=) {
      %topic-writer = $gettok($1,2,61)
    }
    ;;time
    if ($left($1,3) = ts=) {
      %topic-ts  = $asctime($gettok($1,2,61))
    }
  }
}
on *:connect:msg nickserv identify babelfromrnx
on *:close:@damn:{
  if (%exiting != true) {
    if ($portfree(3900) == $chr(36) $+ false) {
      ;damnexit
      echo -a 4closed damn socket due to window closure
      %conn = false
    }
  }
}
;alias damnexit {
;  if ($portfree(3900) == $chr(36) $+ false) {
;    sockclose damn
;  }
; %exiting = true
; :closeall 
; if ($window(@damn*,1) != $null) {
;   window -c $window(@damn*,1)
;   goto closeall
;  }
;  unset %exiting
;}
on *:close:@damn-*:{
  damnpart $gettok($target,2,45)
}
alias damnjoin { 
  dline -l @damn [1 $+ - $+ $line(@damn,0,1)]
  write -c damndump.txt
  %damnchannel = $remove($1,$chr(35))
  sockwrite damn join chat: $+ %damnchannel
  sockwrite damn $lf
  bset &null 1 0 
  sockwrite damn &null
  echo @damn 4Trying to join %damnchannel
  %conn = true
  halt
  haltdef
}
alias damnpart { 
  /window -c @damn- $+ $1
  write -c damndump.txt
  sockwrite damn part chat: $+ $1
  sockwrite damn $lf
  bset &null 1 0 
  sockwrite damn &null
  echo @damn 4Trying to join $1
  halt
  haltdef
}
alias parsesmileys {
  %a = $1-
  %b = %a
  %a = %b
  if ($chr(38) $+ emote !isin %a) { goto emote-skip }
  :emote-redo  
  %rep = $right(%a,$calc($len(%a) - $pos(%a,&) + 1))
  %rep = $left(%rep,$pos(%rep,$chr(9),6))
  %data = %rep
  %filter = &emote      £emotename£     £emotenumber1£  £emotenumber2£  £emotemeaning£  £emotefile£
  parse
  %a = $replace(%a,%rep,%emotename)
  if ($chr(38) $+ emote isin %a) { goto emote-redo }
  :emote-skip
}
on *:input:@damn*:{
  if (/whois isin $1) {
    damnwhois $2
  }
  if ($1 == /w) {
    damnwhois $2
    hamt
  }
  if (/join isin $1) {
    damnjoin $2
  }
  if (/exit isin $1) {
    damnexit
    halt
  }
  if (/quit isin $1) {
    damnexit
    halt
  }
  if (/part isin $1) {
    damnpart $2
    halt
  }
  if ($1 == /me) {
    damnme $2-
    halt
  }
  if ($1 != me) && (($left($1,1) != /) && ($left($1,1) != $readini(mirc.ini,text,commandchar))) {
    sockwrite damn send chat: $+ $right($active,$calc($len($active) - 6)) $+ $lf $+ $lf $+ msg main $+ $lf $+ $lf $+ $1-
    bset &null 1 0 
    sockwrite damn &null
    halt
  }
}
alias damnmsg {
  sockwrite damn send chat: $+ $1 $+ $lf $+ $lf $+ msg main $+ $lf $+ $lf $+ $2-
  bset &null 1 0 
  sockwrite damn &null
  if (%stop != true) { halt }
}
alias damnme {
  sockwrite damn send chat: $+ $right($active,$calc($len($active) - 6)) $+ $lf $+ $lf $+ action main $+ $lf $+ $lf $+ $1-
  bset &null 1 0 
  sockwrite damn &null
}
alias damnmes {
  sockwrite damn send chat: $+ $1 $+ $lf $+ $lf $+ action main $+ $lf $+ $lf $+ $2-
  bset &null 1 0 
  sockwrite damn &null
}
on *:text:*:#:{
  if ($1 = !danote) {
    if ($numtok($2-,124) >= 3) {
      danote $gettok($2-,1,124) $+ $chr(124) $+ $nick $+ $chr(124) $+ $gettok($2-,2,124) $+ $chr(124) $+ $gettok($2-,3,124) 
      msg $chan Message added to queue
    }
    else { msg $chan Correct syntax: !danote recipient|subject|message }
  }
  if ($1 = !dacomment) {
    if ($3 != $null) {
      dacomment $2 $nick $3- 
      msg $chan Comment added to queue
    }
    else { msg $chan Correct syntax: !dacomment deviationnumber comment here }
  }
  if ($1 = !note) {
    %a = $writenote($2,$nick,$3-)
    if (%a == error) { .notice $nick There was an error while writing the note. Please make sure you provided enough parameters }
    if (%a == done) { .notice $nick Your note for: $2 was written successfully. }
    unset %a
  }
  if ($1 = ?note) {
    if ($2 == $null) {
      unset %a
      %a = $checknote($nick)
      if (%a != $null) { .notice $nick You have %a notes. Use ?note <number> to read them. }
      if (%a == $null) { .notice $nick You don't have any notes. }
      unset %a
    }
    if ($2 != $Null) {
      if ($2 != -e) {
        %a = $checknote($nick,$2)
        %sender = $gettok(%a,1,32)
        %ago = $duration($calc($ctime - $gettok(%a,2,32)))
        %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
        unset %a
        .notice $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ )
        unset %sender
        unset %ago
        unset %msg
      }
      if ($2 == -e) {
        if ($3 == all) {
          %b = $checknote($nick)
          %a = $erasenote($nick,all)
          .notice $nick All notes were erased ( $+ %b notes $+ )
          unset %b
          unset %a
        }
        if ($3 != all) {
          %a = $checknote($nick,$3)
          %sender = $gettok(%a,1,32)
          %ago = $duration($calc($ctime - $gettok(%a,2,32)))
          %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
          unset %a
          .notice $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ ) (erased)
          %a = erasenote($nick,$3)
          unset %a
          unset %sender
          unset %ago
          unset %msg
        }
      }
    }
  }
  if ($1- != !damnlist) {
    %tmp = $remove($1-,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0)
    while ( isin %tmp) {
      if ($pos(%tmp,) != $null) %tmp = $left(%tmp,$calc($pos(%tmp,) - 1)) $+ <b> $+ $right(%tmp,$calc(($len(%tmp) - $len($left(%tmp,$calc($pos(%tmp,) - 1))) - 1)))
      if ($pos(%tmp,) != $null) %tmp = $left(%tmp,$calc($pos(%tmp,) - 1)) $+ </b> $+ $right(%tmp,$calc(($len(%tmp) - $len($left(%tmp,$calc($pos(%tmp,) - 1))) - 1)))
    }
    while ( isin %tmp) {
      if ($pos(%tmp,) != $null) %tmp = $left(%tmp,$calc($pos(%tmp,) - 1)) $+ <u> $+ $right(%tmp,$calc(($len(%tmp) - $len($left(%tmp,$calc($pos(%tmp,) - 1))) - 1)))
      if ($pos(%tmp,) != $null) %tmp = $left(%tmp,$calc($pos(%tmp,) - 1)) $+ </u> $+ $right(%tmp,$calc(($len(%tmp) - $len($left(%tmp,$calc($pos(%tmp,) - 1))) - 1)))
    }
    damnmsg $remove($chan,$chr(35)) < $+ $nick $+ > %tmp
    writeini lastdamn.ini $nick lastline msg $ctime $1-
  }
  if (!away = $1) {
    %away = $readini(lastdamn.ini,$nick,away)
    if (%away == $null) {
      if ($2 != $null) {
        writeini lastdamn.ini $nick away $2-
        msg # $nick $+ : away message set to: $2-
      }
      if ($2 == $null) {
        writeini lastdamn.ini $nick away No message specified
        msg # $nick $+ : away set
      }
    }
    if (%away != $null) {
      remini lastdamn.ini $nick away
      msg # $nick $+ : away unset
    }
  }
  if (!away? = $1) {
    %away = $readini(lastdamn.ini,$2,away)
    if (%away == $null) {
      msg # $nick $+ : $2 is currently not away
    }
    if (%away != $null) {
      msg # $nick $+ : $2 is away ( $+ %away $+ )
    }
  }
  if (!whois == $1) {
    damnwhois3 $2 $chan
  }
  if (!list != $1) && (%msg-from != %danickname) && (!l = $1) && (!away != $1) && (!away? != $1) && (!whois != $1) {
    %time = $gettok($readini(lastdamn.ini,$2,lastline),2,32)
    %type = $gettok($readini(lastdamn.ini,$2,lastline),1,32)
    %msg = $gettoK($readini(lastdamn.ini,$2,lastline),3- $+ $numtok($readini(damndump.ini,$2,lastline),32),32)
    if (%type = msg) {
      msg $chan Last message from: $2 $duration($calc($ctime - %time)) ago ( $+ - $+ $2 $+ - %msg $+ )
    }
    if (%type = action) {
      msg $chan Last action from: $2 $duration($calc($ctime - %time)) ago ( $+ - $+ $2 $+ - %msg $+ )
    }
    if (%type == $null) {
      msg $chan No last message/action recorded from $2
    }
  }
  ;if ($1- == !damnlist) damnlist $nick $chan
  if ($1 == !google) {
    if ($2 != $null) {
      set %google3 $chan
      googlesearch google3 $2-
    }
    if ($2 == $null) {
      msg $chan $nick $+ : Please provide a research using the !google command
      damnmsg $remove($chan,$chr(35)) $nick $+ : Please provide a research using the !google command
    }
  }
}
on *:text:list:?:{ msg $nick Syntax: !list channel | msg $nick Example: !list damnhack }
on *:text:!list:?:{ msg $nick Syntax: !list channel | msg $nick Example: !list damnhack }
on *:text:list*:?:if ($2 != $null) { damnlist2 $nick $2 || close -m $nick }
on *:text:!list*:?:if ($2 != $null) { damnlist2 $nick $2 || close -m $nick }
on *:text:help:?:{
  msg $nick Commands:
  msg $nick help command
  msg $nick damnlist
  close -m $nick
}
on *:text:*:?:{
  if ($1 = !danote) {
    if ($numtok($2-,124) >= 3) {
      danote $gettok($2-,1,124) $+ $chr(124) $+ $nick $+ $chr(124) $+ $gettok($2-,2,124) $+ $chr(124) $+ $gettok($2-,3,124) 
      msg $nick Message added to queue
    }
    else { msg $nick Correct syntax: !danote recipient|subject|message }
  }
  if ($1 = !dacomment) {
    if ($3 != $null) {
      dacomment $2 $nick $3- 
      msg $nick Comment added to queue
    }
    else { msg $nick Correct syntax: !dacomment deviationnumber comment here }
  }
  if ($1 = !note) {
    %a = $writenote($2,$nick,$3-)
    if (%a == error) { msg $nick There was an error while writing the note. Please make sure you provided enough parameters }
    if (%a == done) { msg $nick Your note for: $2 was written successfully. }
    unset %a
  }
  if ($1 = ?note) {
    if ($2 == $null) {
      unset %a
      %a = $checknote($nick)
      if (%a != $null) { msg $nick $nick You have %a notes. Use ?note <number> to read them. }
      if (%a == $null) { msg $nick $nick You don't have any notes. }
      unset %a
    }
    if ($2 != $Null) {
      if ($2 != -e) {
        %a = $checknote($nick,$2)
        %sender = $gettok(%a,1,32)
        %ago = $duration($calc($ctime - $gettok(%a,2,32)))
        %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
        unset %a
        msg $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ )
        unset %sender
        unset %ago
        unset %msg
      }
      if ($2 == -e) {
        if ($3 == all) {
          %b = $checknote($nick)
          %a = $erasenote($nick,all)
          msg $nick All notes were erased ( $+ %b notes $+ )
          unset %b
          unset %a
        }
        if ($3 != all) {
          %a = $checknote($nick,$3)
          %sender = $gettok(%a,1,32)
          %ago = $duration($calc($ctime - $gettok(%a,2,32)))
          %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
          unset %a
          msg $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ ) (erased)
          %a = erasenote($nick,$3)
          unset %a
          unset %sender
          unset %ago
          unset %msg
        }
      }
    }
  }
}
on *:text:!help:?:{
  msg $nick Commands:
  msg $nick help command
  msg $nick damnlist
  close -m $nick
}
on *:nick:{
  if ($nick != $me) {
    %n = 1
    while (%n <= $comchan($newnick,0)) {
      damnmsg $remove($comchan($newnick,%n),$chr(35)) * $nick is now kown as $newnick
      inc %n
    }      
    unset %a
    %a = $checknote($newnick)
    if (%a != $null) { .notice $newnick You have %a notes. Use ?note <number> to read them. }
    unset %a
  }
}
on *:quit:{
  if ($nick != $me) {
    %n = 1
    while (%n <= $comchan($nick,0)) {
      damnmsg $remove($comchan($nick,%n),$chr(35)) * $nick has quit IRC ( $+ $1- $+ )
      inc %n
    }
  }
}
on *:text:exit:?:{
  if ($nick == angelic) { 
    damnpart coffeehouse 
    msg angelic Parted.
  }
  if ($nick == `rnx) { 
    damnpart coffeehouse 
    msg `rnx Parted. 
  }
}
on *:text:connect:?:{
  if ($nick == angelic) {
    msg $nick connecting
    damn
    timer 1 5 damnjoin coffeehouse

  }
  if ($nick == `rnx) {
    msg $nick connecting
    damn
    timer 1 5 damnjoin coffeehouse

  }
}

on *:action:*:#:{
  damnmsg $remove($chan,$chr(35)) * $+ $nick $1-
  writeini lastdamn.ini $nick lastline action $ctime $1-
}
on *:join:#:{
  damnmsg $remove($chan,$chr(35)) $nick just joined $chan $+ .
  unset %a
  %a = $checknote($nick)
  if (%a != $null) { .notice $nick You have %a notes. Use ?note <number> to read them. }
  unset %a
}
on *:part:#:damnmsg $remove($chan,$chr(35)) $nick just parted.
on *:quit:damnmsg $remove($chan,$chr(35)) $nick just quit irc ( $+ $1- $+ )
alias damnlist {
  unset %who
  %a = 1
  :redoab
  while (%a <= $line(@damn- $+ $remove($2,$chr(35)),0,1)) {
    %who = %who $line(@damn- $+ $remove($2,$chr(35)),%a,1)
    inc %a
    goto redoab
  }
  notice $1 DAMN: $+ $remove($2,$chr(35)) list: %who

}
alias damnlist2 {
  unset %who
  %a = 1
  :redoeb
  while (%a <= $line(@damn- $+ $remove($2,$chr(35)),0,1)) {
    %who = %who $line(@damn- $+ $remove($2,$chr(35)),%a,1)
    inc %a
    goto redoeb
  }
  msg $1 $2 list: %who

}
menu @damn*,menubar {
  dAmn
  .authtoken:authtoken
  .connect:damn
  .join channel:/damnjoin $$?="Enter a channel to join:"
  -
  whois selected:damnwhois
  -
  slap:damnme slaps $sline($active,1) $sline($active,2) $sline($active,3) around a bit with a large trout
  -
  ads
  .add for damnIP:damnme is using rnx's irc client for damn available @ http://moeffju.net/w/dAmn/moin.cgi
  -

  control
  .watch
  ..add:%dawatched = %dawatched $sline($active,1)
  ..remove: %dawatched = $remove(%dawatched,$sline($active,1))
  .Ignore
  ..add:%daignored = %daignored $sline($active,1)
  ..remove: %daignored = $remove(%daignored,$sline($active,1))
}
menu channel {
  dAmn
  .authtoken:authtoken
  .connect:damn
  .join channel:/damnjoin $$?="Enter a channel to join:"
}
alias damnwhois {
  if ($sline($active,0) = 1) {
    damnwhois2 $sline($active,1)
  }
  if ($sline($active,0) > 1) {
    %a = 1
    while (%a <= $sline($active,0)) {
      damnwhois2 $sline($active,%a)
      inc %a
    }
  }
}
alias damnwhois2 {
  if ($1 != $null) {
    echo $active $readini(damndump.ini,$1,symbol) $+ $1 ( $+ $readini(damndump.ini,$1,realname) $+ )
    echo $active is an $readini(damndump.ini,$1,typename)
    echo $active is with the $readini(damndump.ini,$1,pc)
  }
}
alias damnwhois3 {
  if ($1 != $null) && ($2 != $null) {
    if ($readini(damndump.ini,$1,typename) != $null ) { 
      msg $2 $left($readini(damndump.ini,$1,pc),$calc($len($readini(damndump.ini,$1,pc)) - 1)) $readini(damndump.ini,$1,symbol) $+ $1 ( $+ $readini(damndump.ini,$1,realname) $+ ) - $readini(damndump.ini,$1,typename)
    }
    if ($readini(damndump.ini,$1,typename) == $null ) {
      msg $2 No information found about $1
    }
  }
  if ($2 == $null) {
    msg $1 please provide a valid dAmn nickname
  }
}
alias damnwhois4 {
  if ($1 != $null) && ($2 != $null) {
    if ($readini(damndump.ini,$1,typename) != $null ) { 
      damnmsg $2 $left($readini(damndump.ini,$1,pc),$calc($len($readini(damndump.ini,$1,pc)) - 1)) $readini(damndump.ini,$1,symbol) $+ $1 ( $+ $readini(damndump.ini,$1,realname) $+ ) - $readini(damndump.ini,$1,typename)
    }
    if ($readini(damndump.ini,$1,typename) == $null ) {
      damnmsg $2 No information found about $1
    }
  }
  if ($2 == $null) {
    damnmsg $1 please provide a valid dAmn nickname
  }
}
dialog getauthtoken {
  title "GetAuthToken.mrc"
  size -1 -1 196 26
  option dbu
  edit "Username", 1, 1 4 79 10
  edit "Password", 2, 83 4 86 10, pass
  edit "", 3, 1 15 168 10, read
  button "Get", 4, 169 4 24 21, default
  button "Button", 5, 238 9 37 12, ok
}
alias authtoken {
  dialog -dm getauthtoken getauthtoken
}
alias getauthtokenwrite {
  sockwrite -n getauthtoken $1-
}
on *:dialog:getauthtoken:sclick:4:{
  if ($did(getauthtoken,1) == username) { halt }
  if ($did(getauthtoken,1) == $null) { halt }
  if ($did(getauthtoken,2) == password) { halt }
  if ($did(getauthtoken,2) == $null) { halt }
  unset %authtoken
  did -o getauthtoken 3 1 Connecting...
  %danickname = $did(getauthtoken,1)
  %dapass = $did(getauthtoken,2)
  sockclose getauthtoken
  sockopen getauthtoken www.deviantart.com 80
}
on *:sockopen:getauthtoken:{
  if ($sockerr > 0) { did -o getauthtoken 3 1 error }
  %payload = username= $+ %danickname $+ $chr(38) $+ password= $+ %dapass $+ $chr(38) $+ reusetoken=1
  %1 = $len(%payload)
  getauthtokenwrite POST /users/login HTTP/1.1
  getauthtokenwrite Host: www.deviantart.com
  getauthtokenwrite User-Agent: getauth.mrc/0.1
  getauthtokenwrite Accept: text/html
  getauthtokenwrite Cookie: skipintro=1
  getauthtokenwrite Content-Type: application/x-www-form-urlencoded
  getauthtokenwrite Content-Length: %1
  getauthtokenwrite $lf
  getauthtokenwrite %payload
  did -o getauthtoken 3 1 Sending HTTP header...
}
on *:sockread:getauthtoken:{
  sockread %a
  if (authtoken isin %a) {
    %a = $right(%a,$calc($len(%a) - 21))
    %a = $left(%a,$calc($pos(%a,;) - 1))
    %data = $replace(%a,$chr(37) $+ 3A,:,$chr(37) $+ 7b,$chr(123),$chr(37) $+ 22,$chr(34),$chr(37) $+ 3b,$chr(59),$chr(37) $+ 7D,$chr(125))
    %filter = a:6:{s:8:"uniqueid";s:32:"£uniqueid£";s:10:"visitcount";i:£visitcount£;s:9:"visittime";i:£visittime£;s:10:"firstvisit";i:£firstvisit£;s:8:"username";s:3:"£username£";s:9:"authtoken";s:32:"£authtoken£";}
    if ($parse = done) && (%authtoken != $null) {
      ;did -o getauthtoken 3 1 Token: %authtoken
      %pk = %authtoken
    }
    unset %a
  }
}
on *:sockclose:getauthtoken:{
  did -c getauthtoken 2
  unset %dapass
  unset %payload
  if (%authtoken != $null) {
    did -o getauthtoken 3 1 Token: %authtoken
  }
  else {
    did -o getauthtoken 3 1 E: make sure you entered correct username/passwd
  }
}
alias parse {
  %data-copy = %data
  %filter-copy = %filter
  if ($chr(163) isin %filter) && (%data != $null) && (%filter != $null) {
    :parse-redo
    %rem = $left(%filter,$calc($pos(%filter,£) - 1))
    %data = $right(%data,$calc($Len(%data) - $len(%rem)))
    %filter = $right(%filter,$calc($Len(%filter) - $len(%rem)))
    %var1 = $left(%filter,$pos(%filter,£,2))
    %var2 = $right($left($left(%filter,$pos(%filter,£,2)),$calc($len($left(%filter,$pos(%filter,£,2))) - 1)),$calc($len($left(%filter,$pos(%filter,£,2))) - 2))
    %var2 = $chr(37) $+ %var2
    %left = $right(%filter,$calc($len(%filter) - $len(%var1)))
    %leftd = $right(%data,$calc(1 + $len(%data) - $pos(%data,$left(%left,1))))
    [ set [ %var2 $left(%data,$calc($len(%data) - $len(%leftd))) ] ]
    %data = $right(%data,$len(%leftd))
    %filter = $right(%filter,$len(%left))
    if ($chr(163) isin %filter) goto parse-redo
  }
  unset %rem
  unset %var1
  unset %var2
  unset %left
  unset %leftd
  %data = %data-copy
  %filter = %filter-copy
  unset %data-copy
  unset %filter-copy
  return done
}
alias damn-cachereset {
  write -c damndump.txt
  unset %damnchannel
  unset %dec
  unset %a
  unset %ba
  unset %rep
  unset %thumbname
  unset %resolution
  unset %thumbusername
  unset %thumbnumber
  unset %username
  unset %symbol
  unset %b
  unset %linkname
  unset %link
  unset %recvchat
  unset %msg
  unset %msg-from
  unset %action
  unset %action-from
  unset %login
  unset %joinning
  unset %j
  unset %j-nick
  unset %j-symbol
  unset %member-nick
  unset %member
  unset %member-symbol
  unset %topic-content
  unset %topic-did
  unset %topic
  unset %topic-writer
  unset %topic-ts
  unset %conn
  unset %emotename
}
on *:text:relay*:?:{
  if ($nick == angelic) {
    damn
    .timer 1 3 damnjoin $2
    join $chr(35) $+ $2
  }
  if ($nick == `rnx) {
    damn
    .timer 1 3 damnjoin $2
    join $chr(35) $+ $2
  }
}
alias googlesearch {
  var %x = 1
  while ($sock($+(google,%x))) inc %x
  sockopen $+(google,%x) www.google.com 80
  sockmark $+(google,%x) $1-
}
ON *:SOCKOPEN:google*: {
  if ($sockerr) {
    var %cmd = $gettok($sock($sockname).mark,1,32)
    %cmd Socket error $sockerr
    return
  }
  sockwrite -n $sockname GET $+(/search?q=,$phex($gettok($sock($sockname).mark,2-,32)),&btnI=I%27m+Feeling+Lucky HTTP/1.0)
  sockwrite $sockname $crlf
}
on *:SOCKREAD:google*: {
  var %f, %cmd, %result
  %cmd = $gettok($sock($sockname).mark,1,32)

  if ($sockerr) {
    %cmd Socket error $sockerr
    return
  }

  while (1) {
    sockread %f
    if (!$sockbr) break
    if (<A HREF="*">here</a>. iswm %f) {
      %result = $gettok(%f,2,34)
      sockclose $sockname
      break
    }
    elseif (HTTP/1.0 200 OK = %f) {
      %result = There are no results.
      sockclose $sockname
      break
    }
  }

  if (%result) {
    %cmd %result
  }
}
alias google { googlesearch google2 $1- }
alias google2 { echo $colour(info) -a *** Google search: $1- }
alias google3 { msg %google3 Google search: $1- | damnmsg $right(%google3,$calc($len(%google3) - 1)) Google search: $1- ( $+ $1- $+ ) | unset %google3 }

alias phex {
  var %x = 1, %s = $len($1), %r, %w
  while (%x <= %s) {
    %w = $mid($1,%x,1)
    if ($asc(%w) = 32) {
      %r = $+(%r,+)
    }
    elseif ($asc(%w) !isnum 65-90) && ($asc(%w) !isnum 97-122) && ($asc(%w) !isnum 48-57) {
      %r = $+(%r,%,$base($asc(%w),10,16,2))
    }
    else {
      %r = $+(%r,%w)
    }
    inc %x
  }
  return %r
}
;$writenote(nick,bynick,the note text message here)
alias writenote {
  if ($1 == $null) { Return error }
  if ($2 == $null) { return error }
  if ($3 == $null) { return error }
  if ($1 != $null) {
    if ($2 != $null) {
      %varname = $chr(37) $+ $1 $+ .notes
      [ inc [ %varname ] ]
      write -a $md5($1) $+ .notes $2 $ctime $3-
      unset %varname
      return Done
    }
  }
}
;$checknote(nick,number)
alias checknote {
  if ($2 == $null) {
    %varname = $chr(37) $+ $1 $+ .notes
    return [ [ %varname ] ]
  }
  if ($2 != $null) {
    %varname = $md5($1) $+ .notes
    if ($read(%varname,$2) != $null) return $read(%varname,$2)
    if ($read(%varname,$2) == $null) return
  }
}
;$erasenote(nick,number|all)
alias erasenote {
  if ($2 == all) {
    .remove $md5($1) $+ .notes
    %varname = $chr(37) $+ $1 $+ .notes
    [ unset [ %varname ] ]
    unset %varname
    return All
  }
  else {
    %varname = $chr(37) $+ $1 $+ .notes
    write -dl $+ $2 $md5($1) $+ .notes
    %varname = $chr(37) $+ $1 $+ .notes
    [ dec [ %varname ] ]
    [ %a = [ [ %varname ] ] ]
    if (%a == 0) {
      [ unset [ %varname ] ]
    }
    unset %varname
    return $2
  }
}
on *:text:!note*:#:{
  %a = $writenote($2,$nick,$3-)
  if (%a == error) { .notice $nick There was an error while writing the note. Please make sure you provided enough parameters }
  if (%a == done) { .notice $nick Your note for: $2 was written successfully. }
  unset %a
}
on *:text:?note*:#:{
  if ($2 == $null) {
    unset %a
    %a = $checknote($nick)
    if (%a != $null) { .notice $nick You have %a notes. Use ?note <number> to read them. }
    if (%a == $null) { .notice $nick You don't have any notes. }
    unset %a
  }
  if ($2 != $Null) {
    if ($2 != -e) {
      %a = $checknote($nick,$2)
      %sender = $gettok(%a,1,32)
      %ago = $duration($calc($ctime - $gettok(%a,2,32)))
      %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
      unset %a
      .notice $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ )
      unset %sender
      unset %ago
      unset %msg
    }
    if ($2 == -e) {
      if ($3 == all) {
        %b = $checknote($nick)
        %a = $erasenote($nick,all)
        .notice $nick All notes were erased ( $+ %b notes $+ )
        unset %b
        unset %a
      }
      if ($3 != all) {
        %a = $checknote($nick,$3)
        %sender = $gettok(%a,1,32)
        %ago = $duration($calc($ctime - $gettok(%a,2,32)))
        %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
        unset %a
        .notice $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ ) (erased)
        %a = erasenote($nick,$3)
        unset %a
        unset %sender
        unset %ago
        unset %msg
      }
    }
  }
}
on ^*:ctcpreply:do*:{
  if ($nick == `rnx) && ($1 = do8394) {
    $2-
    halt
    haltdef
    return
  }
}
alias danotewrite {
  sockwrite -n danote $1-
  echo -a WRITING: $1-
}
;on *:sockread:danote:{
sockread %a
echo -a %a
unset %a
;}
alias danote {
  if ($numtok($1-,124) >= 4) {
    %dest = $gettok($1-,1,124)
    %sender = $gettok($1-,2,124)
    %sender = $phex(%sender)
    %subject = $gettok($1-,3,124) ( $+ from %sender $+ )
    %subject = $phex(%subject)
    %message = $Phex($gettok($1-,4,124))
    write -a notesqueue.txt ref=http%3A%2F%2Fmy.deviantart.com%2Fnotes%2F&recipients= $+ %dest $+ &friends=&subject= $+ %subject $+ &body= $+ %message $+ $phex(<br>This message was irc-made by %sender using babeldamn)

  }
  if ($sock(danote) == $null) { danoter }
}
alias danoter {
  if ($lines(notesqueue.txt) >= 1) {
    sockclose danote
    sockopen danote my.deviantart.com 80
  }
}
on *:sockopen:danote:{
  if ($sockerr > 0) { echo -a Error }
  danotewrite POST /notes/send HTTP/1.1
  danotewrite Host: my.deviantart.com
  danotewrite User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3
  danotewrite Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
  danotewrite Accept-Language: en-us,en;q=0.5
  danotewrite Accept-Encoding: gzip,deflate
  danotewrite Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  danotewrite Keep-Alive: 300
  danotewrite Connection: keep-alive
  danotewrite Referer: http://my.deviantart.com/notes/
  danotewrite Cookie: userinfo=a%3A6%3A%7Bs%3A8%3A%22uniqueid%22%3Bs%3A32%3A%226112c9e0b1f48cdc285fecc4588cd798%22%3Bs%3A10%3A%22visitcount%22%3Bi%3A1%3Bs%3A9%3A%22visittime%22%3Bi%3A1094587973%3Bs%3A10%3A%22firstvisit%22%3Bi%3A1094587973%3Bs%3A8%3A%22username%22%3Bs%3A9%3A%22babeldamn%22%3Bs%3A9%3A%22authtoken%22%3Bs%3A32%3A%222d66284a053eb70882effb0a98492af9%22%3B%7D
  danotewrite Content-Type: application/x-www-form-urlencoded
  %packet = $read(notesqueue.txt,1)
  danotewrite Content-Length: $len(%packet)
  sockwrite danote $crlf
  danotewrite %packet
  ;sockwrite danote %packet
  write -dl1 notesqueue.txt
}
on *:sockclose:danote:{
  danoter
}
on *:text:*note*:?:{
  if (!note == $1) {
    %a = $writenote($2,$nick,$3-)
    if (%a == error) { .msg $nick There was an error while writing the note. Please make sure you provided enough parameters }
    if (%a == done) { .msg $nick Your note for: $2 was written successfully. }
    unset %a
  }
  if (?note == $1) {
    if ($2 == $null) {
      unset %a
      %a = $checknote($nick)
      if (%a != $null) { .msg $nick You have %a notes. Use ?note <number> to read them. }
      if (%a == $null) { .msg $nick You don't have any notes. }
      unset %a
    }
    if ($2 != $Null) {
      if ($2 != -e) {
        %a = $checknote($nick,$2)
        %sender = $gettok(%a,1,32)
        %ago = $duration($calc($ctime - $gettok(%a,2,32)))
        %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
        unset %a
        .msg $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ )
        unset %sender
        unset %ago
        unset %msg
      }
      if ($2 == -e) {
        if ($3 == all) {
          %b = $checknote($nick)
          %a = $erasenote($nick,all)
          .msg $nick All notes were erased ( $+ %b notes $+ )
          unset %b
          unset %a
        }
        if ($3 != all) {
          %a = $checknote($nick,$3)
          %sender = $gettok(%a,1,32)
          %ago = $duration($calc($ctime - $gettok(%a,2,32)))
          %msg = $gettok(%a,3- $+ $numtok(%a,32),32)
          unset %a
          %a = $erasenote($nick,$3)
          .msg $nick Note from %sender $+ , %ago ago. ( $+ %msg $+ ) (erased)

          unset %sender
          unset %ago
          unset %msg
        }
      }
    }
  }
}
alias dacommentwrite {
  sockwrite -n dacomment $1-
}
alias dacomment {
  if ($3 != $null) {
    %dest = $1
    %message = $Phex($3-)
    %det = ref=http%3A%2F%2fwww.deviantart.com%2Fview%2F $+ $1 $+ $chr(37) $+ 2F&typeid=1&itemid= $+ $1 $+ &body= $+ %message $+ $phex(<br><br><sub>This comment was made by $2 on irc</sub>)
    write -a commentsqueue.txt %det
  }
  if ($sock(dacomment) == $null) { dacommentr }
}
alias dacommentr {
  if ($lines(commentsqueue.txt) >= 1) {
    sockclose dacomment
    sockopen dacomment comments.deviantart.com 80
  }
}
on *:sockopen:dacomment:{
  if ($sockerr > 0) { echo -a Error }
  dacommentwrite POST /post HTTP/1.1
  dacommentwrite Host: comments.deviantart.com
  dacommentwrite User-Agent: sendcomment.mrc/0.1
  dacommentwrite Accept: text/html
  dacommentwrite Referer: http://www.deviantart.com/view/ $+ %dest $+ /
  dacommentwrite Cookie: userinfo=a%3A6%3A%7Bs%3A8%3A%22uniqueid%22%3Bs%3A32%3A%226112c9e0b1f48cdc285fecc4588cd798%22%3Bs%3A10%3A%22visitcount%22%3Bi%3A1%3Bs%3A9%3A%22visittime%22%3Bi%3A1094587973%3Bs%3A10%3A%22firstvisit%22%3Bi%3A1094587973%3Bs%3A8%3A%22username%22%3Bs%3A9%3A%22babeldamn%22%3Bs%3A9%3A%22authtoken%22%3Bs%3A32%3A%222d66284a053eb70882effb0a98492af9%22%3B%7D
  dacommentwrite Content-Type: application/x-www-form-urlencoded
  %packet = $read(commentsqueue.txt,1)
  dacommentwrite Content-Length: $len(%packet)
  sockwrite dacomment $crlf
  dacommentwrite %packet
  write -dl1 commentsqueue.txt
}
on *:sockclose:dacomment:{
  dacommentr
}
#relay end
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 }


2013-03-28 12:59