This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

user profile script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
B
Bidziil
Voice
Posts: 7
Joined: Sun Feb 15, 2009 2:12 am

quick question.....

Post by Bidziil »

how do I change the command character from ! to .
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Re: quick question.....

Post by tomekk »

Bidziil wrote:how do I change the command character from ! to .
!desc -> .desc ?
B
Bidziil
Voice
Posts: 7
Joined: Sun Feb 15, 2009 2:12 am

Post by Bidziil »

yes, I would like all commands, public as well as the setup ones to be . instead of !

like .setup instead of !setup
.desc instead of !desc
etc.....
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

Bidziil wrote:yes, I would like all commands, public as well as the setup ones to be . instead of !

like .setup instead of !setup
.desc instead of !desc
etc.....
change:

Code: Select all

bind pub - !setup setup_proc 
bind pub - !desc desc_proc
to:

Code: Select all

bind pub - .setup setup_proc 
bind pub - .desc desc_proc
m
manipulativeJack
Voice
Posts: 13
Joined: Tue Feb 17, 2009 9:52 pm

Post by manipulativeJack »

I guess it would be a major re-write to make it so that each part of the profile could be changed without starting fresh?

like

/msg bot !nick 23
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

manipulativeJack wrote:I guess it would be a major re-write to make it so that each part of the profile could be changed without starting fresh?

like

