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 

How do I get this to accept msged commands

 
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
Amarth
Voice


Joined: 29 Sep 2005
Posts: 5

PostPosted: Thu Sep 29, 2005 9:19 am    Post subject: How do I get this to accept msged commands Reply with quote

Hi All,

The following script is largely the next.tcl v2.0 written by mortician. I have removed all the stuff I don't need and rewritten stuff in it to get it to work how I need it to. What the script does is records nicks on join, and then enables helpers to help each person, removing them off the list, so marking them served.

1.
Okay I have tried to get it to accept pm's for the commands, primarily the ones I need are !list, !served <nick> and !getlist. But what I have tried just doesn't seem to work. My tcl knowledge is mainly based on modifying existing scripts, so how do I get it to do this!

2.
in addition in join, rehash and getlist etc I know how to exclude it listing ops or particular users with flags, but I want it to also exclude nicks that have {} in them or are all in lower case. from being listed. How do I do that?

The script works, only with public commands. Here is the script:

Code:

# --------------------------------------------------------------------
#
#              ______________________________________
#             |                                      |
#             | served v1.0 by Amarth                |
#             | email: aramarth@hotmail.com          |
#             |                                      |
#             | original script next v2.0            |
#             |   by mortician                       |
#             | IRC:   irc.undernet.org - #mortician |
#             | email: mortician@linux.be            |
#             | www:   www.mortician.tk              |
#             |______________________________________|
#
#
# --------------------------------------------------------------------
# Commands
# --------------------------------------------------------------------
# Public Commands:
#   --> /msg <botnick> verify <nick/handle>
# Trainee Commands:
#   --> /msg <botnick> auth <pass>
#   --> /msg <botnick> deauth
# Regular Helper Commands:
#   --> !list              = notices you the list
#   --> !done              = notices you the list
#   --> !served <nick>     = remove <nick> from the list
#   --> !put <nick>        = puts <nick> into the list
#   --> !getlist           = rebuild the list
#   --> /msg <botnick> add <nick> <option>
#   --> /msg <botnick> del <nick>
#             = removes <nick> from the bots userlist
#
# --------------------------------------------------------------------
# History
# --------------------------------------------------------------------
# September 2005 v1.0 - created from the original script next.tcl v2.0
#                       by mortician
#
# --------------------------------------------------------------------
# VARIABLES
# you have to change these
# --------------------------------------------------------------------

   # The channel you will use this:
set next(chan) "#channelname"
   # the char that marks public commands (!next, etc...)
set next(char) "!"
   # automatic rebuild the offer list
   # users on the channel after a rehash? (1/0)
set next(rehash) "1"

# --------------------------------------------------------------------
# OTHER VARIABLES
# Don't cross this line unless you feel prepared to code
# --------------------------------------------------------------------
set next(list) {}
set next(chan) [string tolower $next(chan)]
set next(num2name) "none helper {helper2} {helper3} helper4 Owner"

# --------------------------------------------------------------------
# auth/deauth ... based on multi 3.3 by OUTsider
# --------------------------------------------------------------------
bind msg - auth next.msg:auth
bind msg - deauth next.msg:deauth
proc next.msg:auth {nick uhost hand rest} {
  global botnick
  set pw [lindex $rest 0]
  set op [lindex $rest 1]
  if {$pw == ""} {
  putnotc $nick "Usage: /msg $botnick auth <password> \[recover\]"
  return 0 }
  if {[matchattr $hand Q]} {
  if {[string tolower $op] == "recover"} {
  if {[passwdok $hand $pw]} {
  setuser $hand XTRA SECNICK $nick
  setuser $hand XTRA SECHOST $uhost
  putnotc $nick "New Identity confirmed. Recover Successful" }
  if {![passwdok $hand $pw]} {
  putnotc $nick "Wrong password. Recover failed !"
  return 0 }
  return 0 }
  putnotc $nick "You are already Authenticated."
  putnotc $nick "Nick: [getuser $hand XTRA SECNICK]"
  putnotc $nick "Host: [getuser $hand XTRA SECHOST]"
  putnotc $nick "Try to login with /msg $botnick auth <pass> recover"
  return 0 }
  if {[passwdok $hand $pw] == 1} {
  chattr $hand +Q
  putnotc $nick "Authentication successful!"
  setuser $hand XTRA SECNICK $nick
  setuser $hand XTRA SECHOST $uhost }
  if {[passwdok $hand $pw] == 0} {
  putnotc $nick "Authentication failed!" }}

proc next.msg:deauth {nick uhost hand rest} {
  if {[getuser $hand XTRA SECNICK] == $nick} {
  chattr $hand -Q
  setuser $hand XTRA SECNICK $nick
  setuser $hand XTRA SECHOST $nick
  putnotc $nick "DeAuthentication successful!" }}

