mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2011
Posts: 2
P
Bowl of petunias
OP Offline
Bowl of petunias
P
Joined: Dec 2011
Posts: 2
I was wanting the script to announce it to the channel when they join if it is their birthday. I was also wanting it to announce every 2.5 hrs that it is someone's birthday, if it is their birthday.
Code:
;Birthday Mode
on *:join:#: {
  if (!$read(bday.txt,s,$nick)) { 
    notice $nick Type $!addbday <name> <month> <day> (Ex. $!addbday Jesus December 25) to set your birthday. Type $!bday <name> to see how long it is until the birthday. 
  }
}
on *:TEXT:$addbday *:#: {
  if ($2) && ($read(bday.txt,s,$2)) { 
    notice $nick This name is already on the birthday list.
    halt
  } 
  if ($2 != $read(bday.txt,s,$2)) && ($2) { 
    write bday.txt $2,$3-
    notice $nick Your birthday has been recorded under the name $2 $+ . type $!bday <name> to see how long you have until the birthday.
    halt  
  } 
}  
on *:TEXT:$bday *:#: {
  if ($2) && ($read(bday.txt,s,$2)) && ( $calc($ctime($read(bday.txt,s,$2) $asctime(yyyy) 00:00:00) - $ctime) > 0 ) { 
    msg $chan There are $duration( $calc( $ctime($read(bday.txt,s,$2) $asctime(yyyy) 00:00:00) - $ctime)) left until $read(bday.txt,s,$2) and $2 $+ 's birthday!!! 
    halt  
  }

  elseif ($2) && ($read(bday.txt,s,$2)) {  
    msg $chan There are $duration($calc($ctime($read(bday.txt,s,$2) $calc($asctime(yyyy)+1) 00:00:00) - $ctime)) left until $read(bday.txt,s,$2) or $2 $+ 's birthday
    halt  
  }
  if ($2 != $read(bday.txt,s,$2)) { 
    notice $nick I'm sorry $nick $+ . This name is not in my list of birthdays. 
  }
}
#bday end


thank you!

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
I was bored, here's something to work from.

Code:
alias bday.usage { 
  if ($prop == add) { return !addbday name month day }
  if ($prop == bday) { return !bday name }
  return Type !addbday <name> <month> <day> (Ex. !addbday Jesus December 25) to set your birthday. Type !bday <name> to see how long it is until the birthday. 
}

on *:start:{
  .timerbday 0 9000 announcebdays #chan
}

on *:join:#chan: {
  if ($isbday($nick) == 1) msg # Happy birthday $+($nick,!)
  ;elseif ($v1 == -1) notice $nick $bday.usage
}

on *:text:!bday *:#chan:{
  var %nick = $iif($2,$2,$nick)
  if ($isbday(%nick) == 1) {
    msg # Today is $+(%nick,'s) birthday!
  }
  elseif ($v1 == 0) {
    var %bday = $readini(bday.ini,nicks,%nick)
    var %month = $gettok(%bday,1,45)
    var %day = $gettok(%bday,2,45)
    msg # $duration($todate(%month,%day)) until $+(%nick,'s) birthday
  }
  else {
    msg # %nick not found. Usage: $bday.usage().bday
  }
}

on *:text:!addbday *:#chan:{
  if ($addbday($2,$3,$4)) {
    msg # Birthday for $2 added.
  }
  else {
    msg # $bday.usage().add
  }
}

alias addbday {
  var %nick = $1
  var %month = $2
  var %day = $3
  
  if ($0 < 3) || (%day !isnum) return $false

  if (%month isalpha) {
    var %months = jan feb apr mar may jun jul aug sep oct nov dec
    %month = $findtok(%months,$left(%month,3),32)
  }
  else {
    %month = $regsubex(%month,^0+,)
  }

  var %date = $+(%month,-,%day)

  writeini bday.ini nicks %nick %date
  writeini bday.ini %date %nick 1
  return $true
}

alias announcebdays {
  var %chan = $$1
  var %date = $+($asctime(m),-,$asctime(d))
  var %nick, %nicklist
  var %i = 1
  var %n = $ini(bday.ini,%date,0)
  while (%i <= %n) {
    %nick = $ini(bday.ini,%date,%i)
    if (%nick ison %chan) %nicklist = %nicklist %nick
    inc %i
  }
  dec %i
  if (%i == 2) {
    %nicklist = $replace(%nicklist,$chr(32),$+($chr(32),$chr(38),$chr(32)))
  }
  elseif (%i > 2) {
    %nicklist = $replace(%nicklist,$chr(32),$+($chr(44),$chr(32)))
    %nicklist = $regsubex(%nicklist,(\S+?$),and \1)
  }

  if (%nicklist) msg %chan Happy Birthday to $+(%nicklist,!)
}

alias isbday {
  var %nick = $1
  var %date = $readini(bday.ini,nicks,%nick)
  var %month = $gettok(%date,1,45)
  var %day = $gettok(%date,2,45)

  if (!%date) return -1
  if (%month == $asctime(m)) && (%day == $asctime(d)) return 1
  return 0
}

alias todate {
  var %month = $1
  var %day = $$2
  var %year = $asctime(yyyy)

  var %todate = $calc($ctime($+(%day,-,%month,-,%year) 00:00:00) - $ctime)
  if (%todate < 0) {
    inc %year
    %todate = $calc($ctime($+(%day,-,%month,-,%year) 00:00:00) - $ctime)
  }
  return %todate
}


Link Copied to Clipboard