/msg bot !nick 23
try:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.3
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !setup
set setup_chans {#channel #channel2}

# dir with profile files
set profiles_dir "profiles"

# dir with teasers
set teasers_dir "teasers"

# location msg
set location_msg "Thanks for taking the time to set up a profile so we may better know you. For the first step you do !location (and area you live)"

# sex msg
set sex_msg "you are ready for the next step which is !SEX-OR type in your sex (male/female) and your D/s position (Top/Bottom, Dom/sub, Master/slave, Sadist, masochist, switch)"

# age msg
set age_msg "you are ready for the next step which is !age"

# describe msg
set describe_msg "now you are ready for the next step which is !describeME type info you want all on one line"

# likes msg
set likes_msg "Great all you have left is likes and limits .... type !mylikes and your likes all on one line."

# limits msg
set limits_msg " Fantastic, now you are ready for the last step which is !mylimits type info you want all on one line"

# end msg
set end_msg "Wonderful and thank you!!!!!! You have completed the last step of your profile. If you would like to view what you entered do !desc NICK , Thanks, have fun!"

##############################################################
bind pub - !setup setup_proc
bind pub - !desc desc_proc
bind pub - !teaser teaser_proc
bind msgm - "*" pm_proc
bind join - "*" do_on_join

set new_profiles_nicks [list]

if {![file exists $profiles_dir]} {
	file mkdir $profiles_dir
}

if {![file exists $teasers_dir]} {
	file mkdir $teasers_dir
}

proc add_entry_to_profile { nick data } {
	global profiles_dir

	set small_nick [string tolower $nick]

	set new_entry [open $profiles_dir/$small_nick a]
	puts $new_entry $data
	close $new_entry
}

proc update_entry { line_nr nick data } {
	global profiles_dir

	set small_nick [string tolower $nick]

	set get_old [open $profiles_dir/$small_nick r]
	set all_old_data [read $get_old]
	close $get_old

	set profile_line_cntr 0

	set new_profile [open $profiles_dir/$small_nick w]
	
	foreach profile_line [split $all_old_data "\n"] {
		if {$profile_line != ""} {
			if {$profile_line_cntr != $line_nr} {
				puts $new_profile $profile_line
			} {
				puts $new_profile $data
			}
	
			incr profile_line_cntr 1
		}
	}

	close $new_profile
}

proc lines_number { nick } {
	global profiles_dir

	set lines_counter 0
	
	set small_nick [string tolower $nick]

	if {[file exist $profiles_dir/$small_nick]} {
		set fetch_data [open $profiles_dir/$small_nick r]
		set lines_counter [llength [split [read $fetch_data] "\n"]]
		close $fetch_data
	}

	if {$lines_counter > 0} {
		set lines_counter [expr $lines_counter - 1]
	}

	return $lines_counter
}

proc setup_proc { nick uhost hand chan arg } {
	global new_profiles_nicks location_msg profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	putquick "PRIVMSG $nick :$location_msg"

	if {[lsearch $new_profiles_nicks $nick] == -1} {
		lappend new_profiles_nicks $nick
	}

	set small_nick [string tolower $nick]

	set new_profile_db [open $profiles_dir/$small_nick w]
	close $new_profile_db

} 

proc teaser_proc { nick uhost hand chan arg } {
	global profiles_dir teasers_dir profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	set teaser_data $arg
	set small_nick [string tolower $nick]

	if {[file exists $profiles_dir/$small_nick]} {
		if {$arg != ""} {
			set new_teaser [open $teasers_dir/$small_nick w]
			puts $new_teaser $arg
			close $new_teaser

			putquick "PRIVMSG $nick :done."
		}
	} {
		putquick "PRIVMSG $nick :at first, you need to make your profile, use !setup"	
	}

}

proc desc_proc { nick uhost hand chan arg } {
	global new_profiles_nicks profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	set split_args [split $arg]
	set input_nick [string tolower [lindex $split_args 0]]

	if {$input_nick != ""} {
		if {[file exists $profiles_dir/$input_nick]} {
			set read_profile [open $profiles_dir/$input_nick r]
			set full_data [read $read_profile]
			close $read_profile

			set desc_line_by_line [split $full_data "\n"]

			putquick "PRIVMSG $nick :$input_nick\'s location is: [lindex $desc_line_by_line 0]"
			putquick "PRIVMSG $nick :$input_nick is a: [lindex $desc_line_by_line 1]"
			putquick "PRIVMSG $nick :$input_nick\'s age is: [lindex    desc_line_by_line 2]"
			putquick "PRIVMSG $nick :$input_nick\'s description: lindex $desc_line_by_line 3]"
			putquick "PRIVMSG $nick :$input_nick\'s likes are: [lindex $desc_line_by_line 4]"
			putquick "PRIVMSG $nick :$input_nick\'s limits are: [lindex $desc_line_by_line 5]"
		} {
			putquick "PRIVMSG $chan :$nick: sorry, $input_nick profile doesn't exist"
		}
	} {
		putquick "PRIVMSG $chan :$nick: use, !desc <nickname>"
	}
}

proc do_on_join { nick uhost hand chan } {
	global profiles_dir teasers_dir setup_chans botnick

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	if {$botnick == $nick} {
		return
	}

	set small_nick [string tolower $nick]

	if {[file exists $profiles_dir/$small_nick]} {
		putquick "MODE $chan +v $nick"

		if {[file exists $teasers_dir/$small_nick]} {
			set user_teaser ""

			set get_teaser [open $teasers_dir/$small_nick r]
			gets $get_teaser user_teaser
			close $get_teaser

			putquick "PRIVMSG $chan :Teaser for $nick - $user_teaser - to view the full profile type: !desc $nick"
		}
	}
}

proc pm_proc { nick uhost hand arg } {
	global new_profiles_nicks sex_msg age_msg describe_msg likes_msg limits_msg end_msg profiles_dir

	set split_args [split $arg]
	set cmd_name [string tolower [lindex $split_args 0]]
	
	set available_cmds {"!location" "!sex-or" "!age" "!describeme" "!mylikes" "!mylimits" "profile"}

	if {[lsearch $available_cmds $cmd_name] == -1} {
		return
	}

	if {$cmd_name != "profile"} {
		set cmd_data [join [lrange $split_args 1 end]]

		if {[lsearch $new_profiles_nicks $nick] != -1} {
			switch -- $cmd_name {
				"!location" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 0} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$sex_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !location <info>"
					}
				}

				"!sex-or" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 1} { 
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$age_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !sex-or <info>"
					}
				}

				"!age" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 2} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$describe_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !age <info>"
					}
				}

				"!describeme" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 3} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$likes_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !describeme <info>"
					}
				}

				"!mylikes" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 4} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$limits_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !mylikes <info>"
					}
				}

				"!mylimits" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 5} {
							add_entry_to_profile $nick $cmd_data
	
							set temp_new_profiles_nicks [list]
	
							foreach profile_nick [split $new_profiles_nicks] {
								if {($profile_nick != "") && ($profile_nick != $nick)} {
									lappend temp_new_profiles_nicks $profile_nick
								}
							}

							set new_profiles_nicks $temp_new_profiles_nicks
	
							putquick "PRIVMSG $nick :$end_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !mylimits <info>"	
					}
				}
			}
		} {
			putquick "PRIVMSG $nick :You need to type !setup on channel at first"
		}
	} {
		set nick_lower [string tolower $nick]
		set profile_file "$profiles_dir/$nick_lower"

		if {![file exists $profile_file]} {
			putquick "PRIVMSG $nick :at first, you need to make your profile, use !setup"
		} {
		       	set profile_row [lindex [string tolower $split_args] 1]
			set profile_new_data [lrange $split_args 2 end]

			switch -- $profile_row {
				"!location" {
					if {$profile_new_data != ""} {
						update_entry 0 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !location <info>"
					}
				}

				"!sex-or" {
					if {$profile_new_data != ""} {
						update_entry 1 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !sex-or <info>"
					}
				}

				"!age" {
					if {$profile_new_data != ""} {
						update_entry 2 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !age <info>"
					}
				}

				"!describeme" {
					if {$profile_new_data != ""} {
						update_entry 3 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !describeme <info>"
					}
				}

				"!mylikes" { 
					if {$profile_new_data != ""} {
						update_entry 4 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !mylikes <info>"
					}
				}

				"!mylimits" {
					if {$profile_new_data != ""} {
						update_entry 5 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !mylimits <info>"
					}
				}

				default {
					putquick "PRIVMSG $nick :to update use, profile <[join [lrange $available_cmds 0 end-1] " | "]>"
				}
			}
		}
	}
}

