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 

Rep.tcl by Luminous

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Thu Nov 04, 2010 12:54 pm    Post subject: Rep.tcl by Luminous Reply with quote

This doesn't seem to work for me, for some reason....

Any chance someone could edit this script so that adding reputation will be via private?


Code:

## Rep.tcl-v.1.1.0
## Author: Luminous
## Support: pm on egghelp.org

## This is a public script for voiced and opped users to add or remove reputation points to/from users. Its intended use is to keep track of positively and negatively contributing users, similar to forums with reputation systems. Points will be logged to the file "~/eggdrop/rep.txt". Note that everyone starts off at 0 or "neutral" points and does not show up as having reputation via !rep or !rep NICK until they reach negative or positive points. If points are removed from a user not in the file, they are automatically given -1. If rep is added to a user not in the file, they are automatically given 1. The plus/minus increments work normally from there unless the user reaches 0, or neutral, again.

## Commands

# All commands are public

# To add a reputation point to a user, use "NICK++"

# To remove a reputation point, use "NICK--"

# To view the reputation points of a specific user, use "!rep NICK"

# To view all reputation, use "!rep". A list will be noticed you slowly to avoid flooding.

# Set below the char you want to trigger the "rep" functions with:

set bchar "!"

## Code starts, edit beyond here at your own risk

bind pubm * * rep
proc rep {nick host hand chan text} {
 global bchar
    if {[regexp -nocase {^\S+\+\+$} $text] || [regexp -nocase {^\S+--$} $text] || [regexp "^${bchar}rep.*" $text]} {
        if {![isvoice $nick $chan] && ![matchattr $hand |o $chan]} {
            return
        }
        if {![file exists "rep.txt"]} {
            close [open "rep.txt" w]
        }
        set fs [open "rep.txt"]
        set data [split [read -nonewline $fs] \n]
        close $fs
        if {[regexp -nocase {^\S+\+\+$} $text]} {
            set whom [join [lindex [split $text +] 0]]
            if {[string equal -nocase "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom]" "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $nick]"]} {
                putserv "NOTICE $nick :You cannot rep yourself."
                return
            }
            set match [lsearch $data "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom] *"]   
            if {$match == -1} {
                if {![llength $data]} {
                    set fs [open "rep.txt" w]
                } else {
                    set fs [open "rep.txt" a]
                }
                puts $fs "$whom 1"
                close $fs
                putserv "PRIVMSG $chan :$whom now has 1 reputation point."
                return 0
            } else {
                set line [lindex $data $match]
                set rep [lindex $line 1]
                  incr rep
      if {$rep == 0} {
                    set lines [lreplace $data $match $match]
      } else {
                    set newline "$whom $rep"
                    set lines [lreplace $data $match $match $newline]
                }
                set fs [open "rep.txt" w]
                puts $fs [join $lines "\n"]
                close $fs
      if {$rep == 0} {
                    putserv "PRIVMSG $chan :$whom now has neutral reputation points."
      } elseif {$rep == -1} {
                    putserv "PRIVMSG $chan :$whom now has $rep reputation point."
      } else {
                    putserv "PRIVMSG $chan :$whom now has $rep reputation points."
      }
       }
        } elseif {[regexp -nocase {^\S+--$} $text]} {
            set whom [join [lindex [split $text -] 0]]
            set match [lsearch $data "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom] *"]
            if {$match == -1} {
                if {![llength $data]} {
                    set fs [open "rep.txt" w]
                } else {
                    set fs [open "rep.txt" a]
                }
                puts $fs "$whom -1"
                close $fs
                putserv "PRIVMSG $chan :$whom now has -1 reputation point."
                return
            }
            set line [lindex $data $match]
            set rep [lindex $line 1]
            incr rep -1
            set newline "$whom $rep"
            if {$rep == 0} {
                set lines [lreplace $data $match $match]
                set check 0
            } elseif {$rep == 1} {
                set lines [lreplace $data $match $match $newline]
                set check 1
            } else {
                set lines [lreplace $data $match $match $newline]
                set check 2   
       }
            set fs [open "rep.txt" w]
            puts $fs [join $lines "\n"]
            close $fs
            if {$check == 0} {
                putserv "PRIVMSG $chan :$whom now has neutral reputation points."
            } elseif {$check == 1} {
      putserv "PRIVMSG $chan :$whom now has 1 reputation point."
            } else {
            putserv "PRIVMSG $chan :$whom now has $rep reputation points."
       }
   } elseif {[string equal "${bchar}rep" $text]} {
            if {![llength $data]} {
      putserv "PRIVMSG $chan :No one currently has any reputation points."
                return 0
       }
            putserv "NOTICE $nick :   The reputation list is as follows:"
            set fs [open "rep.txt"]
            while {[gets $fs line] >= 0} {
                set rep [join [lindex [split $line] 1]]
                if {$rep == 1 || $rep == -1} {
                    puthelp "NOTICE $nick :[join [lindex [split $line] 0]] has $rep reputation point."
                } else {
                    puthelp "NOTICE $nick :[join [lindex [split $line] 0]] has $rep reputation points."
                }
            }
            puthelp "NOTICE $nick :   End of reputation list"
            close $fs
        } elseif {[string match -nocase "${bchar}rep *" $text]} {
            if {[llength [split $text]] != 2} {
              return
            }
        set whom [string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} [join [lindex [split $text] end]]]
       regsub -all {\s} $whom ""
        set line [lsearch $data "$whom *"]
        if {$line != -1} {
        set line [lindex $data $line]
        set whom [string map {"\\\]" "\]" "\\\[" "\[" "\\\{" "\{" "\\\}" "\}"} $whom]
            if {[lindex [split $line] 1] == 1 || [lindex [split $line] 1] == -1} {
           putserv "PRIVMSG $chan :$whom has [lindex [split $line] 1] reputation point."
            } else {
           putserv "PRIVMSG $chan :$whom has [lindex [split $line] 1] reputation points."
            }
        } else {
           putserv "PRIVMSG $chan :$whom has no reputation points"
        }
   }
    }        
  return
}

