| View previous topic :: View next topic |
| Author |
Message |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Nov 21, 2020 1:48 am Post subject: Karma.tcl |
|
|
So, "Trying" to get this script to work, would appreciate if someone can guide me the right direction
| Code: |
###################################
#Karma 1.0 ComputerTech
###################################
#Usage
###################################
#!++nick 1 << Increases nicks reputation to +1
array set act {
++
--
}
set actcmd "!"
bind pub - "${actcmd}$act*" do:act:hehe
proc do:act:hehe {nick host hand chan text} {
set var0 "[lindex [split $text] 0 ]"
set blah($var0) 0
if {[$act eq "++"]} { ;incr blah($var0) +1
} else {
incr blah($var0) -1
putserv "PRIVMSG $chan :$var0 now has Reputation blah($var0)"
}
}
|
it's meant to be a !karma script
like one from bitbot, so you do !nick++ to increase their reputation, and !nick-- to decrease their reputation, thanks in advanced  _________________ ComputerTech |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Nov 21, 2020 6:21 am Post subject: |
|
|
You'll have to bind pubm and not pub if you want to get the command.
With pub, the text contains everything following the command.
Try something like:
| Code: | bind pubm - "#% ${actcmd}%++" do:act:hehe
bind pubm - "#% ${actcmd}%--" do:act:hehe |
(not tested, I don't remember if - and + are in the % wildcard)
Nota: in your code, you say "!++nick" and "!--nick" and in your post you say "!nick++" and "!nick--"... Chose  _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Nov 21, 2020 9:45 am Post subject: |
|
|
Ah hehe, i'll stick to "!nick++" and "!nick--"
And how would i check if !nick++ or !nick-- was used?
Like to use "if" command to find which one was used?
Thanks in advanced
EDIT, another thing, how can i check if blah($var0) is -1 or +1, so if rhe current amount is +1 it will show on the putserv "output" either + or - with the value, Make sense?  _________________ ComputerTech
Last edited by ComputerTech on Sat Nov 21, 2020 9:55 am; edited 1 time in total |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Nov 21, 2020 9:54 am Post subject: |
|
|
I made tests.
The bind pubm - "#% !%++" works well, but if you want to allow extra characters you need to add * at the end:
| Code: | .tcl proc karma {nick uhost handle chan text} { putlog "binded with $text"}
.tcl bind pubm - "#% !%++" karma
<me> !rasp++
[14:49] triggering bind karma
[14:49] binded with !rasp++
<me> !rasp++ test
(nothing)
[14:49] triggering bind karma
.tcl bind pubm - "#% !%++*" karma
<me> !rasp++ test
[14:53] triggering bind karma
[14:53] binded with !rasp++ test |
Your proc must get the first item of $text and cut it:
1st char is the command symbol (!)
Last 2 chars are the modifier (++ or --)
Everyting else is the nick:
| Code: | set text [lindex $text 0]
set cmd [string index $text 0]
set mod [string range $text end-1 end]
set unick [string range $text 1 end-2] |
| Code: | .tcl set text !rasp++
[14:58] tcl: builtin dcc call: *dcc:tcl CrazyCat 12 set text !rasp++
[14:58] tcl: evaluate (.tcl): set text !rasp++
Tcl: !rasp++
.tcl set cmd [string index $text 0]
[14:58] tcl: builtin dcc call: *dcc:tcl CrazyCat 12 set cmd [string index $text 0]
[14:58] tcl: evaluate (.tcl): set cmd [string index $text 0]
Tcl: !
.tcl set mod [string range $text end-1 end]
[14:58] tcl: builtin dcc call: *dcc:tcl CrazyCat 12 set mod [string range $text end-1 end]
[14:58] tcl: evaluate (.tcl): set mod [string range $text end-1 end]
Tcl: ++
.tcl set unick [string range $text 1 end-2]
[14:59] tcl: builtin dcc call: *dcc:tcl CrazyCat 12 set unick [string range $text 1 end-2]
[14:59] tcl: evaluate (.tcl): set unick [string range $text 1 end-2]
Tcl: rasp |
_________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Nov 21, 2020 10:01 am Post subject: |
|
|
And actually seems i made a typo last night (tired last night)
The way it should work is
original start of per nick is 0, neither + or -
so
!nick++
| Code: |
Putserv "PRIVMSG $chan :$var0 now has Reputation +1"
|
!nick--
| Code: |
Putserv "PRIVMSG $chan :$var0 now has Reputation 0"
|
!nick--
| Code: |
Putserv "PRIVMSG $chan :$var0 now has Reputation -0"
|
hope this clears it a bit  _________________ ComputerTech |
|
| Back to top |
|
 |
CrazyCat Revered One

Joined: 13 Jan 2002 Posts: 1032 Location: France
|
Posted: Sat Nov 21, 2020 1:49 pm Post subject: |
|
|
I don't understand your trouble:
| Code: | if {[$act eq "++"]} {
incr blah($var0)
} elseif {[$act eq "--"] && blah($var0)>0} {
incr blah($var0) -1
}
putserv "PRIVMSG $chan :$var0 now has Reputation blah($var0)"
|
do you want to display "-0" if someone try to decrease karma when it's already equal to 0? _________________ https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community. |
|
| Back to top |
|
 |
ComputerTech Master

Joined: 22 Feb 2020 Posts: 393
|
Posted: Sat Jan 30, 2021 8:02 pm Post subject: |
|
|
Basically if -0. it will show -1 and not just keep 0 as the lowest number, so if - rhat will fall into the hated category and if above -0 it will be on the love side
All new nicks will start off with 0 neither + or -
Example
| Code: |
!love nick will make it +1
!hate nick will make it -1
|
hope that makes sense
I am.not sure if incr will make a number below 0 a - ? i never tried that heh,  _________________ ComputerTech |
|
| Back to top |
|
 |
|