# --------------------------------------------------------------------
# procs
# --------------------------------------------------------------------
proc next.check:authed {nick host hand} {
  global botnick
  if {![matchattr $hand +Q]} {
  putnotc $nick "You are not authenticated."
  putnotc $nick "Please do so with /msg $botnick auth <password>."
  return 0}
  if {[getuser $hand XTRA SECNICK] != $nick} {
  putnotc $nick "Sorry. But I think I missed one of your nickchanges"
  return 0}
  if {[getuser $hand XTRA SECHOST] != $host} {
  putnotc $nick "Sorry. But you don't have the correct host right now."
  return 0}
  return 1}

proc next.addflags {handle level} {
  global next
  switch $level {
  4 { chattr $handle +h|+fvJ $next(chan); return 1 }
  3 { chattr $handle +h|+fvM $next(chan); return 1 }
  2 { chattr $handle +h|+fvL $next(chan); return 1 }
  1 { chattr $handle +h|+fgvK $next(chan); return 1 }
  }
}

proc next.getlevel {handle} {
  global next
  if {[matchattr $handle n|n $next(chan)]} { return 5
  } elseif {[matchattr $handle J|J $next(chan)]} { return 4
  } elseif {[matchattr $handle M|M $next(chan)]} { return 3
  } elseif {[matchattr $handle L|L $next(chan)]} { return 2
  } elseif {[matchattr $handle K|K $next(chan)]} { return 1
  } else { return 0 }
}

# --------------------------------------------------------------------
# mode handlers
# --------------------------------------------------------------------
#### join / rejoin
proc next.add {nick uhost handle chan} {
   global botnick next
   if {$nick == $botnick | $nick == "Warrior" || [string tolower $chan] != $next(chan) || [matchattr $handle g|g $next(chan)] || [matchattr $handle K|K $next(chan)]} { return }
   lappend next(list) $nick
   set num [lsearch -exact $next(list) $nick]
   incr num
}
#### part & sign
proc next.purge {nick uhost handle chan msg} {
   global botnick next
   if {$nick == $botnick || $nick == "Warrior" || [string tolower $chan] != $next(chan) || [matchattr $handle g|g $next(chan)] || [matchattr $handle K|K $next(chan)]} { return }
   set index [lsearch -exact $next(list) $nick]
   if {$index >= 0} {
   set next(list) [lreplace $next(list) $index $index ]
   } else { return }
}
#### nick
proc next.replace {nick uhost handle chan newnick} {
   global botnick next
   if {$nick == $botnick || $nick == "Warrior" || [string tolower $chan] != $next(chan) || [matchattr $handle g|g $next(chan)] || [matchattr $handle K|K $next(chan)]} { return }
   set index [lsearch -exact $next(list) $nick]
   if {$index >= 0} {
   set next(list) [lreplace $next(list) $index $index $newnick]
   } else { return }
}
#### split
proc next.splt {nick uhost handle chan} {
   global botnick next
   if {$nick == $botnick || $nick == "Warrior" || [string tolower $chan] != $next(chan) || [matchattr $handle g|g $next(chan)] || [matchattr $handle K|K $next(chan)]} { return }
   set index [lsearch -exact $next(list) $nick]
   set next(list) [lreplace $next(list) $index $index ]
}
#### rehash
proc next.rehash {type} {
   global botnick next
   if {$next(rehash) && [botonchan $next(chan)]} {
   set llength [llength $next(list)]
   foreach user [chanlist $next(chan)] {
      if {![isvoice $user $next(chan)] && [onchan $user $next(chan)] && $user != $botnick && $user != "Warrior" && ![matchattr [nick2hand $user $next(chan)] K $next(chan)] && ![matchattr [nick2hand $user $next(chan)] g $next(chan)]} {
         set index [lsearch -exact $next(list) [lindex $user 0]]
         if {$index < 0} {
         set next(list) [linsert $next(list) $llength $user ]
         }
      }
   }
   }
}

