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 

REQ: Small Modification of Bartender Script

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


Joined: 21 Apr 2008
Posts: 30

PostPosted: Sun Jun 13, 2010 1:25 pm    Post subject: REQ: Small Modification of Bartender Script Reply with quote

Hello Egghelp Community,

I have a bartender script that i would like to be slightly modified.

Basically, i would like only people who are currently opped or voiced to be able to use the trigger.

It would be fantastic if you could add some scripting where i can select either channels ops or channel voiced or everybody who can use the trigger
e.g. 'users able to access trigger 1. only ops
2. ops & voices
3. Everyone

Currently the script allows anyone to use it and people have been abusing it, spamming and such. Would be a great help to us if you TCL Gurus can come to our aid. Also any modifications you see fit would be welcome too.

I thank you all in advance and please find the script below (i included only the first part and a drink)
best regards,
Achilles

Code:

# Trigger
#############################################################################

set cmdz "!"

#############################################################################

bind pub - ${cmdz}booze pub_booze

proc pub_booze {nick uhost hand channel arg} {
  global botnick cmdz
    putquick "PRIVMSG $nick :1,13Bars Open! Heres what we got for ya:"
    putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
    putquick "PRIVMSG $nick :13,1${cmdz}Corona, ${cmdz}vodka"
    putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
    return 0
}

##############Start of the drinks#################

proc pub_corona {nick uhost hand channel arg} {
  global botnick
  set theNick $nick
  if { [llength $arg] == 1 } {
    set theNick [lindex [split $arg] 0]
  }
    putserv "PRIVMSG $channel :\001ACTION snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to you....enjoy mate"
    return 0       
}
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Thu Jan 31, 2013 5:09 pm    Post subject: Reply with quote

You only have to change

Quote:

set temp(type) "1"


1 = only voices
2 = only ops
3 = everyone

Code:

### temp(type) "1" (only voice users can use the command)
### temp(type) "2" (only op users can use the command)
### temp(type) "3" (everyone can use the command)

# Trigger
#############################################################################

set cmdz "!"

#############################################################################

bind pub - ${cmdz}booze pub_booze

set temp(type) "1"

proc pub_booze {nick uhost hand channel arg} {
   global botnick cmdz temp

   if {$temp(type) == "1"} {
      if {[isvoice $nick $channel]} {
         putquick "PRIVMSG $nick :1,13Bars Open! Heres what we got for ya:"
         putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
         putquick "PRIVMSG $nick :13,1${cmdz}Corona, ${cmdz}vodka"
         putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
         return 0
      }
   } elseif {$temp(type) == "2"} {
      if {[isop $nick $channel]} {
         putquick "PRIVMSG $nick :1,13Bars Open! Heres what we got for ya:"
         putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
         putquick "PRIVMSG $nick :13,1${cmdz}Corona, ${cmdz}vodka"
         putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
         return 0
      }
   } elseif {$temp(type) == "2"} {
      putquick "PRIVMSG $nick :1,13Bars Open! Heres what we got for ya:"
      putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
      putquick "PRIVMSG $nick :13,1${cmdz}Corona, ${cmdz}vodka"
      putquick "PRIVMSG $nick :------------------------------------------------------------------------------------------------"
      return 0
   }
}

##############Start of the drinks#################

proc pub_corona {nick uhost hand channel arg} {
   global botnick temp

   if {$temp(type) == "1"} {
      if {[isvoice $nick $channel]} {
         set theNick $nick
         if { [llength $arg] == 1 } {
            set theNick [lindex [split $arg] 0]
         }
         putserv "PRIVMSG $channel :\001ACTION snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to you....enjoy mate"
         return 0
      }
   } elseif {$temp(type) == "2"} {
      if {[isop $nick $channel]} {
         set theNick $nick
         if { [llength $arg] == 1 } {
            set theNick [lindex [split $arg] 0]
         }
         putserv "PRIVMSG $channel :\001ACTION snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to you....enjoy mate"
         return 0
      }
   } elseif {$temp(type) == "3"} {
      set theNick $nick
      if { [llength $arg] == 1 } {
         set theNick [lindex [split $arg] 0]
      }
      putserv "PRIVMSG $channel :\001ACTION snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to you....enjoy mate"
      return 0
   }
}

_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Feb 01, 2013 6:07 am    Post subject: Reply with quote

Here's my attempt to do this:
Code:

dict set drinks "beer" "snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to you....enjoy mate"
dict set drinks "vodka" "here you go, knock yourself out!"
dict set drinks "tea" "I'm out  of tea, sorry.."

# 0 - everyone, 1 - currently opped or voiced
setudef int serving

bind pubm * "% !*" drink:order
bind pub * !drinks drink:menu

proc drink:order {nick uhost hand chan text} {
   set drink [lindex [split $text !] 1]
   if {[channel get $chan serving]} {
      if {[isop $nick $chan] || [isvoice $nick $chan]} {
         drink:serve $nick $chan $drink
      }
   } else {
      drink:serve $nick $chan $drink
   }
}

proc drink:serve {nick chan drink} {
   global drinks
   if {[string length $drink]} {
      if {[lsearch -nocase [dict keys $drinks] $drink] != -1} {
         puthelp "PRIVMSG $chan :[dict get $drinks $drink]"
      }
   }
}

proc drink:menu {nick uhost hand chan text} {
   if {[channel get $chan serving]} {
      if {[isop $nick $chan] || [isvoice $nick $chan]} {
         drink:fetch $nick $chan
      }
   } else {
      drink:fetch $nick $chan
   }
}

