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

help on faq.tcl

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
draftmann
Voice


Joined: 12 Aug 2005
Posts: 3

PostPosted: Fri Aug 12, 2005 5:42 pm    Post subject: help on faq.tcl Reply with quote

please help me with this tcl, i want this code bind pub - "[string trim $faq(cmdchar)]faq" faq:tell_fact only for user's with cmode(+o, +h and +v). if user without cmode(+o, +h and +v) use this command(??faq nick keyword) to notice himself/herself if he use bind pub - "[string trim $faq(cmdchar)]faq" faq:tell_fact command. Sorry for my bad english Smile

Quote:
Here's an Example how the bot show and how i want the bot to show.
<@nick1> ??faq Guest url
<@bot> Guest: (url) www.somesite.com
<@nick1> ?? url
<@bot> (url) www.somesite.com
<Guest> ?? nick1 url
<@bot> Guest3: (url) www.somesite.com
<Guest> ??faq nick1 url
<@bot> Guest5: (url) www.somesite.com
this it how the script works, it also shows when normal users(not op, halfop or voice) use the public command. I want to for use by op halfop and voice only. Means this command is for any user, but i want it for op/halfop/voice only.

And this is how i want the bot to show(some code needed to change for this) when cmode without(+o,+h and +v) uses this command
<Guest> ??faq nick1 url
-Notice(bot)- u dont have permission for this command.(something like that!)
<Guest> ?? url
-Notice(bot)- www.somesite.com
to notice nick2 non (op, halfop or voice).


i tried my best to explain it how i want the script/tcl to be, may be u can get me. Smile
Here is the script.

Code:
bind pub - "[string trim $faq(cmdchar)]" faq:explain_fact
bind pub - "[string trim $faq(cmdchar)]faq" faq:tell_fact
bind pub - "[string trim $faq(cmdchar)]addword" faq:add_fact
bind pub - "[string trim $faq(cmdchar)]delword" faq:delete_fact
bind pub - "[string trim $faq(cmdchar)]modify" faq:modify_fact
bind pub - "[string trim $faq(cmdchar)]close-faq" faq:close-faqdb
bind pub - "[string trim $faq(cmdchar)]open-faq" faq:open-faqdb
bind pub - "[string trim $faq(cmdchar)]faq-help" faq:faq_howto

proc faq:close-faqdb {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {![matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You can't change the faq-database status."
  return 0
 }
 if {$faq(status)==0} {
  set faq(status) 1
  putnotc $nick "The faq-database was \002closed correctly\002."
  putnotc $nick "Now anybody cant use the command '[string trim $faq(cmdchar)] keyword'."
  putnotc $nick "To open the faq-database again use the command '[string trim $faq(cmdchar)]open-faq'."
  return 0
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002already closed\002."
  return 0
 }
}

proc faq:open-faqdb {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {![matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You can't change the faq-database status."
  return 0
 }
 if {$faq(status)==1} {
  set faq(status) 0
  putnotc $nick "The faq-database was \002opened correctly\002."
  putnotc $nick "Now anybody can use the command '[string trim $faq(cmdchar)] \002keyword\002'."
  putnotc $nick "To close the faq-database again just use the command '[string trim $faq(cmdchar)]close-faq'."
  return 0
 }
 if {$faq(status)==0} {
  putnotc $nick "The faq-database is \002already open\002."
  return 0
 }
}


proc faq:explain_fact {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {$faq(status) == 1} {
  putnotc $nick "The faq-database is \002closed\002."
  return 0
 }
 if {![file exist $faq(database)]} {
  set database [open $faq(database) w]
  puts -nonewline $database ""
  close $database
 }
 set fact [ string trim [ string tolower [ join $args ] ] ]
 if {$fact == ""} {
#  putmsg $nick "Syntax: [string trim $faq(cmdchar)] \002keyword\002"
  return 0
 }
 set database [open $faq(database) r]
 set dbline ""
 while {![eof $database]} {
  gets $database dbline
  set dbfact [ string tolower [ lindex [split $dbline [string trim $faq(splitchar)]] 0 ]]
  set dbdefinition [string range $dbline [expr [string length $fact]+1] end]
  if {$dbfact==$fact} {
    if {[string match -nocase "*$faq(newline)*" $dbdefinition]} {
      set out1 [lindex [split $dbdefinition $faq(newline)] 0]
      set out2 [string range $dbdefinition [expr [string length $out1]+2] end]
      putmsg $channel "\002$fact\002: $out1"
      putmsg $channel "\002$fact\002: $out2"
   } else {
     putmsg $channel "\002$fact\002: $dbdefinition"
   }
   close $database
   return 0
  }
 }
 close $database
 putnotc $nick "I don't know about \002$fact\002."
 if {[matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You could add \002$fact\002 by using [string trim $faq(cmdchar)]addword \002$fact\002[string trim $faq(splitchar)]Definition goes here."
 } else {
#  putnotc $nick "If you're looking for a TCL-Script try http://www.egghelp.org/cgi-bin/tcl_archive.tcl?strings=$fact"
 }
 return 0
}

proc faq:tell_fact {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002closed\002."
  return 0
 }
 if {![file exist $faq(database)]} {
  set database [open $faq(database) w]
  puts -nonewline $database ""
  close $database
 }
 set tellnick [ lindex [split [join $args]] 0 ]
 set fact [ string trim [ string tolower [ join [ lrange [split [join $args]] 1 end ] ] ] ]
 if {$tellnick == ""} {
  putnotc $nick "Syntax: [string trim $faq(cmdchar)]faq \002nick\002 keyword"
  return 0
 }
 if {$fact == ""} {
  putnotc $nick "Syntax: [string trim $faq(cmdchar)]faq nick \002keyword\002"
  return 0
 }
 set database [open $faq(database) r]
 set dbline ""
 while {![eof $database]} {
  gets $database dbline
  set dbfact [ string tolower [ lindex [split $dbline [string trim $faq(splitchar)]] 0 ] ]
  set dbdefinition [string range $dbline [expr [string length $fact]+1] end]
  if {$dbfact==$fact} {
    if {[string match -nocase "*$faq(newline)*" $dbdefinition]} {
      set out1 [lindex [split $dbdefinition "$faq(newline)"] 0]
      set out2 [string range $dbdefinition [expr [string length $out1]+2] end]
      putmsg $channel "\002$tellnick\002: ($dbfact) $out1"
      putmsg $channel "\002$tellnick\002: ($dbfact) $out2"
    } else {
      putmsg $channel "\002$tellnick\002: ($dbfact) $dbdefinition"
    }
    putlog "FAQ: Send keyword \"\002$fact\002\" to $tellnick by $nick ($idx)"
    close $database
    return 0
  }
 }
 close $database
 putnotc $nick "I don't have the keyword \002$fact\002 in my database."
 if {[matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You could add \002$fact\002 by using [string trim $faq(cmdchar)]addword \002$fact\002[string trim $faq(splitchar)]Definition goes here."
 } else {
#  putnotc $nick "If you're looking for a TCL-Script try http://www.egghelp.org/cgi-bin/tcl_archive.tcl?strings=$fact"
 }
 return 0
}

proc faq:add_fact {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002closed\002."
  return 0
 }
 if {![matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
   putnotc $nick "You can't add keywords into my dababase."
  return 0
 }
 if {![file exist $faq(database)]} {
  set database [open $faq(database) w]
  puts -nonewline $database ""
  close $database
 }
 set fact [ string tolower [ lindex [split [join $args] [string trim $faq(splitchar)]] 0 ] ]
 set definition [string range [join $args] [expr [string length $fact]+1] end] 
 set database [open $faq(database) r]
 if {($fact=="")} {
  putnotc $nick "Left parameters."
  putnotc $nick "use: [string trim $faq(cmdchar)]addword \002keyword\002[string trim $faq(splitchar)]definition"
  return 0
 } elseif {($definition=="")} {
  putnotc $nick "Left parameters."
  putnotc $nick "use: [string trim $faq(cmdchar)]addword keyword[string trim $faq(splitchar)]\002definition\002"
  return 0
 }
 while {![eof $database]} {
  gets $database dbline
  set add_fact [ string tolower [ lindex [split $dbline [string trim $faq(splitchar)]] 0 ] ]
  if {$add_fact==$fact} {
   putnotc $nick "This keyword is already in my database:"
   putnotc $nick "Is: \002$fact\002 - $definition"
   putnotc $nick "If you want to modify it just use '[string trim $faq(cmdchar)]modify $fact[string trim $faq(splitchar)]\002definition\002'"
   close $database
   return 0
  }
 }
 close $database
 set database [open $faq(database) a]
 puts $database "$fact[string trim $faq(splitchar)]$definition"
 close $database
 putnotc $nick "The keyword \002$fact\002 was added correctly to my database."
 putnotc $nick "Now: \002$fact\002 - $definition"
}

proc faq:delete_fact {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002closed\002."
  return 0
 }
 if {![matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You can't delete keywords from my database."
  return 0
 }
 if {![file exist $faq(database)]} {
  set database [open $faq(database) w]
  puts -nonewline $database ""
  close $database
 }
 set fact [string tolower [join $args]]
 if {($fact=="")} {
  putnotc $nick "Left parameters."
  putnotc $nick "use: [string trim $faq(cmdchar)]delword \002keyword\002"
  return 0
 }
 set database [open $faq(database) r]
 set dbline ""
 set found 0
 while {![eof $database]} {
  gets $database dbline
  set dbfact [ string tolower [ lindex [split $dbline [string trim $faq(splitchar)]] 0 ] ]
  set dbdefinition [string range $dbline [expr [string length $fact]+1] end]
  if {$dbfact!=$fact} {
   lappend datalist $dbline
  } else {
   putnotc $nick "The keyword \002$fact\002 was deleted correctly from my database."
   putnotc $nick "Was: \002$dbfact\002 - $dbdefinition"
   set found 1
  }
 }
 close $database
 set databaseout [open $faq(database) w]
 foreach line $datalist {
  if {$line!=""} {puts $databaseout $line}
 }
 close $databaseout
 if {$found != 1} {putnotc $nick "\002$fact\002 not found in my database."}
}

proc faq:modify_fact {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002closed\002."
  return 0
 }
 if {![matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  putnotc $nick "You can't modify keywords in my database."
  return 0
 }
 if {![file exist $faq(database)]} {
  set database [open $faq(database) w]
  puts -nonewline $database ""
  close $database
 }
 set fact [ string tolower [ lindex [split [join $args] [string trim $faq(splitchar)]] 0 ] ]
 set definition [string range [join $args] [expr [string length $fact]+1] end]
 set database [open $faq(database) r]
 if {($fact=="")} {
  putnotc $nick "Left parameters."
  putnotc $nick "use: [string trim $faq(cmdchar)]modify \002keyword\002[string trim $faq(splitchar)]definition"
  return 0
 }
 if {($definition=="")} {
  putnotc $nick "Left parameters."
  putnotc $nick "use: [string trim $faq(cmdchar)]modify keyword[string trim $faq(splitchar)]\002definition\002"
  return 0
 }
 set database [open $faq(database) r]
 set dbline ""
 set found 0
 while {![eof $database]} {
  gets $database dbline
  set dbfact [ string tolower [ lindex [split $dbline [string trim $faq(splitchar)]] 0 ] ]
  set dbdefinition [string range $dbline [expr [string length $fact]+1] end]
  if {$dbfact!=$fact} {
   lappend datalist $dbline
  } else {
   if {$dbdefinition!=$definition} {
    lappend datalist "$fact[string trim $faq(splitchar)]$definition"
    putnotc $nick "The keyword \002$fact\002 was modified correctly in my database."
    putnotc $nick "Is now: \002$fact\002 - $definition"
    putnotc $nick "Was: $dbfact - $dbdefinition"
    set found 1
   } else {
    lappend datalist $dbline
    putnotc $nick "I already had it that way. \002$fact\002 was not modified."
    putnotc $nick "Is: \002$fact\002 - $definition"
    set found 1
   }
  }
 }
 close $database
 set databaseout [open $faq(database) w]
 foreach line $datalist {
  if {$line!=""} {puts $databaseout $line}
 }
 close $databaseout
 if {$found != 1} {
  putnotc $nick "\002$fact\002 not found in my database"
  putnotc $nick "If you want to add the fact to the database use: [string trim $faq(cmdchar)]addword $fact[string trim $faq(splitchar)]\002description\002"
 }
}

proc faq:faq_howto {nick idx handle channel args} {
 global faq
 if { [lsearch -exact [split [string tolower $faq(channels)]] [string tolower $channel]] < 0 } {
  return 0
 }
 putnotc $nick "Help commands for FAQ Database $faq(version)"
 if {[matchattr $handle [string trim $faq(glob_flag)]|[string trim $faq(chan_flag)] $channel]} {
  if {$faq(status)==0} {
   putnotc $nick " - [string trim $faq(cmdchar)]close-faq"
   putnotc $nick " - [string trim $faq(cmdchar)]addword : [string trim $faq(cmdchar)]addword \002keyword\002[string trim $faq(splitchar)]your description goes here..."
   putnotc $nick " - [string trim $faq(cmdchar)]delword : [string trim $faq(cmdchar)]delword \002keyword\002"
   putnotc $nick " - [string trim $faq(cmdchar)]modify : [string trim $faq(cmdchar)]modify \002keyword\002[string trim $faq(splitchar)]your new description goes here..."
  }
  if {$faq(status)==1} {
   putnotc $nick " - [string trim $faq(cmdchar)]open-faq"
  }
 }
 if {$faq(status)==0} {
  putnotc $nick " - [string trim $faq(cmdchar)] \002keyword\002 : looks up keyword in the database"
  putnotc $nick " - To let the bot tell someone about something use [string trim $faq(cmdchar)]faq nick \002keyword\002"
 }
 if {$faq(status)==1} {
  putnotc $nick "The faq-database is \002closed\002."
 }
}
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Aug 12, 2005 6:49 pm    Post subject: Reply with quote

Use the [isop], [ishalfop] and [isvoice] commands to check if the user has +o, +h or +v. Read tcl-commands.doc about these three commands.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
draftmann
Voice


Joined: 12 Aug 2005
Posts: 3

PostPosted: Sat Aug 13, 2005 4:17 am    Post subject: Reply with quote

thanks for ur reply Sir_Fz, can u please fixed this for me coz i dont know much about tcl and its command Sad
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Aug 13, 2005 6:29 am    Post subject: Reply with quote

I'm not so interrested in fixing all that but if you help yourself then we'll defenitely help you.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
draftmann
Voice


Joined: 12 Aug 2005
Posts: 3

PostPosted: Sun Aug 14, 2005 12:23 am    Post subject: Reply with quote

Sir_Fz: i have no idea about scripting so can u please help me out.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

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


Forum hosting provided by Reverse.net

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