# --------------------------------------------------------------------
# Regular command handlers
# --------------------------------------------------------------------
#### list
proc next.pub:list {nick uhost handle chan arg} {
   global next
   if {[string tolower $chan] != $next(chan)} { return 0 }
   if {[next.getlevel $handle] >= 1} {
   if {$next(list) == ""} { putserv "NOTICE $nick :there are no Free requiring service."
   return }
   putserv "NOTICE $nick :The following are waiting to be offered, type \002!served <nick>\002 once you have offered: $next(list)"; return
   } else { return 0 }
}
#### put
proc next.pub:put {nick uhost handle chan arg} {
   global botnick next
   if {[string tolower $chan] != $next(chan)} { return 0 }
   if {[next.getlevel $handle] >= 1} {
   if {[lindex [split $arg] 0] == ""} {putserv "NOTICE $nick :usage: .put <nick>"
   return }
   if {[lindex [split $arg] 0] == $botnick} {putserv "NOTICE $nick :this girl does not understand you?"
   return }
   if {[onchan [lindex [split $arg] 0] $next(chan)]} {lappend next(list) [lrange $arg 0 end]
   putserv "NOTICE $nick :[lindex [split $arg] 0] has been added to the offer list."
   return }
   putserv "NOTICE $nick :[lindex [split $arg] 0] isn't in $next(chan)"
   return
   } else { return }
}
#### served
proc next.pub:served {nick uhost handle chan arg} {
   global botnick next
   if {[string tolower $chan] != $next(chan)} { return 0 }
   if {[next.getlevel $handle] >= 1} {
   if {[lindex [split $arg] 0] == ""} {putserv "NOTICE $nick :\002Usage:\002 served <nick>"
   return}
   if {[lindex [split $arg] 0] == $botnick} {putserv "NOTICE $nick :this girl does not understand you?"
   return}
   set index [lsearch -exact $next(list) [lindex [split $arg] 0]]; set next(list) [lreplace $next(list) $index $index ]
   putserv "NOTICE $nick :[lindex [split $arg] 0] has been removed from the offer list."
   return
   } else { return }
}

# --------------------------------------------------------------------
# Channel Op command handlers
# --------------------------------------------------------------------
bind pub - ${next(char)}op next.pub:op
#### getlist
proc next.pub:getlist {nick uhost handle chan arg} {
   global botnick next
   if {[string tolower $chan] != $next(chan)} { return 0 }
   if {[next.getlevel $handle] >= 2} {
   set llength [llength $next(list)]
   foreach user [chanlist $chan] {
      if {![isvoice $user $chan] && [onchan $user $chan] && $user != $botnick && $user != "Warrior" && ![matchattr [nick2hand $nick $chan] K] && ![matchattr [nick2hand $nick $chan] g]} {
         set index [lsearch -exact $next(list) [lindex $user 0]]
         if {$index < 0} {
         set next(list) [linsert $next(list) $llength $user ]
         }
      }
   }
   if {$next(list) == ""} { putserv "NOTICE $nick :No Free to be added. Offer list is empty"
   } else {
   putserv "NOTICE $nick :\002offer list completed\002. ( $next(list) )"
   }
   return
   } else { return }
}

# --------------------------------------------------------------------
# Admin command handlers
# --------------------------------------------------------------------
bind msg m|m add next.msg:add
bind msg m|m del next.msg:del
#### add
proc next.msg:add {nick uhost handle arg} {
global next botnick
   if {![next.check:authed $nick $uhost $handle]} { return 0 }
   set who [lindex [split $arg] 0]
   set lvl [lindex [split $arg] 1]
   if {$who == "" || $lvl == ""} {putnotc $nick "Usage: /msg $botnick add <nick> <level>"; return 0}
   if {![onchan $who $next(chan)]} { putnotc $nick "Sorry, but I can't find $who on $next(chan)"; return 0 }
   if {[nick2hand $who $next(chan)] != "" && [nick2hand $who $next(chan)] != "*"} {
     putnotc $nick "$who is already known in the bot as [nick2hand $who $next(chan)], level [lindex $next(num2name) [next.getlevel $who]]"
     if {[next.getlevel $who] < 4} {
       if {$lvl == 4 || $lvl == 3 || $lvl == 2 || $lvl == 1} {
         next.addflags $who $lvl
         putnotc $nick "Added\002 $who \002as a\002 [lindex $next(num2name) $lvl] \002in $next(chan) to the bot."
         putnotc $who "You have been added as a\002 [lindex $next(num2name) $lvl] \002in $next(chan) to the bot."
         return 1
       } else {
         putnotc $nick "the option can be 1, 2, 3 or 4"
         return 0
       }
     }
   }
   if {[validuser $who]} { putnotc $nick "I was unable to add $who to the userlist. There is already a user with that handle"; return 0}
   if {$lvl == 1 || $lvl == 2 || $lvl == 3 || $lvl == 4} {
       set host "[maskhost $who![getchanhost $who $next(chan)]]"
       adduser $who $host
       putnotc $who "You have been added to the bot. Please set your pass: type /msg $botnick pass <your_pass>"
       putnotc $who "To authenticate, type /msg $botnick auth <password>"
       next.addflags $who $lvl
       putnotc $nick "Added\002 $who \002as a\002 [lindex $next(num2name) $lvl] \002in $next(chan) to the bot."
       return 1
   } else {
       putnotc $nick "the option can be 1, 2, 3 or 4"
       return 0
   }
}
#### del
proc next.msg:del {nick uhost handle arg} {
global next botnick
  if {![next.check:authed $nick $uhost $handle]} { return 0 }
  set who [lindex [split $arg] 0]
  if {$who == ""} {putnotc $nick "Usage: /msg $botnick del <nick>"; return 0}
  if {![onchan $who $next(chan)]} {putnotc $nick "Sorry. But I can't find\002 $who \002on $next(chan)"; return 0}
  if {[nick2hand $who $next(chan)] == "" || [nick2hand $who $next(chan)] == "*"} {
     putnotc $nick "Sorry. But I can't find\002 $who \002 in the userlist"
  return 0 }
  if {[next.getlevel [nick2hand $who $next(chan)]] >= [next.getlevel [nick2hand $nick $next(chan)]]} {
     putnotc $nick "Sorry. But you can't delete a user with an eqaul or higher level then yourself"
  return 0 }
  deluser [nick2hand $who $next(chan)]
  putnotc $nick "Deleted\002 $who \002from the userlist"
}