putlog "profile.tcl ver 0.3 by tomekk loaded"
!setup, !desc, !teaser looks the same

if u want to update information, just use /msg <botname> profile <command>

example:
/msg mybot profile !mylikes my new likes in here !

Script will update the profile, but of course profile file must exists. (script is taking profile name from $nick)

example:
If user with nick "John" will pm bot with profile command then bot will check for file called "john", i think its simple :)

test it,
cheers
D
Daedalus
Voice
Posts: 24
Joined: Wed Jun 27, 2007 7:12 pm

Post by Daedalus »

Hey,

I'm considering/attempting to rewrite this with a view to switching from flatfile storage to mysql storage - so I can more easily set up a page in PHP for viewing profiles on a website.

Unfortunately I'm not hugely great with Tcl (read: limited experience, mostly editing/bugfixing other people's scripts for my own purposes).

I've got a sortof shell-of-a-script worked out in my head but I'm not really 100% sure on too many things.

Any ideas?
D
Daedalus
Voice
Posts: 24
Joined: Wed Jun 27, 2007 7:12 pm

Post by Daedalus »

Daedalus wrote:Hey,

I'm considering/attempting to rewrite this with a view to switching from flatfile storage to mysql storage - so I can more easily set up a page in PHP for viewing profiles on a website.

Unfortunately I'm not hugely great with Tcl (read: limited experience, mostly editing/bugfixing other people's scripts for my own purposes).

I've got a sortof shell-of-a-script worked out in my head but I'm not really 100% sure on too many things.

Any ideas?
This is too vague. I'll open a new thread detailing what the hell I'm talking about to avoid cluttering this one with any answers going "dude, what!" at me. ;)
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

HI all.
i modify to this:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.3
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !setup
set setup_chans {#VinaChat #Rdt}

# dir with profile files
set profiles_dir "Thongtin"

# dir with teasers
set teasers_dir "Loichao"

# location msg
set location_msg "Cam on ban da bo chut thoi gian de lam tieu su ban than. De bat dau hay go: .noisinh (Noi ma ban dang song)"

# sex msg
set sex_msg "Ban da hoan thanh xong buoc thu nhat.Tiep theo hay go .gioitinh (nam/nu) "

# age msg
set age_msg "Ban da hoan thanh buoc thu 2.Tiep theo khai bao tuoi cua ban ,hay go .sinhnhat (Ngay thang nam sinh cua ban)"

# describe msg
set describe_msg "Ban da hoan thanh buoc thu 3. Tiep theo hay tu bach doi chut ve ban than, hay go .tubach (Noi dung tu bach cua Ban)"

# likes msg
set likes_msg "Vo cung cam on ban ve nhung tu bach tren.... Tiep theo ban hay chia se ve so thich, hay go .sothich (nhung so thich cua ban)."

# limits msg
set limits_msg " Rat cam on ban da chia se voi chung toi. Ngay bay gio hay go .tinhtrang (Da ket hon, hay doc than...) de ket thuc."

# end msg
set end_msg "Tuyet voi va cam on ban!!!!!!.Ban da hoan thanh viec khai bao tren. de xem tu bach cua mot nick nao do, hay go .thongtin NICK de xem, Cam on va chuc vui ve!"

##############################################################
bind pub - .caidat setup_proc
bind pub - .thongtin desc_proc
bind pub - .loichao teaser_proc
bind pub - "*" pm_proc
bind join - "*" do_on_join

set new_profiles_nicks [list]

if {![file exists $profiles_dir]} {
   file mkdir $profiles_dir
}

if {![file exists $teasers_dir]} {
   file mkdir $teasers_dir
}

proc add_entry_to_profile { nick data } {
   global profiles_dir

   set small_nick [string tolower $nick]

   set new_entry [open $profiles_dir/$small_nick a]
   puts $new_entry $data
   close $new_entry
}

proc update_entry { line_nr nick data } {
   global profiles_dir

   set small_nick [string tolower $nick]

   set get_old [open $profiles_dir/$small_nick r]
   set all_old_data [read $get_old]
   close $get_old

   set profile_line_cntr 0

   set new_profile [open $profiles_dir/$small_nick w]
   
   foreach profile_line [split $all_old_data "\n"] {
      if {$profile_line != ""} {
         if {$profile_line_cntr != $line_nr} {
            puts $new_profile $profile_line
         } {
            puts $new_profile $data
         }
   
         incr profile_line_cntr 1
      }
   }

   close $new_profile
}

proc lines_number { nick } {
   global profiles_dir

   set lines_counter 0
   
   set small_nick [string tolower $nick]

   if {[file exist $profiles_dir/$small_nick]} {
      set fetch_data [open $profiles_dir/$small_nick r]
      set lines_counter [llength [split [read $fetch_data] "\n"]]
      close $fetch_data
   }

   if {$lines_counter > 0} {
      set lines_counter [expr $lines_counter - 1]
   }

   return $lines_counter
}

proc setup_proc { nick uhost hand chan arg } {
   global new_profiles_nicks location_msg profiles_dir setup_chans

   if {[lsearch $setup_chans $chan] == -1} {
      return
   }

   putquick "PRIVMSG $chan :$location_msg"

   if {[lsearch $new_profiles_nicks $nick] == -1} {
      lappend new_profiles_nicks $nick
   }

   set small_nick [string tolower $nick]

   set new_profile_db [open $profiles_dir/$small_nick w]
   close $new_profile_db

}

proc teaser_proc { nick uhost hand chan arg } {
   global profiles_dir teasers_dir profiles_dir setup_chans

   if {[lsearch $setup_chans $chan] == -1} {
      return
   }

   set teaser_data $arg
   set small_nick [string tolower $nick]

   if {[file exists $profiles_dir/$small_nick]} {
      if {$arg != ""} {
         set new_teaser [open $teasers_dir/$small_nick w]
         puts $new_teaser $arg
         close $new_teaser

         putquick "PRIVMSG $chan :Hoan thanh viec cai dat Loi Chao cho Nick cua ban."
      }
   } {
      putquick "PRIVMSG $chan :De tao loi chao Ban hay go: .loichao <info> de cai dat"   
   }

}

proc desc_proc { nick uhost hand chan arg } {
   global new_profiles_nicks profiles_dir setup_chans

   if {[lsearch $setup_chans $chan] == -1} {
      return
   }

   set split_args [split $arg]
   set input_nick [string tolower [lindex $split_args 0]]

   if {$input_nick != ""} {
      if {[file exists $profiles_dir/$input_nick]} {
         set read_profile [open $profiles_dir/$input_nick r]
         set full_data [read $read_profile]
         close $read_profile

         set desc_line_by_line [split $full_data "\n"]
         putquick "PRIVMSG $chan :5Thong tin Chi tiet ve 12$input_nick 5nhu sau5:"
         putquick "PRIVMSG $chan :12Que Quan:5 [lindex $desc_line_by_line 0]5 "
         putquick "PRIVMSG $chan :12Gioi Tinh:5 [lindex $desc_line_by_line 1]5 "
         putquick "PRIVMSG $chan :12Sinh Nhat:5 [lindex $desc_line_by_line 2]5 "
         putquick "PRIVMSG $chan :12Tu Bach:5 [lindex $desc_line_by_line 3]5 "
         putquick "PRIVMSG $chan :12So Thich:5 [lindex $desc_line_by_line 4]5 "
         putquick "PRIVMSG $chan :12Tinh Trang:5 [lindex $desc_line_by_line 5]5 "
      } {
         putquick "PRIVMSG $chan :$nick: Xin loi, $input_nick chua co trong danh sach."
      }
   } {
      putquick "PRIVMSG $chan :$nick: Hay su dung: .thongtin <nickname>"
   }
}

proc do_on_join { nick uhost hand chan } {
   global profiles_dir teasers_dir setup_chans botnick

   if {[lsearch $setup_chans $chan] == -1} {
      return
   }

   if {$botnick == $nick} {
      return
   }

   set small_nick [string tolower $nick]

   if {[file exists $profiles_dir/$small_nick]} {
      putquick "MODE $chan +v $nick"

      if {[file exists $teasers_dir/$small_nick]} {
         set user_teaser ""

         set get_teaser [open $teasers_dir/$small_nick r]
         gets $get_teaser user_teaser
         close $get_teaser

         putquick "PRIVMSG $chan :[12$nick 12]- 5 $user_teaser  "
      }
   }
}

proc pm_proc { nick uhost hand chan arg } {
   global new_profiles_nicks sex_msg age_msg describe_msg likes_msg limits_msg end_msg profiles_dir
   if {[lsearch $setup_chans $chan] == -1} {
      return
   }

   set split_args [split $arg]
   set cmd_name [string tolower [lindex $split_args 0]]
   
   set available_cmds {".noisinh" ".gioitinh" ".namsinh" ".tubach" ".sothich" ".tinhtrang" "update"}

   if {[lsearch $available_cmds $cmd_name] == -1} {
      return
   }

   if {$cmd_name != "update"} {
      set cmd_data [join [lrange $split_args 1 end]]

      if {[lsearch $new_profiles_nicks $nick] != -1} {
         switch -- $cmd_name {
            ".noisinh" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 0} {
                     add_entry_to_profile $nick $cmd_data
                     putquick "PRIVMSG $chan :$sex_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .quequan <info>"
               }
            }

            ".gioitinh" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 1} {
                     add_entry_to_profile $nick $cmd_data
                     putquick "PRIVMSG $chan :$age_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .gioitinh <info>"
               }
            }

            ".sinhnhat" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 2} {
                     add_entry_to_profile $nick $cmd_data
                     putquick "PRIVMSG $chan :$describe_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .namsinh <info>"
               }
            }

            ".tubach" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 3} {
                     add_entry_to_profile $nick $cmd_data
                     putquick "PRIVMSG $chan :$likes_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .tubach <info>"
               }
            }

            ".sothich" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 4} {
                     add_entry_to_profile $nick $cmd_data
                     putquick "PRIVMSG $chan :$limits_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .sothich <info>"
               }
            }

            ".tinhtrang" {
               if {$cmd_data != ""} {
                  if {[lines_number $nick] == 5} {
                     add_entry_to_profile $nick $cmd_data
   
                     set temp_new_profiles_nicks [list]
   
                     foreach profile_nick [split $new_profiles_nicks] {
                        if {($profile_nick != "") && ($profile_nick != $nick)} {
                           lappend temp_new_profiles_nicks $profile_nick
                        }
                     }

                     set new_profiles_nicks $temp_new_profiles_nicks
   
                     putquick "PRIVMSG $chan :$end_msg"
                  }
               } {
                  putquick "PRIVMSG $chan :Su dung lenh: .tinhtrang <info>"   
               }
            }
         }
      } else {
         putquick "PRIVMSG $chan :Ban can go .caidat de dang ky voi Server VinaChat chung toi"
      }
   } else {
      set nick_lower [string tolower $nick]
      set profile_file "$profiles_dir/$nick_lower"

      if {![file exists $profile_file]} {
         putquick "PRIVMSG $chan :Dau tien, Ban phai cai dat thong tin ca nhan, hay go: .caidat de bat dau"
      } {
                set profile_row [lindex [string tolower $split_args] 1]
         set profile_new_data [lrange $split_args 2 end]

         switch -- $profile_row {
            ".noisinh" {
               if {$profile_new_data != ""} {
                  update_entry 0 $nick $profile_new_data
                  putquick "PRIVMSG $chan :Da hoan thanh."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .quequan <info>"
               }
            }

            ".gioitinh" {
               if {$profile_new_data != ""} {
                  update_entry 1 $nick $profile_new_data
                  putquick "PRIVMSG $chan :done."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .gioitinh <info>"
               }
            }

            ".sinhnhat" {
               if {$profile_new_data != ""} {
                  update_entry 2 $nick $profile_new_data
                  putquick "PRIVMSG $chan :done."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .tuoi <info>"
               }
            }

            ".tubach" {
               if {$profile_new_data != ""} {
                  update_entry 3 $nick $profile_new_data
                  putquick "PRIVMSG $chan :done."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .tubach <info>"
               }
            }

            ".sothich" {
               if {$profile_new_data != ""} {
                  update_entry 4 $nick $profile_new_data
                  putquick "PRIVMSG $chan :done."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .sothich <info>"
               }
            }

            ".tinhtrang" {
               if {$profile_new_data != ""} {
                  update_entry 5 $nick $profile_new_data
                  putquick "PRIVMSG $chan :done."
               } {
                  putquick "PRIVMSG $chan :Hay su dung: update .tinhtrang <info>"
               }
            }

            default {
               putquick "PRIVMSG $chan :De thay doi thong tin,Hay go: update <[join [lrange $available_cmds 0 end-1] " | "]>"
            }
         }
      }
   }
}

