egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Nick specific onjoin greetings.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 607
Location: Tennessee, USA

PostPosted: Sun Jan 06, 2019 9:06 pm    Post subject: Nick specific onjoin greetings. Reply with quote

This script is in reply to a script request from 2 days ago.

That request was deleted, but not before the script was almost done:)

Code:

###################################################################
## SayGreet  ver. 0.1  by SpiKe^^           www.mytclscripts.com ##
###################################################################

##################################################### 06/01/2019 ##
#                                                                 #
# onjoin greeting script, with nick and/or chan specific greets.  #
#                                                                 #
# You Must create the file with all available greeting messages!  #
# Each greeting message goes on its own file line.                #
# The order of the lines doesn't matter. Blank lines are ignored. #
# If the script finds multiple valid greets, picks one randomly.  #
#                                                                 #
# -Example- adding 2 script default greeting messages.            #
#  Welcome to %c% : Stay & Play some Trivia with us.              #
#  Welcome to %c% : Use .triv to start the Trivia game.           #
#                                                                 #
# You can also set Nick and/or Chan Specific greeting messages.   #
# -Example- adding 2 nick specific greetings (both same nick).    #
#  Houdini :: Welcome back %n% : Behave yourself:)                #
#  houdini :: The king has returned. Welcome back %n%             #
# -Example- adding 2 channel specific default greetings.          #
#  #lamechat :: [%n%] Don't be Lame. Say something witty.         #
#  #lameChat :: Welcome to %c% %n% : Don't be Lame:)              #
# -Example- adding 2 nick and channel specific greetings.         #
#  houdini@#trivial :: The king has returned. Top trivia champ!   #
#  houdini@#Trivial :: Welcome back %n% : 99583 Points Last week! #
#                                                                 #
###################################################################

namespace eval saygreet { variable greet
#######################################################
## - Begin Script Settings - Begin Script Settings - ##
#######################################################

#  Set the channel(s) to run this script in.  #
set greet(chans) ""   ;#   ("" = all channels)  #

#  Set the route/file.name to the greetings file.  #
set greet(file) "scripts/greets.txt"

#  Set the file line divider between nick/chan and the message.  #
#  Use any string that will Never be in a greeting message.  #
set greet(fdiv) "::"

#  1 = Send greets by message  #  2 = Send greets by notice  #
set greet(how) "1"

#  1 = Send greets to channel  #  2 = Send greets to nick  #
set greet(who) "1"

#  Prefix all greetings with the users nick??  (1+=yes 0=no)  #
#  1 = Prefix all greetings with users nick.  #
#  2 = Add users nick Only if no %n% in the greet message.  #
set greet(unick) "2"


#######################################################
#### - End Script Settings - End Script Settings - ####
#######################################################

bind join - * [namespace current]::saygreet

set greet(chans) [string trim $greet(chans)]
if {$greet(chans) eq "" || $greet(chans) eq "*"} { set greet(_chans) ""
} else {  set greet(_chans) [split [string tolower $greet(chans)]]  }

if {$greet(how) ne "2"} {  set greet(how) 1  }
if {$greet(who) ne "2"} {  set greet(who) 1  }
if {$greet(unick) ni {0 1}} {  set greet(unick) 2  }

proc saygreet {nk uh hn ch} {  variable greet
  set que "puthelp"
  set nklo [string tolower $nk]  ;  set chlo [string tolower $ch]

  if {$greet(_chans) ne "" && [lsearch -exact $greet(_chans) $chlo]<0} {
    return 0
  }
  if {[isbotnick $nk] || ![file exists $greet(file)]} {  return 0  }

  set open [open $greet(file) r]
  set greets [split [string trim [read $open]] \n]
  close $open
  set defls "" ;  set cdefls "" ;  set sayls "" ;  set csayls ""
  set divider $greet(fdiv)

  foreach gr $greets {  set gr [string trim $gr]
    if {$gr eq ""} {  continue  }
    set rest [join [lassign [split $gr] nkch div]]
    set nkch [string tolower $nkch]
    if {$div eq $divider} {
      if {$nkch eq "!def" || $nkch eq "!default"} {
        lappend defls $rest
      } elseif {[string match "*,${nklo}@${chlo},*" ",${nkch},"]} {
        lappend csayls $rest
      } elseif {[string match "*,${nklo},*" ",${nkch},"]} {
        lappend sayls $rest
      } elseif {[string match "*,${chlo},*" ",${nkch},"]} {
        lappend cdefls $rest
      } elseif {[string match "*,@${chlo},*" ",${nkch},"]} {
        lappend cdefls $rest
      }
    } elseif {$nkch eq $divider} {
      lappend defls "$div $rest"
    } else {  lappend defls $gr  }
  }

  if {$csayls ne ""} {  set gotls $csayls
  } elseif {$sayls ne ""} {  set gotls $sayls
  } elseif {$cdefls ne ""} {  set gotls $cdefls
  } elseif {$defls ne ""} {  set gotls $defls
  } else {  set gotls ""  }
  if {$gotls eq ""} {  return 0  }

  set got [lindex $gotls [rand [llength $gotls]]]
  set say [string map [list %n% $nk %c% $ch] $got]
  if {$greet(unick)==2 && ![string match "*%n%*" $got]} {
    set say "$nk : $say"
  } elseif {$greet(unick)==1} {  set say "$nk : $say"  }

  if {$greet(how)==2} { set how "NOTICE" } else { set how "PRIVMSG" }
  if {$greet(who)==2} {  set who $nk  } else {  set who $ch  }

  $que "$how $who :$say"
}

putlog "SayGreet ver. 0.1 Loaded."
} ;## - End namespace eval - ##


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
m4s
Halfop


Joined: 30 Jan 2017
Posts: 52

PostPosted: Sun Jul 21, 2019 2:53 pm    Post subject: Re: Nick specific onjoin greetings. Reply with quote

SpiKe^^ wrote:
This script is in reply to a script request from 2 days ago.

That request was deleted, but not before the script was almost done:)



Hello!

Thanks the script works! Smile

May I have a request?
I would like to see the names (%n%) and channels (%c%) to be bold in the greetings.

Example:
Configuration in the file: Houdini :: Welcome back %n% : Behave yourself:)
Bot says: Welcome back Houdini : Behave yourself:)

Thank You! Smile
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 607
Location: Tennessee, USA

PostPosted: Mon Jul 22, 2019 10:35 am    Post subject: Reply with quote

Try replace this line...
Code:
set say [string map [list %n% $nk %c% $ch] $got]

with this edited line...
Code:
set say [string map [list %n% \002$nk\002 %c% \002$ch\002] $got]

_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
m4s
Halfop


Joined: 30 Jan 2017
Posts: 52

PostPosted: Mon Jul 22, 2019 12:54 pm    Post subject: Reply with quote

Hello SpiKe^^!

Thanks, it's super! Everything works! Smile Have a nice day! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber