This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Script edit request.

Old posts that have not been replied to for several years.
Locked
a
ac1d
Voice
Posts: 15
Joined: Mon May 02, 2005 2:02 am

Script edit request.

Post by ac1d »

hello. i'm using infobot style script which is made for korean language.
if i could get in touch to the author i would request to him.
but this script is a bit old and can't get in touch with author.
when someone add new topic. it creates topic named text file in egghome/odic.
but the problem is this script checks cases.
i want to edit it to get stored description whatever it's upper or lower case.
(author commented that this script can be edited w/o his approval)

please help! and sorry for some languages in code that you can't understand.

Code: Select all

bind pubm - * odic:handler

set odic_whatis_list {"*뭐야*" "*모야*" "*머야*" "*뭘까*" "*몰까*" "*멀까*" "*뭐지*" "*모지*" "*머지*" "*뭐냐*" "*모냐*" "*머냐*" "*뭡니까*" "*몹니까*" "*멉니까*" "*뭐죠*" "*모죠*" "*머죠*" "*뭐에요*" "*모에요*" "*머에요*" "*뭐니*" "*모니*" "*머니*" "*뭐지요*" "*모지요*" "*뭐지요*" "*뭔데*" "*몬데*" "*먼데*" "*뭔대*" "*몬대*" "*먼대*"}
set odic_add "!추가 *"
set odic_del "!삭제 *"
set odic_help_list {"*도와*" "*도움*" "*help*"}
set odic_max_term 20
set odic_max_comment 200
set odic_botname $nick
set odic_data_dir "./odic"

proc odic:handler {nick uhost handle chan txt} {
    global odic_whatis_list
    global odic_help_list
    global odic_add
    global odic_del
    global odic_botname

    if {[string match $odic_botname $nick]} {
        return 0
    }

    if {[string match $odic_add $txt]} {
        return [odic:add $nick $uhost $handle $chan $txt]
    } elseif {[string match $odic_del $txt]} {
        return [odic:del $nick $uhost $handle $chan $txt]
    }

    foreach whatis_item $odic_whatis_list {
        if {[string match $whatis_item $txt]} {
            return [odic:whatis $nick $uhost $handle $chan $txt $whatis_item]
        }
    }

    foreach help_item $odic_help_list {
        if {[string match $help_item $txt]} {
            return [odic:help $nick $uhost $handle $chan $txt]
        }
    }

    return 0
}

proc odic:help {nick uhost handle chan txt} {
    global odic_botname
    puthelp "PRIVMSG $chan :$odic_botname 도움말"
    puthelp "PRIVMSG $chan :!추가 (단어) (뜻)"
    puthelp "PRIVMSG $chan :!삭제 (단어)"
    puthelp "PRIVMSG $chan :(단어) 뭐야?"
    puthelp "PRIVMSG $chan :만든이"
    puthelp "PRIVMSG $chan :Taeho Oh ( ohhara@postech.edu )  http://ohhara.sarang.net"
    return 1
}

proc odic:whatis {nick uhost handle chan txt whatis_item} {
    global odic_max_term
    global odic_data_dir
    set get_term 0

    regsub -all \\\* $whatis_item "" new_whatis_item
    if {[regexp (\[^\ \]+)$new_whatis_item $txt dummy term]} {
        set get_term 1
    }
    if {[regexp (\[^\ \]+)\ $new_whatis_item $txt dummy term]} {
        set get_term 1
    }
    if {[string length $term] > $odic_max_term} {
        set get_term 0
    }

    if {$get_term == 0} {
        return 0
    }

    regsub -all \[^0-9a-zA-Z_\x80-\xff\] $term "_" term

    if [catch {open $odic_data_dir/$term r} fd] {
        puthelp "PRIVMSG $chan :난 $term 뭔지 잘 몰라. 나한테 묻지 마."
        return 0
    }

    puthelp "PRIVMSG $chan :$term? 나는 이렇게 알고 있어."
    set index_num 0
    while {![eof $fd]} {
        set read_line [gets $fd]
        if {[string length $read_line] > 0} {
            incr index_num
            puthelp "PRIVMSG $chan :$index_num. $read_line"
        }
    }
    close $fd

    return 1
}

proc odic:add {nick uhost handle chan txt} {
    global odic_max_term
    global odic_max_comment
    global odic_data_dir
    set term [lindex $txt 1]
    set comment [lrange $txt 2 end]

    if {[string length $term] > $odic_max_term} {
        puthelp "PRIVMSG $chan :$term - 너무 깁니다."
        return 0
    }

    if {[string length $comment] > $odic_max_comment} {
        puthelp "PRIVMSG $chan :$comment - 너무 깁니다."
        return 0
    }

    regsub -all \[^0-9a-zA-Z_\x80-\xff\] $term "_" term

    set fd [open $odic_data_dir/$term {WRONLY APPEND CREAT}]
    puts $fd "$comment by $nick"
    close $fd
    puthelp "PRIVMSG $chan :$term - $comment by $nick - 추가되었습니다."

    return 1
}

proc odic:del {nick uhost handle chan txt} {
    puthelp "PRIVMSG $chan :삭제 기능은 제공하지 않습니다. 귀찮아서 넣지 않았습니다. -_-;;;;"
    return 0
}

putlog "odic start"
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

try adding this line:
set term [string tolower $term]

after both 'regsub -all \[^0-9a-zA-Z_\x80-\xff\] $term "_" term' lines. this should archieve your desired effect.
remember to make all existing data files to lowercase!

PS: sorry, I meant the files in the odic data dir :D
Last edited by De Kus on Mon May 02, 2005 12:26 pm, edited 1 time in total.
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...
a
ac1d
Voice
Posts: 15
Joined: Mon May 02, 2005 2:02 am

Post by ac1d »

Thanks a lot De Kus.
it's working as what i wanted!!
you were very helpfull btw don't need to make .user file to lower case?
i just changed .chan files to lower case as you pointed me.
but just curious if .user files need to be changed to lower case
once again THANK YOU
Locked