12-14-2017, 03:16 +0100
Search result (14)
All posts by: Gotisch
AuthorPost
Topic: physioroom (request)   Forum: workJob Offers & Requests      Goto post
Gotisch  07-15-2010, 22:02 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
if there is no pay i suggest a combined effort! ill start with
                                                                                                                              
1
2
3
# physioroom script
# (c) people in #tcl
namespace eval physioroom {

Topic: Problem: Werte aus text auslesen   Forum: workimminent problem solving      Goto post
Gotisch  10-29-2009, 15:28 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
Hallo,

deine idee ist eigentlich ok. in deinem code sind zwar einige fehler (wie zum beispiel der return nach dem du anzahl auf 10 setzt. dann wird ja nichts anderes mehr ausgeführt), aber das ist ja eh nur metacode nehm ich an.

zu deiner frage: wenn text die anzahl list kannst du einfach mit $text darauf zugreifen. du willst wahrscheinlich etwas machen wie:

set anzahl $text

aber vorher solltest du prüfen

1. ist $text eine zahl
2. wenn ja ist sie größer als 5
3. wenn ja ist sie kleiner als 20

(besser antwort 1 jahr zu spät als garnicht :)
Topic: gather   Forum: workJob Offers & Requests      Goto post
Gotisch  06-13-2009, 19:34 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
how much does it pay?
Topic: pubcmd.tcl   Forum: #tclcode snippets      Goto post
Gotisch  02-15-2009, 00:29 | pubcmd.tcl ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# help function

# converts special chars for match pattern
proc stringtopattern {string} {
    return [string map [list \\ \\\\ \[ \\\[ \] \\\] ] $string]
}

# do the mode for the command
proc do_mode {channel mode text} {
    # leave when bot dont has op
    if {![botisop $channel]} {return 0}
    # loop every user
    foreach nick [chanlist $channel] {
        # if your text match the nick and isnt himself
        if {![isbotnick $nick] && [string match [stringtopattern $text] $nick]} {
            # give op
            pushmode $channel $mode $nick
        }
    }
    # clear queue (not required)
    flushmode $channel
    # return with log
    return 1
}

# main function for binds/command/trigger
proc pub_op {nick userhost handle channel text} {
    return [do_mode $channel +o $text]
}
proc pub_deop {nick userhost handle channel text} {
    return [do_mode $channel -o $text]
}
proc pub_voice {nick userhost handle channel text} {
    return [do_mode $channel +v $text]
}
proc pub_devoice {nick userhost handle channel text} {
    return [do_mode $channel -v $text]
}

# bind/command/trigger for owner,master and ops
bind pub nmo|nmo !op pub_op
bind pub nmo|nmo !deop pub_deop
bind pub nmo|nmo !voice pub_voice
bind pub nmo|nmo !devoice pub_devoice


/me waves at shroud
This post was edited 1 times, last on 08-12-2009, 19:38 by thommey
Topic: [Site] Paste site   Forum: workscript announcements      Goto post
Gotisch  08-03-2008, 00:31 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
does it return the url of the paste?
Topic: [[TCL] Getting the source code of a web site]   Forum: workimminent problem solving      Goto post
Gotisch  04-09-2008, 01:44 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
                                                                                                                              
1
2
3
4
5
package require http; set thepage [http::data [set token [http::geturl "www.example.com"]]]; http::cleanup $token

foreach {line1 line2 line3} [split $thepage "\n"] {}

return "line1 = $line1 line2 = $line2 line3 = $line3"


oder so :)
Topic: Voting ("dynamisches" votescript)   Forum: workimminent problem solving      Goto post
Gotisch  04-09-2008, 01:40 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
kannst in der start proc ein array erstellen mit nicknames als keys.
Gleichzeitig startest du ein 40 sekunden timer.

dann im bind auf kill checks du ob der key vorhanden ist, wenn ja erhöhst du den um eins.

wenn der timer abgelaufen ist schaut er wo der wert amhöchsten ist und ruft fuer den nick die andere proc auf :)