proc drink:fetch {nick chan} {
   puthelp "PRIVMSG $chan :Drinks currently available: [join [dict keys $::drinks] ", "]"
}

Feel free to add \001ACTION or whatever you wish.

Edit: Fixed. Damn typo.. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.


Last edited by caesar on Fri Feb 01, 2013 3:29 pm; edited 3 times in total
Back to top
View user's profile Send private message
Madalin
Master


Joined: 24 Jun 2005
Posts: 310
Location: Constanta, Romania

PostPosted: Fri Feb 01, 2013 6:10 am    Post subject: Reply with quote

Heh Smile ive modifyed its code if i was to create another one it was smaller of course Razz
_________________
https://github.com/MadaliNTCL - To chat with me: https://tawk.to/MadaliNTCL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Fri Feb 01, 2013 3:02 pm    Post subject: Reply with quote

Code:
# Tcl 8.4 friendly version .. 8)
# credit: caesar
# enable: .chanset #chan +serving

# Amount of drinks each person may
# request in a certain amount of time
# 3:30 means 3 drinks in 30 seconds
# the 4th is throttled until 30 seconds has
# elapsed from their first drink.
#
set drinkThrottle 3:30

# about the array:
# %nick will become $nick (the nickname)
# %chan will become $chan (the channel)
# \n will make the output span onto a new line.
#
array set drinks {
 corona "\001ACTION snaps off the top of a long-necked, ice cold Corona, slips in a slice of lime and hands it to %nick\001\nEnjoy mate."
 coors "\001ACTION pisses in a mug then slides it down the bar to %nick.\001\nDrink up %nick!"
 bud "Um...%nick, we don't serve that in %chan...\nTry a gay bar.. haw!"
 vodka "here you go %nick, knock yourself out!\n\001ACTION slides a shot down the bar to %nick.\001"
 tea "I'm out of tea, sorry %nick..\nOh wait, I do have tea.\nWait, no I don't.. :P"
 tip "%nick better follow the rules in %chan.\nOr does %nick want a nice kickban instead?"
}

setudef flag serving

bind pubm - "% !*" drink:order
bind pub - !drinks drink:menu

proc drink:order {nick uhost hand chan text} {
   if {[channel get $chan serving]} {
     foreach {drink type} [split $text] { break }
      if {[isop $nick $chan] || [isvoice $nick $chan]} {
         drink:serve $nick $uhost $chan [string range $drink 1 end] $type
      }
   }
}

proc drink:serve {nick uhost chan drink type} {
   global drinks
   if {[string length $drink]} {
      foreach name [array names drinks] { lappend lowerDrinks [string tolower $name] }
      if {[lsearch -exact $lowerDrinks $drink] != -1} {
         if {[set wait [throttle_ $uhost,$chan,drink [lindex $::drinkThrottle 1] [lindex $::drinkThrottle 0)]]] != 0} {
            putserv "privmsg $chan :$nick, please wait [lindex $wait 0] seconds for your next drink. You are above the drink request limit by [expr {[lindex $wait 1] - $::drinkAmount}] at the moment. Slow down..."
         } else {
            if {[string length $type] && [onchan $type $chan]} { set nick $type }
            foreach line [split $drinks($drink) \n] {
               puthelp "PRIVMSG $chan :[string map [list %chan $chan %nick $nick] $line]"
             }
         }
      }
   }
}

proc drink:menu {nick uhost hand chan text} {
   if {[channel get $chan serving]} {
      if {[isop $nick $chan] || [isvoice $nick $chan]} {
         drink:fetch $nick $chan
      }
   } else {
      drink:fetch $nick $chan
   }
}

proc drink:fetch {nick chan} {
   global drinks
   puthelp "PRIVMSG $chan :Drinks currently available: ![join [array names drinks] ", !"]"
}


# Throttle Proc (slightly altered, super action missles) - Thanks to user
# see this post: http://forum.egghelp.org/viewtopic.php?t=9009&start=3
proc throttle_ {id seconds amount} {
   if {[info exists ::throttled_($id)]&&[lindex $::throttled_($id) 0]>[clock seconds]} {
      set ::throttled_($id) [list [lindex $::throttled_($id) 0] [set value [expr {[lindex $::throttled_($id) 1] +1}]]]
      if {$value > $amount} { set id ::throttled_($id) } { set id 0 }
   } {
      set ::throttled_($id) [list [expr {[clock seconds]+$seconds}] 1]
      set id 0
   }
}
# delete expired entries every 10 minutes
bind time - ?0* throttleclean_
# sub - clean throttled users
proc throttleclean_ {args} {
   set now [clock seconds]
   foreach {id time} [array get ::throttled_] {
      if {[lindex $time 0]<=$now} {unset ::throttled_($id)}
   }
}
#eof


Edit1:
Modified post above from original. Since the script was corrected, here is a tcl8.4 friendly version of the same script. Also added a throttle system that will keep users from abusing and at the same time amusing.

Edit2:
Improved and added proactive throttle control.

Edit3:
Added ability to match intent of OP's original script:
!corona - the nick issuing !corona gets one.. yay
!corona <nick> - the nickname typed gets a corona if they are in channel otherwise the person typing it will.
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Fri Feb 01, 2013 7:54 pm; edited 30 times in total
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Feb 01, 2013 3:24 pm    Post subject: Reply with quote

meh.. was working with string map on another script and accidentally slipped it in instead of a simple join. Rolling Eyes

no, according to dict manual example I don't need to add [list]. and no. i intended to make serving an int as 0 means everyone and 1 only currently oped or voiced, and somehow after some tests ended with str.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

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


Forum hosting provided by Reverse.net

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