proc next.status {arg} {
global next
  switch $arg {
   on {
      bind join - * next.add
      bind rejn - * next.add
      bind part - * next.purge
      bind sign - * next.purge
      bind nick - * next.replace
      bind splt - * next.splt
      bind mode - *+v* next.voiced
      bind mode - *+o* next.voiced
      bind evnt - rehash next.rehash


      bind pub - ${next(char)}helped next.pub:helped
      bind pub - ${next(char)}done next.pub:list
      bind pub - ${next(char)}list next.pub:list
      bind pub - ${next(char)}served next.pub:served
      bind pub - ${next(char)}put next.pub:put
      bind pub - ${next(char)}getlist next.pub:getlist
   return 1}
   off {
      catch { unbind join - * next.add }
      catch { unbind rejn - * next.add }
      catch { unbind part - * next.purge }
      catch { unbind sign - * next.purge }
      catch { unbind nick - * next.replace }
      catch { unbind splt - * next.splt }
      catch { unbind mode - *+v* next.voiced }
      catch { unbind mode - *+o* next.voiced }
      catch { unbind evnt - rehash next.rehash }

      catch { unbind pub - ${next(char)}helped next.pub:helped }
      catch { unbind pub - ${next(char)}done next.pub:list }
      catch { unbind pub - ${next(char)}list next.pub:list }
      catch { unbind pub - ${next(char)}served next.pub:served }
      catch { unbind pub - ${next(char)}put next.pub:put }
      catch { unbind pub - ${next(char)}getlist next.pub:getlist }
   return 1}
  }
}

# --------------------------------------------------------------------
# the end
# --------------------------------------------------------------------
next.status on
putlog ".served $next(version) by Amarth modified from a script by mortician loaded ..."


I'd really appreciate any help that anyone could give Me!
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Thu Sep 29, 2005 12:58 pm    Post subject: Re: How do I get this to accept msged commands Reply with quote

Amarth wrote:
2.
in addition in join, rehash and getlist etc I know how to exclude it listing ops or particular users with flags, but I want it to also exclude nicks that have {} in them or are all in lower case. from being listed. How do I do that?

okay, the easy one first:
[string match {*[{}]*} $nick] will return 1 if the nick contains braces
[string is lower $ick] will return 1 if the nick only contains lowercase characters, but will be 0 if it contains any non alphabetical characters, so you might want this one:
[string match {*[A-Z]*} $nick] will return 1 if the nick contains any uppercase character
just put them the conditions before you add them in a logical expression Very Happy.

Amarth wrote:
1.
Okay I have tried to get it to accept pm's for the commands, primarily the ones I need are !list, !served <nick> and !getlist. But what I have tried just doesn't seem to work. My tcl knowledge is mainly based on modifying existing scripts, so how do I get it to do this!

It seems you deleted the "bind" commands to link the procs with the outworld. Please remeber to remove "chan" from the argument list and check the proc if it doesnt require $chan, if you move a proc from pub to msg bind.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
Amarth
Voice


Joined: 29 Sep 2005
Posts: 5

PostPosted: Thu Sep 29, 2005 11:05 pm    Post subject: Reply with quote

Excellent, thanks heaps for your help! Funny how a simple thing can be the most annoying to work out!
Back to top
View user's profile Send private message
De Kus
Revered One


Joined: 15 Dec 2002
Posts: 1361
Location: Germany

PostPosted: Fri Sep 30, 2005 5:17 am    Post subject: Reply with quote

ah sorry, just saw the binds are there, they will just only be activated if the the script has been enabled @_o.
_________________
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Back to top
View user's profile Send private message MSN Messenger
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