hoffe das hilft.
Topic: *!*@213.239.199.181 (Why?)   Forum: #tclchannel related questions      Goto post
Gotisch  04-09-2008, 01:23 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
wow 8 hours for getting reconnected 4 times  :rolleyes: thats a bit harsh, don't you think  :vogel: ?
Topic: *!*@213.239.199.181 (Why?)   Forum: #tclchannel related questions      Goto post
Gotisch  11-25-2007, 23:52 | *!*@213.239.199.181 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
Why was i banned and for how long?

The webpage just says:
[   3] *!*@213.239.199.181
       Since 7 hours 46 minutes
What rule did i break?
...
Topic: Problem #1 (Test your TCL Skill.)   Forum: #tclchannel related questions      Goto post
Gotisch  06-12-2006, 22:33 | Problem #1 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
Given a time in numbers we can convert it into words. For example:

5:00 Five o'clock
5:10 Ten minutes past five
5:15 Quarter past five
5:30 Half past five
5:45 Quarter to six
5:47 Thirteen minutes to six

1
Write a program which inputs two numbers (the first between 1 and 12, the second between 0 and 59 inclusive) and then prints out the time they represent, in words. You should follow the format of the examples above. Your program should then terminate.


Language: TCL

Try to write this on your own. When your done post your responce here if you want. And maybe write why yours is better :)

This Problem is taken from Round 1 of BIO'97

SampleSolution as attachment;
Run gives:
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
C:\Dokumente und Einstellungen\Gotisch\Eigene Dateien>tclsh ClockSolution.tcl
ClockSolution (c) Gotisch
Please enter the hour(01-12):01
Please enter the minute(00-59):45
Its quarter to two

C:\Dokumente und Einstellungen\Gotisch\Eigene Dateien>tclsh ClockSolution.tcl
ClockSolution (c) Gotisch
Please enter the hour(01-12):01
Please enter the minute(00-59):00
Its one o'clock

C:\Dokumente und Einstellungen\Gotisch\Eigene Dateien>tclsh ClockSolution.tcl
ClockSolution (c) Gotisch
Please enter the hour(01-12):17
Please enter the minute(00-59):30
Its half past five

C:\Dokumente und Einstellungen\Gotisch\Eigene Dateien>

This post was edited 2 times, last on 06-12-2006, 23:34 by Gotisch
  The user has attached a file: ClockSolution.tcl (Save, 1,332 Bytes, downloaded 75 times)
Topic: [TCL] re_syntax (Examples for regexp and regsub)   Forum: #tclcode snippets      Goto post
Gotisch  04-25-2006, 21:31 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
Yes, more of those (also from other topics), i surely will get crazy enough eventually to put them all on a page, where it will stay longer and look clearer. This forum is more user2user, even if you cant make topics, we could move them, if they are good
Topic: [TCL] Randomize List   Forum: #tclcode snippets      Goto post
Gotisch  03-19-2006, 20:49 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
Imho this doesn't really randomize a list. I wrote this proc to check how big the probability is to find a entry at a certain position of the list:

                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
proc test {} {
    proc randlist {a b} { return [expr {int(rand()*2) ? -1 : 1}] }
    proc repeat { what {times 1}} {
        for {set a 0} {$a < $times} {incr a} {
            uplevel 1 $what
        }
    }
    puts "num    prob. to be found in list at that place:"
    puts "x    1    2    3    4    5    6    7    8    9    0"
    for {set i 0} { $i <= 9 } {incr i} {
        set prob [list $i]
        for {set j 0} { $j <= 9} { incr j} {
            set k 0
            repeat {if {[lsearch [lsort -command randlist [list 1 2 3 4 5 6 7 8 9 0]] $i] == $j} { incr k }} 1000
            lappend prob [expr {($k*100)/1000}]
        }
        puts [join $prob "    "]
    }
}


Running this gives us:
                                                                                                                              
01
02
03
04
05
06
07
08
09
10
11
12
num     prob. to be found in list at that place:
x       1       2       3       4       5       6       7       8       9       0
0       24      25      19      12      6       5       1       1       1       1
1       5       6       7       8       11      11      10      12      13      11
2       5       5       8       9       10      13      11      11      10      11
3       6       4       7       9       9       11      12      11      13      11
4       5       6       8       7       10      11      11      11      10      13
5       7       6       6       9       11      10      10      11      11      12
6       5       5       8       9       12      10      10      11      12      12
7       5       7       8       7       10      11      10      12      12      13
8       6       5       8       7       12      11      10      12      12      13
9       22      23      18      12      8       3       3       1       0       0

This means that the number 0 (last entry in list) has a probability to be in the first position of the list after the "randomisation" of 24%. On a perfect shuffle this should be 10% (100/(entries in list))
This "gap" gets smaller with more entries ( with 15 entries its barely noticable) but worse with less (with 5 entries the last entry has a prob of 50% to be first after the shuffle)

Or am i calculating it wrong?


for a more in dept discussion about shuffleling a list: http://wiki.tcl.tk/941
Topic: [EGG] Splitting long text into smaller parts for IRC output   Forum: #tclcode snippets      Goto post
Gotisch  02-18-2006, 16:13 ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
This will do the same                                                                                                                               
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
proc safesay {target text} {
    #there are 510 characters maximum allowed for the command and its parameters.
    #the command is
    #:nick!ident@host PRIVMSG target :text
    set nick $::botnick
    set host [getchanhost $nick]
    set maxlength [expr {510 - [string length $nick] - [string length $host] - [string length $target] - 14}]
    #putlog $maxlength
    #so now comes the trick
    while {[string length $text] > 0} {
        #lets get as much text as fits in one line:
        set output [string range $text 0 $maxlength]
        #putlog $output
        set text [string replace $text 0 $maxlength]
        putchan $target $output
    }
}

This post was edited 1 times, last on 08-14-2009, 04:29 by thommey
Topic: [EGG] Access (Allows to set a channelmode +Access who will check Q-auth against a db)   Forum: workscript announcements      Goto post
Gotisch  02-18-2006, 15:00 | [EGG] Access ICQ
(Moderator)
Member since 01/2006
19 Posts
Location: Europe
This script will check Q-Auths against a Database with at least two columns, where one defines the auth and the other the channel the auth has access to.

you can change access with the .access command (owners only) from the party line.