putlog "profile.tcl ver 0.3 by tomekk loaded"  
in my room i type
* VinaChat sets mode: +o ChanBot
<Rdt> .dangky
<@ChanBot> Dau tien, Ban phai khai bao doi chut ve ban than, Hay go: .caidat de bat dau
<Rdt> .caidat
<@ChanBot> Cam on ban da bo chut thoi gian de lam tieu su ban than. De bat dau hay go: .noisinh (Noi ma ban dang song)
<Rdt> .noisinh HCM, Vietnam

but nothing ...to next ???
I want to setup in Channel not by pm to bot
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

i'm not able to test it cause i'm far far away from desktop PC,
but, change this line:

Code: Select all

bind pub - "*" pm_proc
to

Code: Select all

bind pubm - "*" pm_proc
and later, cause i forget to join one list:

Code: Select all

set profile_new_data [lrange $split_args 2 end]
to

Code: Select all

set profile_new_data [join [lrange $split_args 2 end]]
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

i wish i can check list nick setup with bot by !list cmd eg:
<Rdt> .list
<ChanBot> Plz choose !list1 (A->F) !list2 (G->L) !list3 (M->R) list4(R-End)
<Rdt> .list1
<ChanBot> Current list Nickname A-F: AndFor, Blader01, ExitMe.
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

