Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# config header and procs moved to profile-0.*.tcl
################################ high wizardry begins ######################################
############################################################################################
if {[string match "*s*" $int_proc_bind]} {
bind pub -|- $int_bind(setup) int_proc_setup
}
if {[string match "*u*" $int_proc_bind]} {
bind pub -|- $int_bind(updatee) int_proc_update
}
if {[string match "*d*" $int_proc_bind]} {
bind pub -|- $int_bind(delete) int_proc_remove
}
if {[string match "*r*" $int_proc_bind]} {
bind pub -|- $int_bind(release) int_proc_release
}
if {[string match "*e*" $int_proc_bind]} {
bind pub o|o $int_bind(sessions) int_proc_sessions
}
if {[string match "*f*" $int_proc_bind]} {
bind pub o|o $int_bind(flussh) int_proc_flush
}
if {[string match "*p*" $int_proc_bind]} {
bind msgm -|- "*" int_proc_msgm
}
if {[string match "*a*" $int_proc_bind]} {
bind part -|- "*" int_proc_part
}
if {[string match "*i*" $int_proc_bind]} {
bind sign -|- "*" int_proc_sign
}
if {[string match "*l*" $int_proc_bind]} {
bind splt -|- "*" int_proc_splt
}
if {[string match "*k*" $int_proc_bind]} {
bind kick -|- "*" int_proc_kick
}
if {[string match "*n*" $int_proc_bind]} {
bind nick -|- "*" int_proc_nick
}
setudef flag intadd
set int_global_nicks [list]
set int_global_uhosts [list]
set int_global_pnames [list]
set int_global_questions_idx [list]
set int_global_answers_mode [list]
set int_global_modes [list]
set int_global_update_mode [list]
proc putnq { data } {
putdccraw 0 [string length "$data\n"] "$data\n"
}
proc int_check_global_n_u { nick uhost } {
global int_global_nicks int_global_uhosts
set new_n_u_state 0
if {([lsearch $int_global_nicks $nick] > -1) && \
([lsearch $int_global_uhosts $uhost] > -1)} {
set new_n_u_state 1
}
return $new_n_u_state
}
proc int_check_global_pn { profile_name } {
global int_global_pnames
set new_pn_state 0
if {[lsearch $int_global_pnames $profile_name] > -1} {
set new_pn_state 1
}
return $new_pn_state
}
proc int_nick_to_profile { nick } {
global int_global_nicks int_global_pnames
set profile_name ""
set nick_idx [lsearch $int_global_nicks $nick]
set profile_name [lindex $int_global_pnames $nick_idx]
return $profile_name
}
proc int_nick_to_idx { nick } {
global int_global_nicks
set nick_idx [lsearch $int_global_nicks $nick]
return $nick_idx
}
proc int_nick_to_answer_mode { nick } {
global int_global_answers_mode
set nick_answer_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_answer_mode [lindex $int_global_answers_mode $nick_global_idx]
return $nick_answer_mode
}
proc int_nick_to_update_mode { nick } {
global int_global_update_mode
set nick_update_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_update_mode [lindex $int_global_update_mode $nick_global_idx]
return $nick_update_mode
}
proc int_nick_to_mode { nick } {
global int_global_modes
set nick_int_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_int_mode [lindex $int_global_modes $nick_global_idx]
return $nick_int_mode
}
proc int_switch_answer_mode { nick } {
global int_global_answers_mode
set nick_global_idx [int_nick_to_idx $nick]
set user_answer_mode [lindex $int_global_answers_mode $nick_global_idx]
if {$user_answer_mode == 0} {
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx 1]
} {
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx 0]
}
}
proc int_switch_update_mode { nick } {
global int_global_update_mode
set nick_global_idx [int_nick_to_idx $nick]
set user_update_mode [lindex $int_global_update_mode $nick_global_idx]
if {$user_update_mode == 0} {
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx 1]
} {
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx 0]
}
}
proc int_incr_nick_idx { nick } {
global int_global_questions_idx
set nick_global_idx [int_nick_to_idx $nick]
set nick_question_idx [expr [lindex $int_global_questions_idx $nick_global_idx] + 1]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx $nick_question_idx]
}
proc int_set_nick_idx { nick new_idx } {
global int_global_questions_idx
set nick_global_idx [int_nick_to_idx $nick]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx $new_idx]
}
proc int_nick_for_delete { nick } {
global int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode
set nick_global_idx [int_nick_to_idx $nick]
set int_global_nicks [lreplace $int_global_nicks $nick_global_idx $nick_global_idx]
set int_global_uhosts [lreplace $int_global_uhosts $nick_global_idx $nick_global_idx]
set int_global_pnames [lreplace $int_global_pnames $nick_global_idx $nick_global_idx]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx]
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx]
set int_global_modes [lreplace $int_global_modes $nick_global_idx $nick_global_idx]
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx]
}
proc int_proc_setup { nick uhost hand chan arg } {
global int_bind int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp int_questions_auto_start int_random_generator int_questions_list
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 0} {
if {([int_nick_to_mode $nick] != "update") && ([int_nick_to_mode $nick] != "remove")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "setup"
lappend int_global_update_mode 0
if {$int_random_generator == 0} {
set open_dev [open "/dev/urandom" r]
set get_bytes [read $open_dev 16]
close $open_dev
} {
set some_numbers [expr floor(rand() * [clock seconds])]
set some_string [lindex $int_questions_list [rand [llength $int_questions_list]]]
set some_char [string index $some_string [expr [rand [string length $some_string]] - 1]]
set get_bytes "$some_numbers $some_char"
}
set md5_key [md5 $get_bytes]
set action_time [clock seconds]
int_new_profile_event $nick $uhost $chan $profile_name $md5_key $action_time
set key_msg $int_msg(int_key)
regsub -all "&k" $key_msg $md5_key key_msg
putnq "PRIVMSG $nick :$int_msg(int_start)"
putnq "PRIVMSG $nick :$key_msg"
if {$int_questions_auto_start == 1} {
int_proc_msgm $nick $uhost $hand $int_bind(questions_start)
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_help)"
}
}
proc int_proc_update { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 1} {
if {([int_nick_to_mode $nick] != "setup") && ([int_nick_to_mode $nick] != "remove")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "update"
lappend int_global_update_mode 0
putnq "PRIVMSG $nick :$int_msg(update_start)"
} {
putnq "PRIVMSG $nick :$int_msg(update_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_not_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_help)"
}
}
proc int_proc_remove { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 1} {
if {([int_nick_to_mode $nick] != "setup") && ([int_nick_to_mode $nick] != "update")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "remove"
lappend int_global_update_mode 0
putnq "PRIVMSG $nick :$int_msg(remove_start)"
} {
putnq "PRIVMSG $nick :$int_msg(remove_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(remove_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_not_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(remove_help)"
}
}
proc int_proc_release { nick uhost hand chan arg } {
global int_global_nicks int_msg
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(release_done)"
} {
putnq "PRIVMSG $nick :$int_msg(release_empty)"
}
}
proc int_proc_msgm { nick uhost hand arg } {
global int_bind int_msg int_questions_list int_global_questions_idx int_questions_key int_questions_regexp int_question_help
set arg [string trim $arg]
if {[int_check_global_n_u $nick $uhost] == 1} {
set profile_name [int_nick_to_profile $nick]
set nick_global_idx [int_nick_to_idx $nick]
set nick_answer_mode [int_nick_to_answer_mode $nick]
set nick_update_mode [int_nick_to_update_mode $nick]
set questions_counter [expr [llength $int_questions_list] - 1]
set action_time [clock seconds]
set nick_question_idx [lindex $int_global_questions_idx $nick_global_idx]
set nick_int_mode [int_nick_to_mode $nick]
if {$nick_int_mode == "setup"} {
if {$nick_answer_mode == 0} {
if {$int_bind(questions_start) == $arg} {
putnq "PRIVMSG $nick :[lindex $int_questions_list $nick_question_idx]"
int_switch_answer_mode $nick
}
} {
if {[lindex $int_global_questions_idx $nick_global_idx] < $questions_counter} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_incr_nick_idx $nick
int_answer_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
putnq "PRIVMSG $nick :[lindex $int_questions_list [expr $nick_question_idx + 1]]"
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_answer_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(int_end)"
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
}
}
} elseif {$nick_int_mode == "update"} {
set question_list [list]
set question_idx 1
foreach question $int_questions_list {
if {$question != ""} {
lappend question_list "$question_idx\) $question"
incr question_idx 1
}
}
set question_list [join $question_list ", "]
if {$nick_answer_mode == 0} {
if {[int_check_if_key_is_correct $nick $uhost $profile_name $arg] == 1} {
putnq "PRIVMSG $nick :$int_msg(update_welcome)"
putnq "PRIVMSG $nick :$int_msg(update_question_list) $question_list"
int_switch_answer_mode $nick
} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(update_wrong_key)"
}
} {
if {$nick_update_mode == 0} {
if {[regexp {^[0-9]+$} $arg]} {
if {($arg > 0) && ($arg <= [expr $questions_counter + 1])} {
putnq "PRIVMSG $nick :[lindex $int_questions_list [expr $arg - 1]]"
int_switch_update_mode $nick
int_set_nick_idx $nick [expr $arg - 1]
} {
putnq "PRIVMSG $nick :$int_msg(update_question_number_range)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_question_number)"
}
} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_update_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
putnq "PRIVMSG $nick :$int_msg(update_done)"
putnq "PRIVMSG $nick :$int_msg(update_question_list) $question_list"
int_switch_update_mode $nick
int_set_nick_idx $nick 0
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
}
}
} elseif {$nick_int_mode == "remove"} {
if {[int_check_if_key_is_correct $nick $uhost $profile_name $arg] == 1} {
int_nick_for_delete $nick
int_remove_profile_event $nick $uhost $profile_name $action_time
putnq "PRIVMSG $nick :$int_msg(remove_end)"
} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(remove_wrong_key)"
}
}
}
}
proc int_proc_sessions { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_questions_key int_global_modes int_global_update_mode
if {![channel get $chan intadd]} {
return
}
set sess_len [llength $int_global_nicks]
if {$sess_len > 0} {
putnq "PRIVMSG $nick :nick | uhost | profile | qidx | qkey | amode | imode | umode"
for {set i 0} {$i < $sess_len} {incr i 1} {
putnq "PRIVMSG $nick :[lindex $int_global_nicks $i] | [lindex $int_global_uhosts $i] | [lindex $int_global_pnames $i] | [lindex $int_global_questions_idx $i] | [lindex $int_questions_key [lindex $int_global_questions_idx $i]] | [lindex $int_global_answers_mode $i] | [lindex $int_global_modes $i] | [lindex $int_global_update_mode $i]"
}
} {
putnq "PRIVMSG $nick :$int_msg(sessions_list_empty)"
}
}
proc int_proc_flush { nick uhost hand chan arg } {
global int_global_nicks int_msg int_bind_regexp int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode
if {![channel get $chan intadd]} {
return
}
set nick_to_flush [lindex [split $arg] 0]
if {$nick_to_flush != ""} {
if {![regexp $int_bind_regexp $nick_to_flush]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[lsearch $int_global_nicks $nick_to_flush] > -1} {
int_nick_for_delete $nick_to_flush
putnq "PRIVMSG $nick :$int_msg(session_destroyed)"
} {
putnq "PRIVMSG $nick :$int_msg(session_n_exists)"
}
} {
set int_global_nicks [list]
set int_global_uhosts [list]
set int_global_pnames [list]
set int_global_questions_idx [list]
set int_global_answers_mode [list]
set int_global_modes [list]
set int_global_update_mode [list]
putnq "PRIVMSG $nick :$int_msg(all_sessions_destroyed)"
}
}
proc int_proc_part { nick uhost hand chan msg } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_sign { nick uhost hand chan msg } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_splt { nick uhost hand chan } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_kick { nick uhost hand chan target rsn } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $target] > -1} {
int_nick_for_delete $target
}
}
proc int_proc_nick { nick uhost hand chan newnick } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
set nick_global_idx [int_nick_to_idx $nick]
if {$nick_global_idx > -1} {
set int_global_nicks [lreplace $int_global_nicks $nick_global_idx $nick_global_idx $newnick]
}
}
putlog "interviewer-addon.tcl ver 0.1 by tomekk loaded"
# end of magic ;)
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.5
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# if you want to use commands from this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +intadd +profile
# and later .save
# variables and procedures:
# with profile_ prefix are from profile script
# with int_ prefix are from interviewer-addon
# bind for view procedure
# after this command bot will show the user profile
set profile_view_command "!view"
# bot for list procedure
# after this command bot will show the list of profile names
set profile_list_command "!list"
# bind for delete prcedure
# after this command bot will delete the profile (only for o|o)
# user can delete his profile by typing !remove (only when key will be correct)
set profile_drop_command "!delete"
# bind for help procedure
# after this command bot will show the available commands
set profile_help_command "!help"
# bind for setup procedure
# after this command bot will try to make a new profile and start the interview
set int_bind(setup) "!setup"
# bind for update procedure
# after this command user will be able to update his profile information
set int_bind(updatee) "!update"
# bind for remove procedure
# after this command bot will try to remove profile
set int_bind(delete) "!remove"
# bind for release procedure
# after this command bot will try to destroy user's session (something like logout)
set int_bind(release) "!release"
# bind for sessions procedure
# after this command bot will print current sessions list (only for o|o)
set int_bind(sessions) "!sessions"
# bind for flush procedure
# after this command bot will try to destroy all sessions or just one given session (only for o|o)
set int_bind(flussh) "!flush"
# dir with script data
set profile_script_dir "profiles.db"
# dir with keys
set profile_keys_dir "$profile_script_dir/keys"
# dir with profiles
set profile_profiles_dir "$profile_script_dir/profiles"
# dir with teasers
set profile_teasers_dir "$profile_script_dir/teasers"
# interviewer-addon script path
set interviewer_addon_path "scripts/interviewer-addon-0.1.tcl"
# regexp for !setup, !update, !remove, !flush commands (default, only small and BIG letters are allowed)
# in this script (profile-0.*.tcl), all profiles names are in 'lower case', but we have to allow big chars because someone can write !setup MyNiCk or something, otherwise script will make 'mynick' ;)
set int_bind_regexp {^[a-zA-Z]+$}
# all these five lists must have the same number of elements
# headers for !view
set profile_view_headers {
"&n location:"
"&n sex:"
"&n age:"
"&n description:"
"&n likes:"
"&n limits:"
}
# questions lists, one by one
set int_questions_list {
"your location ;>"
"your sex ;>"
"your age ;>"
"your description ;>"
"your likes ;>"
"your limits ;>"
}
# uniq key of each question
# some short uniq word, without spaces will be better
set int_questions_key {
"location"
"sex"
"age"
"desc"
"likes"
"limits"
}
# questions regexps, one by one
# if you don't know how to build regexp, use {.*} and pray (.* any chars ;p)
set int_questions_regexp {
{.*}
{^(male|female)$}
{^[0-9]{1,2}$}
{.*}
{.*}
{.*}
}
# questions help messages, one by one
set int_question_help {
""
"male or female"
"only numbers are allowed (0 - 99)"
""
""
""
}
# messages
set profile_help "available commands for every user: !setup, !update, !remove, !release, !view, !list"
set int_msg(int_start) "hey! Your profile has been created, get your key and type some info about yourself!"
set int_msg(int_key) "here is your key: &k, save it, you will need it later for update or delete your profile"
set int_msg(int_end) "thanks for the answers, bye!"
set int_msg(update_start) "hi, if you want to update your profile you have to type your profile key now (paste it here and press enter)"
set int_msg(update_welcome) "hi, your key is OK, we can update your profile now; I will print the questions list for you, choose one and answer! (type number of question and press enter)"
set int_msg(update_question_list) "here are the questions(to stop the interview mode use !release on chan):"
set int_msg(update_question_number) "only numbers are allowed here (1 or more)"
set int_msg(update_question_number_range) "please choose number from 1 to 6"
set int_msg(update_wrong_key) "you typed wrong key, if you want to try again, please use !update <profile_name> again"
set int_msg(update_done) "information has been updated"
set int_msg(remove_start) "hi, if you want to remove this profile you have to type your profile key now (paste it here and press enter)"
set int_msg(remove_end) "profile has been successfully removed"
set int_msg(remove_wrong_key) "you typed wrong key, if you want to try again, please use !remove <profile_name> again"
set int_msg(just_one_command) "you can use just one command in the same time, !setup, !update or !remove; use !release if you want to use setup, update or remove command again"
set int_msg(profile_exists) "profile with that name already exists"
set int_msg(profile_not_exists) "profile with that name doesn't exists"
set int_msg(setup_already_in_use) "you can't use this command twice in the same time"
set int_msg(update_already_in_use) "you can't use this command twice in the same time"
set int_msg(remove_already_in_use) "you can't use this command twice in the same time"
set int_msg(setup_profile_name_already_in_use) "someone is already making setup with that name"
set int_msg(update_profile_name_already_in_use) "someone is already making update with that name"
set int_msg(remove_profile_name_already_in_use) "someone is already trying to remove profile with that name"
set int_msg(all_sessions_destroyed) "all sessions have been destroyed"
set int_msg(session_destroyed) "session has been destroyed"
set int_msg(session_n_exists) "session for this user doesn't exists"
set int_msg(sessions_list_empty) "sessions list is empty ;)"
set int_msg(release_empty) "your session doesn't exists"
set int_msg(release_done) "your session has been destroyed, you can use !setup, !update or !remove again"
set int_msg(setup_help) "use: !setup <profile_name>"
set int_msg(update_help) "use: !update <profile_name>"
set int_msg(remove_help) "use: !remove <profile_name>"
set int_msg(bind_help) "only small and BIG letters are allowed, sorry"
# type of key generator
# 0 - use /dev/urandom (good for unix systems)
# 1 - use some rand() (use it for windows systems, of course it will work under unix too)
set int_random_generator 1
# which procedures bot should bind (default all)
# s - setup proc
# u - update proc
# d - remove proc
# r - release proc
# e - sessions proc
# f - flush proc
# p - private messages proc
# a - part proc
# i - sign proc
# l - split proc
# k - kick proc
# n - nick proc
set int_proc_bind "sudrefpailkn"
# autostart of 'questions', without any extra word
# 0 - disable, 1 - enable
set int_questions_auto_start 1
# bind for questions start
# after this command bot will start the interview (priv command, after !setup)
# works only when $int_questions_auto_start is set to 0
# but, even if you set $int_questions_auto_start to 1, please leave here some word
set int_bind(questions_start) "start"
################################################################################################################
bind pub -|- $profile_view_command profile_view_proc
bind pub -|- $profile_list_command profile_list_proc
bind pub -|- $profile_drop_command profile_drop_proc
bind pub -|- $profile_help_command profile_help_proc
setudef flag profile
if {![file exists $profile_script_dir]} {
file mkdir $profile_script_dir
}
if {![file exists $profile_profiles_dir]} {
file mkdir $profile_profiles_dir
}
if {![file exists $profile_teasers_dir]} {
file mkdir $profile_teasers_dir
}
if {![file exists $profile_keys_dir]} {
file mkdir $profile_keys_dir
}
proc profile_check_if_profile_exists { profile_name } {
global profile_profiles_dir
set profile_name [string tolower $profile_name]
set profile_exists 0
if {[file exists $profile_profiles_dir/$profile_name]} {
set profile_exists 1
}
return $profile_exists
}
proc profile_view_proc { nick uhost hand chan arg } {
global profile_profiles_dir profile_view_command profile_view_headers
if {![channel get $chan profile]} {
return
}
set profile_name [string tolower [lindex [split $arg] 0]]
if {$profile_name != ""} {
if {[file exists $profile_profiles_dir/$profile_name]} {
set get_profile_data [open $profile_profiles_dir/$profile_name r]
set all_profile_rows [split [read $get_profile_data] "\n"]
close $get_profile_data
set headers_counter [expr [llength $profile_view_headers] - 1]
for {set i 0} {$i <= $headers_counter} {incr i 1} {
set db_data [lindex $all_profile_rows $i]
set each_profile_header [lindex $profile_view_headers $i]
regsub -all "&n" $each_profile_header "$profile_name\'s" each_profile_header
if {$db_data != ""} {
putquick "PRIVMSG $nick :$each_profile_header $db_data"
} {
putquick "PRIVMSG $nick :$each_profile_header N/A"
}
}
} {
putquick "PRIVMSG $nick :profile $profile_name doesn't exists"
}
} {
putquick "PRIVMSG $nick :use: $profile_view_command <profile_name>"
}
}
proc profile_list_proc { nick uhost hand chan arg } {
global profile_profiles_dir
if {![channel get $chan profile]} {
return
}
set list_number [lindex [split $arg] 0]
if {$list_number != ""} {
switch -- $list_number {
"1" {
set af_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{a,b,c,d,e,f}*}]
if {$af_list != ""} {
putquick "PRIVMSG $nick :list from A to F: $af_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"2" {
set gl_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{g,h,i,j,k,l}*}]
if {$gl_list != ""} {
putquick "PRIVMSG $nick :list from G to L: $gl_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"3" {
set mr_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{m,n,o,p,q,r}*}]
if {$mr_list != ""} {
putquick "PRIVMSG $nick :list from M to R: $mr_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"4" {
set sz_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{s,t,u,v,w,x,y,z}*}]
if {$sz_list != ""} {
putquick "PRIVMSG $nick :list from S to Z: $sz_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
}
} {
putquick "PRIVMSG $nick :use: !list 1 (A->F) / !list 2 (G->L) / !list 3 (M->R) / list 4 (S-Z)"
}
}
proc profile_delete_proc { profile_name } {
global profile_profiles_dir profile_keys_dir profile_teasers_dir
set profile_name [string tolower $profile_name]
set user_profile_file "$profile_profiles_dir/$profile_name"
set user_key_file "$profile_keys_dir/$profile_name"
set user_teaser_file "$profile_teasers_dir/$profile_name"
if {[file exists $user_profile_file]} {
file delete $user_profile_file
}
if {[file exists $user_key_file]} {
file delete $user_key_file
}
if {[file exists $user_teaser_file]} {
file delete $user_teaser_file
}
}
proc profile_drop_proc { nick uhost hand chan arg } {
global profile_profiles_dir profile_drop_command
if {![channel get $chan profile]} {
return
}
if {$arg != ""} {
foreach profile_name [split $arg] {
set profile_name [string tolower $profile_name]
if {$profile_name != ""} {
if {[file exists $profile_profiles_dir/$profile_name]} {
profile_delete_proc $profile_name
putquick "PRIVMSG $nick :profile $profile_name has been deleted"
} {
putquick "PRIVMSG $nick :profile $profile_name doesn't exists"
}
}
}
} {
putquick "PRIVMSG $nick :use: $profile_drop_command <profile_name> ... <profile_name>"
}
}
proc profile_help_proc { nick uhost hand chan arg } {
global profile_help
if {![channel get $chan profile]} {
return
}
putquick "PRIVMSG $nick :$profile_help"
}
proc int_check_if_profile_exists { nick uhost profile_name chan } {
set profile_name [string tolower $profile_name]
if {[profile_check_if_profile_exists $profile_name] == 1} {
return 1
} {
return 0
}
}
proc int_check_if_key_is_correct { nick uhost profile_name profile_key } {
global profile_keys_dir
set profile_name [string tolower $profile_name]
set db_profile_key ""
set get_profile_key [open $profile_keys_dir/$profile_name r]
gets $get_profile_key db_profile_key
close $get_profile_key
if {$db_profile_key == [md5 $profile_key]} {
return 1
} {
return 0
}
}
proc int_remove_profile_event { nick uhost profile_name action_time } {
profile_delete_proc $profile_name
}
proc int_new_profile_event { nick uhost chan profile_name profile_key action_time} {
global profile_profiles_dir profile_keys_dir
set profile_name [string tolower $profile_name]
set create_new_profile [open $profile_profiles_dir/$profile_name w]
close $create_new_profile
set create_profile_key [open $profile_keys_dir/$profile_name w]
puts $create_profile_key [md5 $profile_key]
close $create_profile_key
}
proc int_answer_event { nick uhost profile_name arg action_time question_key } {
global profile_profiles_dir
set profile_name [string tolower $profile_name]
set add_entry_to_profile [open $profile_profiles_dir/$profile_name a]
puts $add_entry_to_profile $arg
close $add_entry_to_profile
}
proc int_update_event { nick uhost profile_name arg action_time question_key } {
global profile_profiles_dir int_questions_key
set profile_name [string tolower $profile_name]
set question_idx [lsearch $int_questions_key $question_key]
set load_profile [open $profile_profiles_dir/$profile_name r]
set get_whole_profile [split [read $load_profile] "\n"]
close $load_profile
set keys_counter [expr [llength $int_questions_key] - 1]
set update_profile [open $profile_profiles_dir/$profile_name w]
for {set i 0} {$i <= $keys_counter} {incr i 1} {
set each_profile_line [lindex $get_whole_profile $i]
if {$question_idx != $i} {
if {$each_profile_line != ""} {
puts $update_profile $each_profile_line
} {
puts $update_profile "N/A"
}
} {
puts $update_profile $arg
}
}
close $update_profile
}
source $interviewer_addon_path
putlog "profile.tcl ver 0.5 by tomekk loaded"
Code: Select all
proc int_proc_setup { nick uhost hand chan arg } {
Code: Select all
set profile_name [lindex [split $arg] 0]
Code: Select all
set profile_name $nick
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.5birth
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# custom mod of profile-0.5.tcl script
# if you want to use commands from this script on your chan, type in eggdrop console (via telnet or DCC chat)
# .chanset #channel_name +intadd +profile
# and later .save
# variables and procedures:
# with profile_ prefix are from profile script
# with int_ prefix are from interviewer-addon
# bind for view procedure
# after this command bot will show the user profile
set profile_view_command "!view"
# bot for list procedure
# after this command bot will show the list of profile names
set profile_list_command "!list"
# bind for delete prcedure
# after this command bot will delete the profile (only for o|o)
# user can delete his profile by typing !remove (only when key will be correct)
set profile_drop_command "!delete"
# bind for help procedure
# after this command bot will show the available commands
set profile_help_command "!help"
# bind for setup procedure
# after this command bot will try to make a new profile and start the interview
set int_bind(setup) "!setup"
# bind for update procedure
# after this command user will be able to update his profile information
set int_bind(updatee) "!update"
# bind for remove procedure
# after this command bot will try to remove profile
set int_bind(delete) "!remove"
# bind for release procedure
# after this command bot will try to destroy user's session (something like logout)
set int_bind(release) "!release"
# bind for sessions procedure
# after this command bot will print current sessions list (only for o|o)
set int_bind(sessions) "!sessions"
# bind for flush procedure
# after this command bot will try to destroy all sessions or just one given session (only for o|o)
set int_bind(flussh) "!flush"
# bind for birthday date checks
# 0 - disable
# 1 - enable, bot sohuld checks dates every day
set profile_birth_checks 1
# if profile_birth_checks is set to 1,
# you can set here on which hour/minute bot will check the birth dates (hour in 24clock format, hours/minutes in format like: 02, 03, 04, 11, 22 etc)
set profile_birth_hour 10
set profile_birth_minute 05
# birthday entry position in profile datafile
# default 3rd position, after 'from' and 'sex' fields
set profile_birth_file_pos 3
# dir with script data
set profile_script_dir "profiles.db"
# dir with keys
set profile_keys_dir "$profile_script_dir/keys"
# dir with profiles
set profile_profiles_dir "$profile_script_dir/profiles"
# dir with teasers
set profile_teasers_dir "$profile_script_dir/teasers"
# interviewer-addon script path
set interviewer_addon_path "scripts/interviewer-addon-0.1.tcl"
# regexp for !setup, !update, !remove, !flush commands (default, only small and BIG letters are allowed)
# in this script (profile-0.*.tcl), all profiles names are in 'lower case', but we have to allow big chars because someone can write !setup MyNiCk or something, otherwise script will make 'mynick' ;)
set int_bind_regexp {^[a-zA-Z]+$}
# all these five lists must have the same number of elements
# headers for !view
set profile_view_headers {
"&n location:"
"&n sex:"
"&n birthday:"
"&n description:"
"&n likes:"
"&n limits:"
}
# questions lists, one by one
set int_questions_list {
"your location ;>"
"your sex ;>"
"your birthday date ;>"
"your description ;>"
"your likes ;>"
"your limits ;>"
}
# uniq key of each question
# some short uniq word, without spaces will be better
set int_questions_key {
"location"
"sex"
"birth"
"desc"
"likes"
"limits"
}
# questions regexps, one by one
# if you don't know how to build regexp, use {.*} and pray (.* any chars ;p)
set int_questions_regexp {
{.*}
{^(male|female)$}
{^[0-9]{2}\-[0-9]{2}\-[0-9]{4}$}
{.*}
{.*}
{.*}
}
# questions help messages, one by one
set int_question_help {
""
"male or female"
"only date in format MM-DD-YYYY is allowed, examples: 12-30-1980, 02-03-1975, etc."
""
""
""
}
# messages
set profile_help "available commands for every user: !setup, !update, !remove, !release, !view, !list"
set int_msg(int_start) "hey! Your profile has been created, get your key and type some info about yourself!"
set int_msg(int_key) "here is your key: &k, save it, you will need it later for update or delete your profile"
set int_msg(int_end) "thanks for the answers, bye!"
set int_msg(update_start) "hi, if you want to update your profile you have to type your profile key now (paste it here and press enter)"
set int_msg(update_welcome) "hi, your key is OK, we can update your profile now; I will print the questions list for you, choose one and answer! (type number of question and press enter)"
set int_msg(update_question_list) "here are the questions(to stop the interview mode use !release on chan):"
set int_msg(update_question_number) "only numbers are allowed here (1 or more)"
set int_msg(update_question_number_range) "please choose number from 1 to 6"
set int_msg(update_wrong_key) "you typed wrong key, if you want to try again, please use !update <profile_name> again"
set int_msg(update_done) "information has been updated"
set int_msg(remove_start) "hi, if you want to remove this profile you have to type your profile key now (paste it here and press enter)"
set int_msg(remove_end) "profile has been successfully removed"
set int_msg(remove_wrong_key) "you typed wrong key, if you want to try again, please use !remove <profile_name> again"
set int_msg(just_one_command) "you can use just one command in the same time, !setup, !update or !remove; use !release if you want to use setup, update or remove command again"
set int_msg(profile_exists) "profile with that name already exists"
set int_msg(profile_not_exists) "profile with that name doesn't exists"
set int_msg(setup_already_in_use) "you can't use this command twice in the same time"
set int_msg(update_already_in_use) "you can't use this command twice in the same time"
set int_msg(remove_already_in_use) "you can't use this command twice in the same time"
set int_msg(setup_profile_name_already_in_use) "someone is already making setup with that name"
set int_msg(update_profile_name_already_in_use) "someone is already making update with that name"
set int_msg(remove_profile_name_already_in_use) "someone is already trying to remove profile with that name"
set int_msg(all_sessions_destroyed) "all sessions have been destroyed"
set int_msg(session_destroyed) "session has been destroyed"
set int_msg(session_n_exists) "session for this user doesn't exists"
set int_msg(sessions_list_empty) "sessions list is empty ;)"
set int_msg(release_empty) "your session doesn't exists"
set int_msg(release_done) "your session has been destroyed, you can use !setup, !update or !remove again"
set int_msg(setup_help) "use: !setup <profile_name>"
set int_msg(update_help) "use: !update <profile_name>"
set int_msg(remove_help) "use: !remove <profile_name>"
set int_msg(bind_help) "only small and BIG letters are allowed, sorry"
# type of key generator
# 0 - use /dev/urandom (good for unix systems)
# 1 - use some rand() (use it for windows systems, of course it will work under unix too)
set int_random_generator 1
# which procedures bot should bind (default all)
# s - setup proc
# u - update proc
# d - remove proc
# r - release proc
# e - sessions proc
# f - flush proc
# p - private messages proc
# a - part proc
# i - sign proc
# l - split proc
# k - kick proc
# n - nick proc
set int_proc_bind "sudrefpailkn"
# autostart of 'questions', without any extra word
# 0 - disable, 1 - enable
set int_questions_auto_start 1
# bind for questions start
# after this command bot will start the interview (priv command, after !setup)
# works only when $int_questions_auto_start is set to 0
# but, even if you set $int_questions_auto_start to 1, please leave here some word
set int_bind(questions_start) "start"
################################################################################################################
bind pub -|- $profile_view_command profile_view_proc
bind pub -|- $profile_list_command profile_list_proc
bind pub -|- $profile_drop_command profile_drop_proc
bind pub -|- $profile_help_command profile_help_proc
if {$profile_birth_checks == 1} {
bind time - "$profile_birth_minute $profile_birth_hour * * *" profile_check_birthday
}
setudef flag profile
if {![file exists $profile_script_dir]} {
file mkdir $profile_script_dir
}
if {![file exists $profile_profiles_dir]} {
file mkdir $profile_profiles_dir
}
if {![file exists $profile_teasers_dir]} {
file mkdir $profile_teasers_dir
}
if {![file exists $profile_keys_dir]} {
file mkdir $profile_keys_dir
}
proc profile_check_if_profile_exists { profile_name } {
global profile_profiles_dir
set profile_name [string tolower $profile_name]
set profile_exists 0
if {[file exists $profile_profiles_dir/$profile_name]} {
set profile_exists 1
}
return $profile_exists
}
proc profile_view_proc { nick uhost hand chan arg } {
global profile_profiles_dir profile_view_command profile_view_headers
if {![channel get $chan profile]} {
return
}
set profile_name [string tolower [lindex [split $arg] 0]]
if {$profile_name != ""} {
if {[file exists $profile_profiles_dir/$profile_name]} {
set get_profile_data [open $profile_profiles_dir/$profile_name r]
set all_profile_rows [split [read $get_profile_data] "\n"]
close $get_profile_data
set headers_counter [expr [llength $profile_view_headers] - 1]
for {set i 0} {$i <= $headers_counter} {incr i 1} {
set db_data [lindex $all_profile_rows $i]
set each_profile_header [lindex $profile_view_headers $i]
regsub -all "&n" $each_profile_header "$profile_name\'s" each_profile_header
if {$db_data != ""} {
putquick "PRIVMSG $nick :$each_profile_header $db_data"
} {
putquick "PRIVMSG $nick :$each_profile_header N/A"
}
}
} {
putquick "PRIVMSG $nick :profile $profile_name doesn't exists"
}
} {
putquick "PRIVMSG $nick :use: $profile_view_command <profile_name>"
}
}
proc profile_list_proc { nick uhost hand chan arg } {
global profile_profiles_dir
if {![channel get $chan profile]} {
return
}
set list_number [lindex [split $arg] 0]
if {$list_number != ""} {
switch -- $list_number {
"1" {
set af_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{a,b,c,d,e,f}*}]
if {$af_list != ""} {
putquick "PRIVMSG $nick :list from A to F: $af_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"2" {
set gl_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{g,h,i,j,k,l}*}]
if {$gl_list != ""} {
putquick "PRIVMSG $nick :list from G to L: $gl_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"3" {
set mr_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{m,n,o,p,q,r}*}]
if {$mr_list != ""} {
putquick "PRIVMSG $nick :list from M to R: $mr_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
"4" {
set sz_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f {{s,t,u,v,w,x,y,z}*}]
if {$sz_list != ""} {
putquick "PRIVMSG $nick :list from S to Z: $sz_list"
} {
putquick "PRIVMSG $nick :list is empty"
}
}
}
} {
putquick "PRIVMSG $nick :use: !list 1 (A->F) / !list 2 (G->L) / !list 3 (M->R) / list 4 (S-Z)"
}
}
proc profile_delete_proc { profile_name } {
global profile_profiles_dir profile_keys_dir profile_teasers_dir
set profile_name [string tolower $profile_name]
set user_profile_file "$profile_profiles_dir/$profile_name"
set user_key_file "$profile_keys_dir/$profile_name"
set user_teaser_file "$profile_teasers_dir/$profile_name"
if {[file exists $user_profile_file]} {
file delete $user_profile_file
}
if {[file exists $user_key_file]} {
file delete $user_key_file
}
if {[file exists $user_teaser_file]} {
file delete $user_teaser_file
}
}
proc profile_drop_proc { nick uhost hand chan arg } {
global profile_profiles_dir profile_drop_command
if {![channel get $chan profile]} {
return
}
if {$arg != ""} {
foreach profile_name [split $arg] {
set profile_name [string tolower $profile_name]
if {$profile_name != ""} {
if {[file exists $profile_profiles_dir/$profile_name]} {
profile_delete_proc $profile_name
putquick "PRIVMSG $nick :profile $profile_name has been deleted"
} {
putquick "PRIVMSG $nick :profile $profile_name doesn't exists"
}
}
}
} {
putquick "PRIVMSG $nick :use: $profile_drop_command <profile_name> ... <profile_name>"
}
}
proc profile_help_proc { nick uhost hand chan arg } {
global profile_help
if {![channel get $chan profile]} {
return
}
putquick "PRIVMSG $nick :$profile_help"
}
proc int_check_if_profile_exists { nick uhost profile_name chan } {
set profile_name [string tolower $profile_name]
if {[profile_check_if_profile_exists $profile_name] == 1} {
return 1
} {
return 0
}
}
proc int_check_if_key_is_correct { nick uhost profile_name profile_key } {
global profile_keys_dir
set profile_name [string tolower $profile_name]
set db_profile_key ""
set get_profile_key [open $profile_keys_dir/$profile_name r]
gets $get_profile_key db_profile_key
close $get_profile_key
if {$db_profile_key == [md5 $profile_key]} {
return 1
} {
return 0
}
}
proc int_remove_profile_event { nick uhost profile_name action_time } {
profile_delete_proc $profile_name
}
proc int_new_profile_event { nick uhost chan profile_name profile_key action_time} {
global profile_profiles_dir profile_keys_dir
set profile_name [string tolower $profile_name]
set create_new_profile [open $profile_profiles_dir/$profile_name w]
close $create_new_profile
set create_profile_key [open $profile_keys_dir/$profile_name w]
puts $create_profile_key [md5 $profile_key]
close $create_profile_key
}
proc int_answer_event { nick uhost profile_name arg action_time question_key } {
global profile_profiles_dir
set profile_name [string tolower $profile_name]
set add_entry_to_profile [open $profile_profiles_dir/$profile_name a]
puts $add_entry_to_profile $arg
close $add_entry_to_profile
}
proc int_update_event { nick uhost profile_name arg action_time question_key } {
global profile_profiles_dir int_questions_key
set profile_name [string tolower $profile_name]
set question_idx [lsearch $int_questions_key $question_key]
set load_profile [open $profile_profiles_dir/$profile_name r]
set get_whole_profile [split [read $load_profile] "\n"]
close $load_profile
set keys_counter [expr [llength $int_questions_key] - 1]
set update_profile [open $profile_profiles_dir/$profile_name w]
for {set i 0} {$i <= $keys_counter} {incr i 1} {
set each_profile_line [lindex $get_whole_profile $i]
if {$question_idx != $i} {
if {$each_profile_line != ""} {
puts $update_profile $each_profile_line
} {
puts $update_profile "N/A"
}
} {
puts $update_profile $arg
}
}
close $update_profile
}
proc profile_check_birthday { min hour day month year } {
global profile_profiles_dir profile_birth_file_pos
set output_channel_list [list]
foreach bot_channel [channels] {
if {$bot_channel != ""} {
if {[botonchan $bot_channel]} {
if {[channel get $bot_channel profile]} {
lappend output_channel_list $bot_channel
}
}
}
}
set all_profile_list [glob -tails -directory $profile_profiles_dir -nocomplain -type f *]
foreach profile $all_profile_list {
if {$profile != ""} {
set profile_handle [open $profile_profiles_dir/$profile r]
set profile_data [read $profile_handle]
close $profile_handle
set need_just_birthday [lindex [split $profile_data "\n"] [expr $profile_birth_file_pos - 1]]
if {$need_just_birthday != ""} {
set split_the_date [split $need_just_birthday "-"]
set birth_month [lindex $split_the_date 0]
set birth_day [lindex $split_the_date 1]
set birth_year [lindex $split_the_date 2]
set current_clock_seconds [clock seconds]
set current_clock_month [clock format $current_clock_seconds -format %m]
set current_clock_day [clock format $current_clock_seconds -format %d]
set current_clock_year [clock format $current_clock_seconds -format %Y]
if {($birth_month == $current_clock_month) && ($birth_day == $current_clock_day)} {
foreach output_channel $output_channel_list {
putquick "PRIVMSG $output_channel :$profile birthday is today and he/she is [expr $current_clock_year - $birth_year]"
}
}
}
}
}
}
source $interviewer_addon_path
putlog "profile.tcl ver 0.5birth by tomekk loaded"
Code: Select all
# bind for birthday date checks
# 0 - disable
# 1 - enable, bot sohuld checks dates every day
set profile_birth_checks 1
# if profile_birth_checks is set to 1,
# you can set here on which hour/minute bot will check the birth dates (hour in 24clock format, hours/minutes in format like: 02, 03, 04, 11, 22 etc)
set profile_birth_hour 10
set profile_birth_minute 05
# birthday entry position in profile datafile
# default 3rd position, after 'from' and 'sex' fields
set profile_birth_file_pos 3
Code: Select all
<Chasse> [15:51] Tcl error in file 'eggdrop.conf':
<Chasse> [15:51] can't read "int_proc_bind": no such variable
<Chasse> while executing
<Chasse> "string match "*s*" $int_proc_bind"
<Chasse> invoked from within
<Chasse> "if {[string match "*s*" $int_proc_bind]} {
<Chasse> bind pub -|- $int_bind(setup) int_proc_setup
<Chasse> } "
<Chasse> (file "scripts/interviewer-addon-0.1.tcl" line 14)
<Chasse> invoked from within
<Chasse> "source scripts/interviewer-addon-0.1.tcl"
<Chasse> (file "eggdrop.conf" line 1337)
<Chasse> [15:51] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
Code: Select all
set interviewer_addon_path "scripts/interviewer-addon-0.1.tcl"
Code: Select all
<Chasse> [19:21] Tcl error [int_proc_setup]: invalid character "\"
<Chasse> in expression "...nicks $nick] > -1) && \
<Chasse> ([lsearch $int..."
Code: Select all
<Nor7on> .set errorInfo
<Chasse> Currently: invalid character "\"
<Chasse> Currently: in expression "...nicks $nick] > -1) && \
<Chasse> Currently: ([lsearch $int..."
<Chasse> Currently: (parsing expression "([lsearch $int_global_...")
<Chasse> Currently: invoked from within
<Chasse> Currently: "if {([lsearch $int_global_nicks $nick] > -1) && \
<Chasse> Currently: ([lsearch $int_global_uhosts $uhost] > -1)} {
<Chasse> Currently: set new_n_u_state 1
<Chasse> Currently: } "
<Chasse> Currently: (procedure "int_check_global_n_u" line 6)
<Chasse> Currently: invoked from within
<Chasse> Currently: "int_check_global_n_u $nick $uhost"
<Chasse> Currently: (procedure "int_proc_setup" line 18)
<Chasse> Currently: invoked from within
<Chasse> Currently: "int_proc_setup $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# config header and procs moved to profile-0.*.tcl
################################ high wizardry begins ######################################
############################################################################################
if {[string match "*s*" $int_proc_bind]} {
bind pub -|- $int_bind(setup) int_proc_setup
}
if {[string match "*u*" $int_proc_bind]} {
bind pub -|- $int_bind(updatee) int_proc_update
}
if {[string match "*d*" $int_proc_bind]} {
bind pub -|- $int_bind(delete) int_proc_remove
}
if {[string match "*r*" $int_proc_bind]} {
bind pub -|- $int_bind(release) int_proc_release
}
if {[string match "*e*" $int_proc_bind]} {
bind pub o|o $int_bind(sessions) int_proc_sessions
}
if {[string match "*f*" $int_proc_bind]} {
bind pub o|o $int_bind(flussh) int_proc_flush
}
if {[string match "*p*" $int_proc_bind]} {
bind msgm -|- "*" int_proc_msgm
}
if {[string match "*a*" $int_proc_bind]} {
bind part -|- "*" int_proc_part
}
if {[string match "*i*" $int_proc_bind]} {
bind sign -|- "*" int_proc_sign
}
if {[string match "*l*" $int_proc_bind]} {
bind splt -|- "*" int_proc_splt
}
if {[string match "*k*" $int_proc_bind]} {
bind kick -|- "*" int_proc_kick
}
if {[string match "*n*" $int_proc_bind]} {
bind nick -|- "*" int_proc_nick
}
setudef flag intadd
set int_global_nicks [list]
set int_global_uhosts [list]
set int_global_pnames [list]
set int_global_questions_idx [list]
set int_global_answers_mode [list]
set int_global_modes [list]
set int_global_update_mode [list]
proc putnq { data } {
putdccraw 0 [string length "$data\n"] "$data\n"
}
proc int_check_global_n_u { nick uhost } {
global int_global_nicks int_global_uhosts
set new_n_u_state 0
if {([lsearch $int_global_nicks $nick] > -1) && ([lsearch $int_global_uhosts $uhost] > -1)} {
set new_n_u_state 1
}
return $new_n_u_state
}
proc int_check_global_pn { profile_name } {
global int_global_pnames
set new_pn_state 0
if {[lsearch $int_global_pnames $profile_name] > -1} {
set new_pn_state 1
}
return $new_pn_state
}
proc int_nick_to_profile { nick } {
global int_global_nicks int_global_pnames
set profile_name ""
set nick_idx [lsearch $int_global_nicks $nick]
set profile_name [lindex $int_global_pnames $nick_idx]
return $profile_name
}
proc int_nick_to_idx { nick } {
global int_global_nicks
set nick_idx [lsearch $int_global_nicks $nick]
return $nick_idx
}
proc int_nick_to_answer_mode { nick } {
global int_global_answers_mode
set nick_answer_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_answer_mode [lindex $int_global_answers_mode $nick_global_idx]
return $nick_answer_mode
}
proc int_nick_to_update_mode { nick } {
global int_global_update_mode
set nick_update_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_update_mode [lindex $int_global_update_mode $nick_global_idx]
return $nick_update_mode
}
proc int_nick_to_mode { nick } {
global int_global_modes
set nick_int_mode ""
set nick_global_idx [int_nick_to_idx $nick]
set nick_int_mode [lindex $int_global_modes $nick_global_idx]
return $nick_int_mode
}
proc int_switch_answer_mode { nick } {
global int_global_answers_mode
set nick_global_idx [int_nick_to_idx $nick]
set user_answer_mode [lindex $int_global_answers_mode $nick_global_idx]
if {$user_answer_mode == 0} {
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx 1]
} {
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx 0]
}
}
proc int_switch_update_mode { nick } {
global int_global_update_mode
set nick_global_idx [int_nick_to_idx $nick]
set user_update_mode [lindex $int_global_update_mode $nick_global_idx]
if {$user_update_mode == 0} {
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx 1]
} {
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx 0]
}
}
proc int_incr_nick_idx { nick } {
global int_global_questions_idx
set nick_global_idx [int_nick_to_idx $nick]
set nick_question_idx [expr [lindex $int_global_questions_idx $nick_global_idx] + 1]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx $nick_question_idx]
}
proc int_set_nick_idx { nick new_idx } {
global int_global_questions_idx
set nick_global_idx [int_nick_to_idx $nick]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx $new_idx]
}
proc int_nick_for_delete { nick } {
global int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode
set nick_global_idx [int_nick_to_idx $nick]
set int_global_nicks [lreplace $int_global_nicks $nick_global_idx $nick_global_idx]
set int_global_uhosts [lreplace $int_global_uhosts $nick_global_idx $nick_global_idx]
set int_global_pnames [lreplace $int_global_pnames $nick_global_idx $nick_global_idx]
set int_global_questions_idx [lreplace $int_global_questions_idx $nick_global_idx $nick_global_idx]
set int_global_answers_mode [lreplace $int_global_answers_mode $nick_global_idx $nick_global_idx]
set int_global_modes [lreplace $int_global_modes $nick_global_idx $nick_global_idx]
set int_global_update_mode [lreplace $int_global_update_mode $nick_global_idx $nick_global_idx]
}
proc int_proc_setup { nick uhost hand chan arg } {
global int_bind int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp int_questions_auto_start int_random_generator int_questions_list
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 0} {
if {([int_nick_to_mode $nick] != "update") && ([int_nick_to_mode $nick] != "remove")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "setup"
lappend int_global_update_mode 0
if {$int_random_generator == 0} {
set open_dev [open "/dev/urandom" r]
set get_bytes [read $open_dev 16]
close $open_dev
} {
set some_numbers [expr floor(rand() * [clock seconds])]
set some_string [lindex $int_questions_list [rand [llength $int_questions_list]]]
set some_char [string index $some_string [expr [rand [string length $some_string]] - 1]]
set get_bytes "$some_numbers $some_char"
}
set md5_key [md5 $get_bytes]
set action_time [clock seconds]
int_new_profile_event $nick $uhost $chan $profile_name $md5_key $action_time
set key_msg $int_msg(int_key)
regsub -all "&k" $key_msg $md5_key key_msg
putnq "PRIVMSG $nick :$int_msg(int_start)"
putnq "PRIVMSG $nick :$key_msg"
if {$int_questions_auto_start == 1} {
int_proc_msgm $nick $uhost $hand $int_bind(questions_start)
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(setup_help)"
}
}
proc int_proc_update { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 1} {
if {([int_nick_to_mode $nick] != "setup") && ([int_nick_to_mode $nick] != "remove")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "update"
lappend int_global_update_mode 0
putnq "PRIVMSG $nick :$int_msg(update_start)"
} {
putnq "PRIVMSG $nick :$int_msg(update_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_not_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_help)"
}
}
proc int_proc_remove { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode int_bind_regexp
if {![channel get $chan intadd]} {
return
}
set profile_name [lindex [split $arg] 0]
if {$profile_name != ""} {
if {![regexp $int_bind_regexp $profile_name]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[int_check_if_profile_exists $nick $uhost $profile_name $chan] == 1} {
if {([int_nick_to_mode $nick] != "setup") && ([int_nick_to_mode $nick] != "update")} {
if {[int_check_global_n_u $nick $uhost] == 0} {
if {[int_check_global_pn $profile_name] == 0} {
lappend int_global_nicks $nick
lappend int_global_uhosts $uhost
lappend int_global_pnames $profile_name
lappend int_global_questions_idx 0
lappend int_global_answers_mode 0
lappend int_global_modes "remove"
lappend int_global_update_mode 0
putnq "PRIVMSG $nick :$int_msg(remove_start)"
} {
putnq "PRIVMSG $nick :$int_msg(remove_profile_name_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(remove_already_in_use)"
}
} {
putnq "PRIVMSG $nick :$int_msg(just_one_command)"
}
} {
putnq "PRIVMSG $nick :$int_msg(profile_not_exists)"
}
} {
putnq "PRIVMSG $nick :$int_msg(remove_help)"
}
}
proc int_proc_release { nick uhost hand chan arg } {
global int_global_nicks int_msg
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(release_done)"
} {
putnq "PRIVMSG $nick :$int_msg(release_empty)"
}
}
proc int_proc_msgm { nick uhost hand arg } {
global int_bind int_msg int_questions_list int_global_questions_idx int_questions_key int_questions_regexp int_question_help
set arg [string trim $arg]
if {[int_check_global_n_u $nick $uhost] == 1} {
set profile_name [int_nick_to_profile $nick]
set nick_global_idx [int_nick_to_idx $nick]
set nick_answer_mode [int_nick_to_answer_mode $nick]
set nick_update_mode [int_nick_to_update_mode $nick]
set questions_counter [expr [llength $int_questions_list] - 1]
set action_time [clock seconds]
set nick_question_idx [lindex $int_global_questions_idx $nick_global_idx]
set nick_int_mode [int_nick_to_mode $nick]
if {$nick_int_mode == "setup"} {
if {$nick_answer_mode == 0} {
if {$int_bind(questions_start) == $arg} {
putnq "PRIVMSG $nick :[lindex $int_questions_list $nick_question_idx]"
int_switch_answer_mode $nick
}
} {
if {[lindex $int_global_questions_idx $nick_global_idx] < $questions_counter} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_incr_nick_idx $nick
int_answer_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
putnq "PRIVMSG $nick :[lindex $int_questions_list [expr $nick_question_idx + 1]]"
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_answer_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(int_end)"
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
}
}
} elseif {$nick_int_mode == "update"} {
set question_list [list]
set question_idx 1
foreach question $int_questions_list {
if {$question != ""} {
lappend question_list "$question_idx\) $question"
incr question_idx 1
}
}
set question_list [join $question_list ", "]
if {$nick_answer_mode == 0} {
if {[int_check_if_key_is_correct $nick $uhost $profile_name $arg] == 1} {
putnq "PRIVMSG $nick :$int_msg(update_welcome)"
putnq "PRIVMSG $nick :$int_msg(update_question_list) $question_list"
int_switch_answer_mode $nick
} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(update_wrong_key)"
}
} {
if {$nick_update_mode == 0} {
if {[regexp {^[0-9]+$} $arg]} {
if {($arg > 0) && ($arg <= [expr $questions_counter + 1])} {
putnq "PRIVMSG $nick :[lindex $int_questions_list [expr $arg - 1]]"
int_switch_update_mode $nick
int_set_nick_idx $nick [expr $arg - 1]
} {
putnq "PRIVMSG $nick :$int_msg(update_question_number_range)"
}
} {
putnq "PRIVMSG $nick :$int_msg(update_question_number)"
}
} {
if {[regexp [lindex $int_questions_regexp $nick_question_idx] $arg]} {
int_update_event $nick $uhost $profile_name $arg $action_time [lindex $int_questions_key $nick_question_idx]
putnq "PRIVMSG $nick :$int_msg(update_done)"
putnq "PRIVMSG $nick :$int_msg(update_question_list) $question_list"
int_switch_update_mode $nick
int_set_nick_idx $nick 0
} {
putnq "PRIVMSG $nick :[lindex $int_question_help $nick_question_idx]"
}
}
}
} elseif {$nick_int_mode == "remove"} {
if {[int_check_if_key_is_correct $nick $uhost $profile_name $arg] == 1} {
int_nick_for_delete $nick
int_remove_profile_event $nick $uhost $profile_name $action_time
putnq "PRIVMSG $nick :$int_msg(remove_end)"
} {
int_nick_for_delete $nick
putnq "PRIVMSG $nick :$int_msg(remove_wrong_key)"
}
}
}
}
proc int_proc_sessions { nick uhost hand chan arg } {
global int_msg int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_questions_key int_global_modes int_global_update_mode
if {![channel get $chan intadd]} {
return
}
set sess_len [llength $int_global_nicks]
if {$sess_len > 0} {
putnq "PRIVMSG $nick :nick | uhost | profile | qidx | qkey | amode | imode | umode"
for {set i 0} {$i < $sess_len} {incr i 1} {
putnq "PRIVMSG $nick :[lindex $int_global_nicks $i] | [lindex $int_global_uhosts $i] | [lindex $int_global_pnames $i] | [lindex $int_global_questions_idx $i] | [lindex $int_questions_key [lindex $int_global_questions_idx $i]] | [lindex $int_global_answers_mode $i] | [lindex $int_global_modes $i] | [lindex $int_global_update_mode $i]"
}
} {
putnq "PRIVMSG $nick :$int_msg(sessions_list_empty)"
}
}
proc int_proc_flush { nick uhost hand chan arg } {
global int_global_nicks int_msg int_bind_regexp int_global_nicks int_global_uhosts int_global_pnames int_global_questions_idx int_global_answers_mode int_global_modes int_global_update_mode
if {![channel get $chan intadd]} {
return
}
set nick_to_flush [lindex [split $arg] 0]
if {$nick_to_flush != ""} {
if {![regexp $int_bind_regexp $nick_to_flush]} {
putnq "PRIVMSG $nick :$int_msg(bind_help)"
return
}
if {[lsearch $int_global_nicks $nick_to_flush] > -1} {
int_nick_for_delete $nick_to_flush
putnq "PRIVMSG $nick :$int_msg(session_destroyed)"
} {
putnq "PRIVMSG $nick :$int_msg(session_n_exists)"
}
} {
set int_global_nicks [list]
set int_global_uhosts [list]
set int_global_pnames [list]
set int_global_questions_idx [list]
set int_global_answers_mode [list]
set int_global_modes [list]
set int_global_update_mode [list]
putnq "PRIVMSG $nick :$int_msg(all_sessions_destroyed)"
}
}
proc int_proc_part { nick uhost hand chan msg } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_sign { nick uhost hand chan msg } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_splt { nick uhost hand chan } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $nick] > -1} {
int_nick_for_delete $nick
}
}
proc int_proc_kick { nick uhost hand chan target rsn } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
if {[lsearch $int_global_nicks $target] > -1} {
int_nick_for_delete $target
}
}
proc int_proc_nick { nick uhost hand chan newnick } {
global int_global_nicks
if {![channel get $chan intadd]} {
return
}
set nick_global_idx [int_nick_to_idx $nick]
if {$nick_global_idx > -1} {
set int_global_nicks [lreplace $int_global_nicks $nick_global_idx $nick_global_idx $newnick]
}
}
putlog "interviewer-addon.tcl ver 0.1 by tomekk loaded"
# end of magic ;)