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 

Karma.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 216

PostPosted: Sat Nov 21, 2020 1:48 am    Post subject: Karma.tcl Reply with quote

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 Razz Razz
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 643
Location: France

PostPosted: Sat Nov 21, 2020 6:21 am    Post subject: Reply with quote

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 Smile
_________________
https://www.eggdrop.fr - French speaking IRC network
Offer me a coffee
Back to top
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 216

PostPosted: Sat Nov 21, 2020 9:45 am    Post subject: Reply with quote

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? Shocked

Thanks in advanced Razz


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? Rolling Eyes
_________________
ComputerTech


Last edited by ComputerTech on Sat Nov 21, 2020 9:55 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 643
Location: France

PostPosted: Sat Nov 21, 2020 9:54 am    Post subject: Reply with quote

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 speaking IRC network
Offer me a coffee
Back to top
View user's profile Send private message Visit poster's website
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 216

PostPosted: Sat Nov 21, 2020 10:01 am    Post subject: Reply with quote

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 Razz
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 643
Location: France

PostPosted: Sat Nov 21, 2020 1:49 pm    Post subject: Reply with quote

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 speaking IRC network
Offer me a coffee
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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