in cmd update when another nick change to my nick he used cmd update ...
bot will update profile.
i want to restricted to nick have identified to used that cmd.
???
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

0.4 with !list command:

Code: Select all

# Author: tomekk
# e-mail:  tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.4
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html

# channels for !setup
set setup_chans {#channel #channel2}

# dir with profile files
set profiles_dir "profiles"

# dir with teasers
set teasers_dir "teasers"

# location msg
set location_msg "Thanks for taking the time to set up a profile so we may better know you. For the first step you do !location (and area you live)"

# sex msg
set sex_msg "you are ready for the next step which is !SEX-OR type in your sex (male/female) and your D/s position (Top/Bottom, Dom/sub, Master/slave, Sadist, masochist, switch)"

# age msg
set age_msg "you are ready for the next step which is !age"

# describe msg
set describe_msg "now you are ready for the next step which is !describeME type info you want all on one line"

# likes msg
set likes_msg "Great all you have left is likes and limits .... type !mylikes and your likes all on one line."

# limits msg
set limits_msg " Fantastic, now you are ready for the last step which is !mylimits type info you want all on one line"

# end msg
set end_msg "Wonderful and thank you!!!!!! You have completed the last step of your profile. If you would like to view what you entered do !desc NICK , Thanks, have fun!"

##############################################################
bind pub - !setup setup_proc
bind pub - !desc desc_proc
bind pub - !teaser teaser_proc
bind pub - !list list_proc
bind msgm - "*" pm_proc
bind join - "*" do_on_join

set new_profiles_nicks [list]

if {![file exists $profiles_dir]} {
	file mkdir $profiles_dir
}

if {![file exists $teasers_dir]} {
	file mkdir $teasers_dir
}

proc add_entry_to_profile { nick data } {
	global profiles_dir

	set small_nick [string tolower $nick]

	set new_entry [open $profiles_dir/$small_nick a]
	puts $new_entry $data
	close $new_entry
}

proc update_entry { line_nr nick data } {
	global profiles_dir

	set small_nick [string tolower $nick]

	set get_old [open $profiles_dir/$small_nick r]
	set all_old_data [read $get_old]
	close $get_old

	set profile_line_cntr 0

	set new_profile [open $profiles_dir/$small_nick w]
	
	foreach profile_line [split $all_old_data "\n"] {
		if {$profile_line != ""} {
			if {$profile_line_cntr != $line_nr} {
				puts $new_profile $profile_line
			} {
				puts $new_profile $data
			}
	
			incr profile_line_cntr 1
		}
	}

	close $new_profile
}

proc lines_number { nick } {
	global profiles_dir

	set lines_counter 0
	
	set small_nick [string tolower $nick]

	if {[file exist $profiles_dir/$small_nick]} {
		set fetch_data [open $profiles_dir/$small_nick r]
		set lines_counter [llength [split [read $fetch_data] "\n"]]
		close $fetch_data
	}

	if {$lines_counter > 0} {
		set lines_counter [expr $lines_counter - 1]
	}

	return $lines_counter
}

proc setup_proc { nick uhost hand chan arg } {
	global new_profiles_nicks location_msg profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	putquick "PRIVMSG $nick :$location_msg"

	if {[lsearch $new_profiles_nicks $nick] == -1} {
		lappend new_profiles_nicks $nick
	}

	set small_nick [string tolower $nick]

	set new_profile_db [open $profiles_dir/$small_nick w]
	close $new_profile_db

} 

proc teaser_proc { nick uhost hand chan arg } {
	global profiles_dir teasers_dir profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	set teaser_data $arg
	set small_nick [string tolower $nick]

	if {[file exists $profiles_dir/$small_nick]} {
		if {$arg != ""} {
			set new_teaser [open $teasers_dir/$small_nick w]
			puts $new_teaser $arg
			close $new_teaser

			putquick "PRIVMSG $nick :done."
		}
	} {
		putquick "PRIVMSG $nick :at first, you need to make your profile, use !setup"	
	}

}

proc list_proc { nick uhost hand chan arg } {
	global profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	set list_number [lindex [split $arg] 0]

	if {$list_number != ""} {
		switch -- $list_number {
			"1" {
				set af_list [glob -tails -directory $profiles_dir -nocomplain -type f {{a,b,c,d,e,f}*}]

				if {$af_list != ""} {
					putquick "PRIVMSG $chan :Current list Nickname A-F: $af_list"
				} {
					putquick "PRIVMSG $chan :list is empty"
				}
			}

			"2" {
				set gl_list [glob -tails -directory $profiles_dir -nocomplain -type f {{g,h,i,j,k,l}*}]

				if {$gl_list != ""} {
					putquick "PRIVMSG $chan :Current list Nickname G-L: $gl_list"
				} {
					putquick "PRIVMSG $chan :list is empty"
				}
			}

			"3" {
				set mr_list [glob -tails -directory $profiles_dir -nocomplain -type f {{m,n,o,p,q,r}*}]

				if {$mr_list != ""} {
					putquick "PRIVMSG $chan :Current list Nickname M-R: $mr_list"
				} {
					putquick "PRIVMSG $chan :list is empty"
				}
			}

			"4" {
				set sz_list [glob -tails -directory $profiles_dir -nocomplain -type f {{s,t,u,v,w,x,y,z}*}]

				if {$sz_list != ""} {
					putquick "PRIVMSG $chan :Current list Nickname S-Z: $sz_list"
				} {
					putquick "PRIVMSG $chan :list is empty"
				}
			}
		}
	} {
		putquick "PRIVMSG $chan :Plz choose !list 1 (A->F) / !list 2 (G->L) / !list 3 (M->R) / list 4 (S-Z)"
	}
}

proc desc_proc { nick uhost hand chan arg } {
	global new_profiles_nicks profiles_dir setup_chans

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	set split_args [split $arg]
	set input_nick [string tolower [lindex $split_args 0]]

	if {$input_nick != ""} {
		if {[file exists $profiles_dir/$input_nick]} {
			set read_profile [open $profiles_dir/$input_nick r]
			set full_data [read $read_profile]
			close $read_profile

			set desc_line_by_line [split $full_data "\n"]

			putquick "PRIVMSG $nick :$input_nick\'s location is: [lindex $desc_line_by_line 0]"
			putquick "PRIVMSG $nick :$input_nick is a: [lindex $desc_line_by_line 1]"
			putquick "PRIVMSG $nick :$input_nick\'s age is: [lindex $desc_line_by_line 2]"
			putquick "PRIVMSG $nick :$input_nick\'s description: [lindex $desc_line_by_line 3]"
			putquick "PRIVMSG $nick :$input_nick\'s likes are: [lindex $desc_line_by_line 4]"
			putquick "PRIVMSG $nick :$input_nick\'s limits are: [lindex $desc_line_by_line 5]"
		} {
			putquick "PRIVMSG $chan :$nick: sorry, $input_nick profile doesn't exist"
		}
	} {
		putquick "PRIVMSG $chan :$nick: use, !desc <nickname>"
	}
}

proc do_on_join { nick uhost hand chan } {
	global profiles_dir teasers_dir setup_chans botnick

	if {[lsearch $setup_chans $chan] == -1} {
		return
	}

	if {$botnick == $nick} {
		return
	}

	set small_nick [string tolower $nick]

	if {[file exists $profiles_dir/$small_nick]} {
		putquick "MODE $chan +v $nick"

		if {[file exists $teasers_dir/$small_nick]} {
			set user_teaser ""

			set get_teaser [open $teasers_dir/$small_nick r]
			gets $get_teaser user_teaser
			close $get_teaser

			putquick "PRIVMSG $chan :Teaser for $nick - $user_teaser - to view the full profile type: !desc $nick"
		}
	}
}

proc pm_proc { nick uhost hand arg } {
	global new_profiles_nicks sex_msg age_msg describe_msg likes_msg limits_msg end_msg profiles_dir

	set split_args [split $arg]
	set cmd_name [string tolower [lindex $split_args 0]]
	
	set available_cmds {"!location" "!sex-or" "!age" "!describeme" "!mylikes" "!mylimits" "profile"}

	if {[lsearch $available_cmds $cmd_name] == -1} {
		return
	}

	if {$cmd_name != "profile"} {
		set cmd_data [join [lrange $split_args 1 end]]

		if {[lsearch $new_profiles_nicks $nick] != -1} {
			switch -- $cmd_name {
				"!location" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 0} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$sex_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !location <info>"
					}
				}

				"!sex-or" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 1} { 
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$age_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !sex-or <info>"
					}
				}

				"!age" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 2} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$describe_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !age <info>"
					}
				}

				"!describeme" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 3} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$likes_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !describeme <info>"
					}
				}

				"!mylikes" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 4} {
							add_entry_to_profile $nick $cmd_data
							putquick "PRIVMSG $nick :$limits_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !mylikes <info>"
					}
				}

				"!mylimits" {
					if {$cmd_data != ""} {
						if {[lines_number $nick] == 5} {
							add_entry_to_profile $nick $cmd_data
	
							set temp_new_profiles_nicks [list]
	
							foreach profile_nick [split $new_profiles_nicks] {
								if {($profile_nick != "") && ($profile_nick != $nick)} {
									lappend temp_new_profiles_nicks $profile_nick
								}
							}

							set new_profiles_nicks $temp_new_profiles_nicks
	
							putquick "PRIVMSG $nick :$end_msg"
						}
					} {
						putquick "PRIVMSG $nick :use, !mylimits <info>"	
					}
				}
			}
		} {
			putquick "PRIVMSG $nick :You need to type !setup on channel at first"
		}
	} {
		set nick_lower [string tolower $nick]
		set profile_file "$profiles_dir/$nick_lower"

		if {![file exists $profile_file]} {
			putquick "PRIVMSG $nick :at first, you need to make your profile, use !setup"
		} {
		       	set profile_row [lindex [string tolower $split_args] 1]
			set profile_new_data [lrange $split_args 2 end]

			switch -- $profile_row {
				"!location" {
					if {$profile_new_data != ""} {
						update_entry 0 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !location <info>"
					}
				}

				"!sex-or" {
					if {$profile_new_data != ""} {
						update_entry 1 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !sex-or <info>"
					}
				}

				"!age" {
					if {$profile_new_data != ""} {
						update_entry 2 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !age <info>"
					}
				}

				"!describeme" {
					if {$profile_new_data != ""} {
						update_entry 3 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !describeme <info>"
					}
				}

				"!mylikes" { 
					if {$profile_new_data != ""} {
						update_entry 4 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !mylikes <info>"
					}
				}

				"!mylimits" {
					if {$profile_new_data != ""} {
						update_entry 5 $nick $profile_new_data
						putquick "PRIVMSG $nick :done."
					} {
						putquick "PRIVMSG $nick :use, profile !mylimits <info>"
					}
				}

				default {
					putquick "PRIVMSG $nick :to update use, profile <[join [lrange $available_cmds 0 end-1] " | "]>"
				}
			}
		}
	}
}

