Simple Channel Greet System

By Scakk on Apr 12, 2008

This is a simple channel greet system using hash tables. It saves greets based on nick so you can have a different greet for each nick you use.

!setgreet
!delgreet
!viewgreet
!viewgreet

Updated the script some 18Oct09
1) Added save function for hash tables.
2) Removed all the evil "| halt"
3) Added a little color to the "on join" part.
4) Added an "on connect" to load the Greets hash table when you connect.

on *:text:!setgreet*:#: { 
  $iif(!$hget(Greet), hmake -s Greet 100)
  if (!$3) { .notice $nick Usage !Setgreet Nick Greet }
  if ($3) {
    if (!$hget(Greets,$2)) { .notice $nick Your greet message for $2 has been set to $qt($3-) | hadd -m Greets $2 $3- }
    if ($hget(Greets,$2)) { .notice $nick There is already a greet set for $+($2,.) You can remove it using !delgreet nick and then place a new greet using !setgreet nick greet. }
    hsave -s Greets Greets.dat
  } 
}

on *:text:!delgreet*:#: { 
  if (!$2) { .notice $nick Please provide a nick for greet deletion. }
  if ($2) { .notice $nick The greet message for $2 has been deleted. | hdel Greets $2 }
  hsave -s Greets Greets.dat
} 

on *:text:!viewgreet*:#:{
  if ($2) { $iif($hfind(Greets,$2), msg $chan $+([,$colored($2,4),]:) $hget(Greets,$2) , msg $chan $2 does not have a greet.) }
  if (!$2) { $iif($hfind(Greets,$nick), msg $chan $+([,$colored($nick,4),]:) $hget(Greets,$nick) , msg $chan $nick does not have a greet. ) }
}

on *:join:#CHANNEL: { if ($hfind(Greets,$nick)) { msg $chan $+([,$colored($nick,4),]:) $hget(Greets,$nick) } }

on *:connect: { if ($isfile(Greets.dat)) hload Greets Greets.dat }

; Usage: $colored(TEXT,N1,N2) or $colored(TEXT,N1,N2).b
; N1 & N2 are both optional.
alias colored { if ($isid) { return $+($iif($prop = b,$chr(2)),$iif($2 isnum 0-15,$+($chr(3),$iif($len($2) == 1,$+($chr(48),$2),$2))),$iif($3 isnum 0-15,$+($chr(44),$iif($len($3) == 1,$+($chr(48),$3),$3))),$1,$chr(15)) } }

Comments

Sign in to comment.
Scakk   -  May 25, 2011

This was written long ago. I might redo it and update it a bit if I get the time with the other projects I am working on.

 Respond  
Jethro   -  May 25, 2011

Scakk, you may get an error saying the hash table doesn't exist before loading upon connection. (This error will occur if someone has his or her mIRC closed or exited) My suggestion is to make it like so:

on *:connect:{ 
 if (!$hget(greets)) hmake greets 100
 if ($file(greets).shortfn)) hload greets $v1
}

You sort of don't need this bit under the first text event:> $iif(!$hget(Greet), hmake -s Greet 100)You already have the -m switch specified for the /hadd command to be made if the hash table doesn't exist. The default table size is already 100 slots. And it doesn't matter how big or small the table size is, as the space is going to be unlimited. Though the bigger the size, the faster hash table works.

Finally, and this is unimportant, you can congregate those text events as one.

 Respond  
Scakk   -  May 25, 2011

This goes in Remotes ( ALT +R )

This would go on a bot or be used by others in the channel(s) so they can set a greet for themselves.

 Respond  
loves.enough   -  May 25, 2011

how to use this ?
where i put it in remote or mrc file

 Respond  
Scakk   -  Oct 18, 2009

Updated it a bit as noted in Introduction.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.