I was writing this for Someone but only for one channel. So i though just in case someone needs something like that to expand it to multiple chans.

                                                                                                                              
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#Access (c) gotisch
namespace eval Access {
    # Limit's Access to a Channel based on Q-Auth.
    # To check Q-Account we use: who nick n%nat,30
    # Config:
    variable mysql
    array set mysql {
        pkg        ""
        host    "localhost"
        user    "user"
        pass    "pass"
        db        "db"
        table    "access"
        ncol    "account"
        ccol     "channel"
    }
    #No need to change that prob.
    variable num 100
    variable chan ""
    #Channel flag
    setudef flag Access
    #Binds:
    bind join - * [namespace current]::OnJoin
    bind raw - 354 [namespace current]::OnRaw
    bind dcc n access  [namespace current]::OnCommand
    #Procs:
    proc OnCommand { ha id te } {
        set args [split $te]
        if {[llength $args] < 3} {
            showhelp $id
            return
        }
        foreach {cmd auth chan} $args break;
        switch $cmd {
            "add" {
                if {![IsAllowed $auth $chan]} {
                    Allow $auth $chan
                }
                putdcc $id "Done."
            }
            "remove" {
                if {[IsAllowed $auth $chan]} {
                    UnAllow $auth $chan
                }
                putdcc $id "Done."
            }
            default {
                showhelp $id
                return
            }
        }
    }
    proc showhelp id {
        putdcc $id "Syntax is: .access <add/remove> <nick> <channel>"
        putdcc $id "Both can be masks so be carefull"
        putdcc $id "For example '.access remove somenick %' will remove all access of that user."
    }
    proc OnJoin { n uh ha ch } {
        variable num
        variable chan
        if {[isbotnick $n]} {return}
        if {![channel get $ch Access]} {return}
        putquick "WHO $n n%nat,$num" -next
        putlog "[namespace current]: Testing $n on $ch"
        set chan $ch
    }
    proc OnRaw { from keyword arguments } {
        variable num
        variable chan
        if {$keyword != 354} { return }
        putlog "[namespace current]: Got $arguments"
        set list1 [split $arguments]
        if {[lindex $list1 0] != $::botnick} { return }
        putlog "[namespace current]: For me [lindex $list1 0]"
        if {[lindex $list1 1] != $num} { return }
        putlog "[namespace current]: Right Query"
        if {![IsAllowed [lindex $list1 3] $chan]} {
            putlog "[namespace current]: Not Allowed"
            Remove [lindex $list1 2] $chan
            return
        }
    }
    proc IsAllowed {auth chan} {
        variable mysql
        if {$auth == "0"} { return 0 }
        putlog "[namespace current]: Authed as $auth"
        #1. Connect to Database:
        if { [ catch {
                set handle [mysqlconnect -host $mysql(host) -u $mysql(user) -password $mysql(pass) -db $mysql(db)]
            } err ] } {
            putlog "[namespace current]: Could not connect to MYSQL."
            return 1
        }
        #2. We now have a valid mysql handle in $handle
        set result [mysqlsel $handle "SELECT `$mysql(ncol)` FROM `$mysql(table)` WHERE `$mysql(ncol)` LIKE '$auth' AND `$mysql(ccol)` LIKE '$chan'" -list]
        mysqlclose $handle
        putlog "[namespace current]: $result"
        if {$result == {}} { return 0 }
        return 1
    }
    proc Allow { auth chan } {
        variable mysql
        if { [ catch {
                set handle [mysqlconnect -host $mysql(host) -u $mysql(user) -password $mysql(pass) -db $mysql(db)]
            } err ] } {
            putlog "[namespace current]: Could not connect to MYSQL."
            return 1
        }
        putlog "[namespace current]:Allowing '$auth' to enter '$chan'"
        set result [mysqlexec $handle "INSERT INTO `$mysql(table)` ($mysql(ncol), $mysql(ccol)) VALUES ('$auth','$chan')"]
        putlog "[namespace current]: $result"
    }
    proc UnAllow { auth chan } {
        variable mysql
        if { [ catch {
                set handle [mysqlconnect -host $mysql(host) -u $mysql(user) -password $mysql(pass) -db $mysql(db)]
            } err ] } {
            putlog "[namespace current]: Could not connect to MYSQL."
            return 1
        }
        putlog "[namespace current]: Removing '$auth's right to enter '$chan'"
        set result [mysqlexec $handle "DELETE FROM `$mysql(table)` WHERE `$mysql(ncol)` LIKE '$auth' AND `$mysql(ccol)` LIKE '$chan'"]
        putlog "[namespace current]: $result"
    }
    proc Remove {nick chan} {
        if {![channel get $chan Access]} { continue }
        if {![onchan $nick $chan]} { continue }
        newchanban $chan [maskhost [getchanhost $nick $chan]] [namespace current] "No Access - 10min ban" 10 sticky
        putkick $chan $nick "No Access - 10min ban"
        putlog "[namespace current]: Removing $nick from $chan. Reason: No Access"
    }
    proc ScriptLoad {} {
        variable mysql
        putlog "[namespace current]: Loading..."
        if { $mysql(pkg) == "" } {
            #No package set so we try to just require it.
            if { [catch { package require mysqltcl } err ] } { putlog "[namespace current]: Could not load mysql, unloading"; ScriptUnload; return }
        } else {
            #Mysqltcl should be a .so
            if { [catch { load $mysql(pkg) } err ] } { putlog "[namespace current]: Could not load mysql, unloading"; ScriptUnload; return }
        }
        putlog "[namespace current]: Done..."
    }
    #This never gets called manually.
    proc ScriptUnload {} {
        putlog "[namespace current]: Unloading..."
        foreach bind [binds [namespace current]*] {
            unbind [lindex $bind 0] [lindex $bind 1] [lindex $bind 2] [lindex $bind 4]
        }
        putlog "[namespace current]: Done..."
        namespace delete [namespace current]
    }
    #Start
    ScriptLoad
}

Go to forum
Unclassified NewsBoard 1.5.3-d | © 2003-4 by Yves Goergen | Time: 632.7 msec, CPU time: 152 msec, 85 Database queries in 195.4 msec | 11.6 kB (94.2 kB) | Timezone: +0100