putlog "profile.tcl ver 0.4 by tomekk loaded"
10:57:29 <@tomekk> !list
10:57:40 < botty> Plz choose !list 1 (A->F) / !list 2 (G->L) / !list 3 (M->R) / list 4 (S-Z)
10:59:26 <@tomekk> !list 1
10:59:26 < botty> list is empty
10:59:27 <@tomekk> !list 2
10:59:27 < botty> list is empty
10:59:28 <@tomekk> !list 3
10:59:28 < botty> list is empty
10:59:54 <@tomekk> !list 4
10:59:54 < botty> Current list Nickname S-Z: satan tomekk2 tomekk xen
Repdientu wrote:in cmd update when another nick change to my nick he used cmd update ...
bot will update profile.
i want to restricted to nick have identified to used that cmd.
???
yeah, I know about that
Bidziil didn't say anything about that and I didn't make any 'authentication' or something...

Its possible to make some key or host based profile, whatever...

I think this is over of this script, because I'm working on better, more flexible universal interview script which can be easily implemented in any other profile scripts.
It support keys for profiles, you can add new questions without rewriting script etc.

Cheers
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

Hello Tomekk...

Thank you for version 0.4. great you have done for the needs of people.

I estimated you can add the bot to confirmation by the nick want to use the bot with the command to log in with nickserv.

I hope to soon receive a version 0.5 of you.

Thank you
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

after using this. i want to limit all profile eg location. sex,... < 100 words.
and bug when type !setup again. profile will lost all data.
Can you prevent !setup cmd again if it has data of nick . if type !setup again bot will say : <nick> have profile. To update your profile .Type: updat <cmd>
Post Reply