putlog " -rep.tcl loaded"

_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Fri Nov 12, 2010 10:40 am    Post subject: Reply with quote

Sorry, just now saw this:

Code:

## Rep.tcl-v.1.1.1
## Author: Luminous
## Support: pm on egghelp.org

## This is a private script for users to add or remove reputation points to/from users. Its intended use is to keep track of positively and negatively contributing users, similar to forums with reputation systems. Points will be logged to the file "~/eggdrop/rep.txt". Note that everyone starts off at 0 or "neutral" points and does not show up as having reputation via !rep or !rep NICK until they reach negative or positive points. If points are removed from a user not in the file, they are automatically given -1. If rep is added to a user not in the file, they are automatically given 1. The plus/minus increments work normally from there unless the user reaches 0, or neutral, again.

## Commands

# All commands are public

# To add a reputation point to a user, use "NICK++"

# To remove a reputation point, use "NICK--"

# To view the reputation points of a specific user, use "!rep NICK"

# To view all reputation, use "!rep". A list will be privmsg'd to you slowly to avoid flooding.

# Set below the char you want to trigger the "rep" functions with:

set bchar "!"

## Code starts, edit beyond here at your own risk

bind msgm * * rep
proc rep {nick host hand text} {
 global bchar
    if {[regexp -nocase {^\S+(\+\+|--)$} $text] || [regexp "^${bchar}rep.*" $text]} {
        if {![file exists "rep.txt"]} {
            close [open "rep.txt" w]
        }
        set fs [open "rep.txt"]
        set data [split [read -nonewline $fs] \n]
        close $fs
        if {[regexp -nocase {^\S+\+\+$} $text]} {
            set whom [join [lindex [split $text +] 0]]
            if {[string equal -nocase "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom]" "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $nick]"]} {
                putserv "PRIVMSG $nick :You cannot rep yourself."
                return
            }
            set match [lsearch $data "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom] *"]   
            if {$match == -1} {
                if {![llength $data]} {
                    set fs [open "rep.txt" w]
                } else {
                    set fs [open "rep.txt" a]
                }
                puts $fs "$whom 1"
                close $fs
                putserv "PRIVMSG $nick :$whom now has 1 reputation point."
                return 0
            } else {
                set line [lindex $data $match]
                set rep [lindex $line 1]
                  incr rep
      if {$rep == 0} {
                    set lines [lreplace $data $match $match]
      } else {
                    set newline "$whom $rep"
                    set lines [lreplace $data $match $match $newline]
                }
                set fs [open "rep.txt" w]
                puts $fs [join $lines "\n"]
                close $fs
      if {$rep == 0} {
                    putserv "PRIVMSG $nick :$whom now has neutral reputation points."
      } elseif {$rep == -1} {
                    putserv "PRIVMSG $nick :$whom now has $rep reputation point."
      } else {
                    putserv "PRIVMSG $nick :$whom now has $rep reputation points."
      }
       }
        } elseif {[regexp -nocase {^\S+--$} $text]} {
            set whom [join [lindex [split $text -] 0]]
            set match [lsearch $data "[string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} $whom] *"]
            if {$match == -1} {
                if {![llength $data]} {
                    set fs [open "rep.txt" w]
                } else {
                    set fs [open "rep.txt" a]
                }
                puts $fs "$whom -1"
                close $fs
                putserv "PRIVMSG $nick :$whom now has -1 reputation point."
                return
            }
            set line [lindex $data $match]
            set rep [lindex $line 1]
            incr rep -1
            set newline "$whom $rep"
            if {$rep == 0} {
                set lines [lreplace $data $match $match]
                set check 0
            } elseif {$rep == 1} {
                set lines [lreplace $data $match $match $newline]
                set check 1
            } else {
                set lines [lreplace $data $match $match $newline]
                set check 2   
       }
            set fs [open "rep.txt" w]
            puts $fs [join $lines "\n"]
            close $fs
            if {$check == 0} {
                putserv "PRIVMSG $nick :$whom now has neutral reputation points."
            } elseif {$check == 1} {
      putserv "PRIVMSG $nick :$whom now has 1 reputation point."
            } else {
            putserv "PRIVMSG $nick :$whom now has $rep reputation points."
       }
   } elseif {[string equal "${bchar}rep" $text]} {
            if {![llength $data]} {
      putserv "PRIVMSG $nick :No one currently has any reputation points."
                return 0
       }
            putserv "PRIVMSG $nick :   The reputation list is as follows:"
            set fs [open "rep.txt"]
            while {[gets $fs line] >= 0} {
                set rep [join [lindex [split $line] 1]]
                if {$rep == 1 || $rep == -1} {
                    puthelp "PRIVMSG $nick :[join [lindex [split $line] 0]] has $rep reputation point."
                } else {
                    puthelp "PRIVMSG $nick :[join [lindex [split $line] 0]] has $rep reputation points."
                }
            }
            puthelp "PRIVMSG $nick :   End of reputation list"
            close $fs
        } elseif {[string match -nocase "${bchar}rep *" $text]} {
            if {[llength [split $text]] != 2} {
              return
            }
        set whom [string map {"\[" "\\\[" "\]" "\\\]" "\}" "\\\}"} [join [lindex [split $text] end]]]
       regsub -all {\s} $whom ""
        set line [lsearch $data "$whom *"]
        if {$line != -1} {
        set line [lindex $data $line]
        set whom [string map {"\\\]" "\]" "\\\[" "\[" "\\\{" "\{" "\\\}" "\}"} $whom]
            if {[lindex [split $line] 1] == 1 || [lindex [split $line] 1] == -1} {
           putserv "PRIVMSG $nick :$whom has [lindex [split $line] 1] reputation point."
            } else {
           putserv "PRIVMSG $nick :$whom has [lindex [split $line] 1] reputation points."
            }
        } else {
           putserv "PRIVMSG $nick :$whom has no reputation points"
        }
   }
    }       
  return
}

putlog " -rep.tcl loaded"


I did away with the voice/op check line and adjusted the main regexp line. Now anyone can use it via privmsg to your bot. If you want to limit it to the same channel flags, I'll need the name of your main channel to create a $chan arg, since $chan is no longer a standard arg with msgm.
Back to top
View user's profile Send private message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Sat Nov 13, 2010 2:49 pm    Post subject: Reply with quote

Thanks, another request:
Can you limit the number of times a user vote for reputation? like once for ++ and once for a -- ?
_________________
Idling at #Football, Quakenet.
Back to top
View user's profile Send private message
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Mon Nov 15, 2010 8:23 pm    Post subject: Reply with quote

I can. How long until you want it to reset? Note that scripting is on the back burners these days, with my new job, but I'll get to it. Smile
Back to top
View user's profile Send private message
Football
Master


Joined: 26 Dec 2008
Posts: 205
Location: Quakenet, #Football

PostPosted: Tue Nov 16, 2010 2:56 pm    Post subject: Reply with quote

Can you set it as a variable so that I can decide how long (in days) the default will be and just change it at the begining of the script if I want to?
_________________
Idling at #Football, Quakenet.
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 Support & Releases 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