annotate tj.tcl @ 647:98e2254056b2

tj: Adjust few comments.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Feb 2021 10:21:23 +0200
parents cf62cdc44568
children 4156adacdc31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
1 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
3 # TJ v2.0 by ccr/TNSP <ccr@tnsp.org>
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
4 # (C) Copyright 2021 Tecnic Software productions (TNSP)
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 #
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 # This script is freely distributable under GNU GPL (version 2) license.
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 #
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
8 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
10 ### The configuration should be in config.tj in same directory
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
11 ### as this script. Or change the line below to point where ever
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
12 ### you wish. See "config.tj.example" for an example config file.
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
13 source [file dirname [info script]]/config.tj
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
15 ### Required utillib.tcl
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
16 source [file dirname [info script]]/utillib.tcl
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
19 ##########################################################################
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 # No need to look below this line
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
21 ##########################################################################
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
22 package require sqlite3
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
23 package require textutil::split
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
25 set tj_name "TJ"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
26 set tj_message "$tj_name v2.0 (C) 2021 ccr/TNSP"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
27
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
29 # ------------------------------------------------------------------------
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
30 ### Utility functions
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
31 proc tj_log {umsg} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
32 global tj_log_enable tj_name
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
33 if {$tj_log_enable != 0} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
34 putlog "${tj_name}: $umsg"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
35 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
36 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
37
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
38
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
39 proc tj_qm {uid} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
40 global tj_messages
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
41
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
42 if {[info exists tj_messages($uid)]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
43 return $tj_messages($uid)
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
44 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
45 return $uid
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
46 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
47 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
49
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
50 proc tj_smsg {apublic anick achan amsg {aargs {}}} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
51 global tj_preferredmsg tj_cmd_name
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
52 set amsg [string map [list "@cmd@" $tj_cmd_name] $amsg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
53 utl_msg_args $tj_preferredmsg $apublic $anick $achan $amsg $aargs
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
54 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
55
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
56
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
57 proc tj_msg {apublic anick achan aid {aargs {}}} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
58 tj_smsg $apublic $anick $achan [tj_qm $aid] $aargs
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
59 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
60
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
61
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
62 proc tj_correct_handle {uhand} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
63 set ulower [string tolower $uhand]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
64 foreach uuser [userlist] {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
65 if {[string tolower $uuser] == $ulower} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
66 return $uuser
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 return ""
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
73 proc tj_cmd_match {uid ustr} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
74 global tj_commands
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
75 return [utl_cmd_match tj_commands $uid $ustr]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
76 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
77
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
78
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
79 proc tj_arg_rest {rarglist rindex rstr} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
80 upvar $rstr dstr
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
81
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
82 if {$rindex < [llength $rarglist]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
83 set dstr [join [lrange $rarglist $rindex end] " "]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
84 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
85 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
86 return 0
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
87 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
88 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
89
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
91 # ------------------------------------------------------------------------
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
92 proc tj_get_id {rstr rindex rid} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
93 upvar $rindex uindex
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
94 upvar $rid uid
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
95
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
96 if {[string index $rstr 0] == "#"} {
615
1dac9129eb0f tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents: 614
diff changeset
97 set uid [string range $rstr 1 end]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
98 incr uindex
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
99 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
100 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
101 return 0
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
102 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
103 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
104
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
105
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
106 proc tj_get_default_id {uhand} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
107 global tj_default_id
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
108
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
109 set uid [getuser $uhand XTRA "tj_default_id"]
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
110 if {$uid == "" || $uid == "{}" || $uid == "*"} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
111 return $tj_default_id
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
112 } else {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
113 return $uid
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
114 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
115 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
116
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
117
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
118 proc tj_ctime {ustamp} {
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
119 return [clock format $ustamp -format [tj_qm "datefmt_long"]]
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
120 }
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
121
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
122
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
123 proc tj_ctimes {ustamp} {
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
124 return [clock format $ustamp -format [tj_qm "datefmt_short"]]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
128 # ------------------------------------------------------------------------
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
129 proc tj_str_append { qlist qvalue qsingular qplural } {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
130 upvar $qlist ulist
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
131 if {$qvalue > 0} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
132 if {$qvalue > 1} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
133 set qfmt $qplural
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
134 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
135 set qfmt $qsingular
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
136 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
137 lappend ulist [utl_str_map_values [tj_qm "tj_str_${qfmt}"] [list $qvalue]]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
138 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
142 # Return string describing how many years,days,hours,etc
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
143 # the given number of seconds consists of
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
144 proc tj_get_tj_str {useconds} {
505
4f2bf10ceaa2 tj: Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 424
diff changeset
145
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
146 set uyears [expr ($useconds / (365*24*60*60))]
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
147 set urem [expr ($useconds % (365*24*60*60))]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
148 set udays [expr ($urem / (24*60*60))]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
149 set urem [expr ($urem % (24*60*60))]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
150 set uhours [expr ($urem / (60*60))]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
151 set urem [expr ($urem % (60*60))]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
152 set uminutes [expr ($urem / 60)]
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
154 set ulist {}
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
155 tj_str_append ulist $uyears "year" "years"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
156 tj_str_append ulist $udays "day" "days"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
157 tj_str_append ulist $uhours "hour" "hours"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
158 tj_str_append ulist $uminutes "minute" "minutes"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
159
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
160 set ustr [join [lrange $ulist 0 end-1] [tj_qm "tj_str_sep"]]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
161 if {[llength $ulist] > 1} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
162 append ustr [tj_qm "tj_str_sep_last"]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
163 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
164 append ustr [lindex $ulist end]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
165
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
166 return $ustr
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
170 proc tj_get_tj_str_delta {ustamp uclock} {
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
171 set udelta [expr $ustamp - $uclock]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
172
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
173 if {$udelta < 0} {
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
174 set ufmt "tjs_past"
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
175 set useconds [expr -$udelta]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
176 } else {
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
177 set ufmt "tjs_future"
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
178 set useconds $udelta
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
179 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
180
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
181 return [utl_str_map_values [tj_qm $ufmt] [list [tj_get_tj_str $useconds] [tj_ctime $ustamp]]]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
182 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
183
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
185 # ------------------------------------------------------------------------
624
e7c88d4e917c tj: Only get clock once.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
186 proc tj_display_tjs {upublic unick uchan uname uid uclock} {
e7c88d4e917c tj: Only get clock once.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
187
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
188 set nresults 0
615
1dac9129eb0f tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents: 614
diff changeset
189 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' AND utype=0 AND uid LIKE '[utl_escape $uid]'"
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
190 tj_dbh eval $usql {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
191 incr nresults
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
192 set ustamp [utl_sql_datetime_to_stamp $utarget]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
193 set udelta [expr $ustamp - $uclock]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
194
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
195 if {$udelta < 0} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
196 set ufmt "tj_past"
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
197 set useconds [expr -$udelta]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
198 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
199 set ufmt "tj_remaining"
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
200 set useconds $udelta
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
201 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
202
614
8c61b4032648 tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 613
diff changeset
203 tj_msg $upublic $unick $uchan $ufmt [list $uname $uid [tj_get_tj_str $useconds] [tj_ctime $ustamp]]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
204 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
205
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
206 if {!$nresults} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
207 tj_msg $upublic $unick $uchan "tj_not_set" [list $uname $uid]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
208 }
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211
70
15fc72bc3f3e More cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
212 # ------------------------------------------------------------------------
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
213 proc tj_cmd {unick $uhost uhand uchan uargs upublic} {
633
bc87660aa400 tj: Add max items as configurable setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 632
diff changeset
214 global tj_messages tj_default_id tj_default_time tj_default_desc tj_max_items
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
216 # Check if we have a valid user
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
217 if {![utl_valid_user $uhand]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
218 tj_msg $upublic $unick $uchan "err_invalid_user" [list $uhand]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
219 return 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221
624
e7c88d4e917c tj: Only get clock once.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
222 set uclock [clock seconds]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
223 set uhand [tj_correct_handle $uhand]
622
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
224 set qadmin [matchattr $uhand n]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
225
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
226 # Check and handle arguments
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
227 set rarglist [::textutil::split::splitx $uargs {\s+}]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
228 set rcmd [lindex $rarglist 0]
617
ce7a666991e3 tj: Cleanup, set rindex only once.
Matti Hamalainen <ccr@tnsp.org>
parents: 616
diff changeset
229 set rindex 1
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
230
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
231 if {[tj_cmd_match "help" $rcmd]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
232 # Show help
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
233 foreach ukey $tj_messages(help_full) {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
234 tj_msg $upublic $unick $uchan $ukey
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
235 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
236 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
237 } elseif {[tj_cmd_match "set" $rcmd]} {
620
47b15186373f tj: Clarify some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 618
diff changeset
238 # !tj set [#<id>] <[-/+]days [[+/-]<hours>] | dd.mm.yyyy [hh:mm]> [<desc>]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
239 if {![utl_arg_get $rarglist rindex rarg 0]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
240 tj_msg $upublic $unick $uchan "help_set"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
241 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
242 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
243
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
244 # Check for #id prefix
642
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
245 set rdesc "*"
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
246 if {![tj_get_id $rarg rindex uid]} {
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
247 set uid [tj_get_default_id $uhand]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
248 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
249
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
250 # Do we have any arguments left?
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
251 if {![utl_arg_get $rarglist rindex rarg 1]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
252 tj_msg $upublic $unick $uchan "help_set"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
253 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
254 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
255
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
256 # Is it a time stamp?
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
257 if {[regexp {\d+\.\d+\.\d\d\d\d} $rarg rdate]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
258 # Seems so .. check for hours
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
259 set rtime $tj_default_time
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
260 if {[utl_arg_get $rarglist rindex rarg 0]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
261 if {[regexp {\d+:\d+} $rarg rtime]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
262 incr rindex
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
263 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
264 set rtime $tj_default_time
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
265 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
266 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
267
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
268 tj_arg_rest $rarglist $rindex rdesc
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
269
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
270 # Check the timestamp validity
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
271 if {[catch {set rstamp [clock scan "${rdate} ${rtime}" -format "%d.%m.%Y %H:%M"]} uerrmsg]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
272 tj_msg $upublic $unick $uchan "err_timestamp" [list $uerrmsg $rdate $rtime]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
273 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
274 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
275
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
276 } elseif {[regexp {(\+|\-)?(\d+)} $rarg -> dsign rdays]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
277 # Check for days
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
278 if {$dsign == "-"} { set rdays [expr -$rdays] }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
279
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
280 # Check for hours
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
281 set rhours 0
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
282 if {[utl_arg_get $rarglist rindex rarg 0]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
283 if {[regexp {(\+|\-)?(\d+)} $rarg -> hsign rhours]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
284 if {$hsign == "-"} { set rhours [expr -$rhours] }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
285 incr rindex
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
286 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
287
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
288 # Get description, if any
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
289 tj_arg_rest $rarglist $rindex rdesc
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
290
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
291 # Validate hours parameters a bit
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
292 if {$rhours < -24 || $rhours > 24} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
293 tj_msg $upublic $unick $uchan "err_invalid_hours" [list $rhours]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
294 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
295 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
296 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
297
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
298 # Compute target timestamp
634
fd1c56676648 tj: Use uclock uniformly in tj_cmd.
Matti Hamalainen <ccr@tnsp.org>
parents: 633
diff changeset
299 set rstamp [expr $uclock + ($rdays * 24 * 60 * 60) + ($rhours * 60 * 60)]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
300 } else {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
301 # Only description was specified
642
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
302 incr rindex -1
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
303 tj_arg_rest $rarglist $rindex rdesc
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
304 set rstamp "invalid"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
305 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
306
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
307 # Check if ID exists
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
308 set umode 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
309 set nres 0
615
1dac9129eb0f tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents: 614
diff changeset
310 set usql "SELECT * FROM tj WHERE uid LIKE '[utl_escape $uid]'"
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
311 tj_dbh eval $usql {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
312 set umode 0
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
313 set cid $id
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
314 set ctarget $utarget
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
315
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
316 # If description has not been set, fetch previous
642
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
317 if {$rdesc == "*"} {
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
318 set rdesc $udesc
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
319 }
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
320 incr nres
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
321 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
322
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
323 # Check for DB sanity at this point
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
324 if {$nres > 1} {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
325 # If we have more than one result for this ID, there's been
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
326 # some kind of mistake at some point.
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
327 tj_msg $upublic $unick $uchan "err_db_corrupt" [list $nres]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
328 tj_log "too many $nres fatal error piip"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
329 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
330 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
331
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
332 # Check if we are trying to add a new entry without valid timestamp
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
333 if {$rstamp == "invalid"} {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
334 # Yes, if mode is "new", we should error out
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
335 if {$umode} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
336 tj_msg $upublic $unick $uchan "err_missing_timestamp"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
337 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
338 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
339
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
340 # Otherwise we are updating, so just use the old timestamp
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
341 set rdate $ctarget
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
342 set ustamp [utl_sql_datetime_to_stamp $ctarget]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
343 } else {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
344 # Timestamp was okay
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
345 set rdate [utl_sql_stamp_to_datetime $rstamp]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
346 set ustamp $rstamp
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
347 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
348
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
349 # If description has not been set, use default
642
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
350 if {$rdesc == "*"} {
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
351 set rdesc $tj_default_desc
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
352 }
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
353
641
0b618c09063f tj: Use ustamp instead of rstamp here.
Matti Hamalainen <ccr@tnsp.org>
parents: 639
diff changeset
354 set utjstr [tj_get_tj_str_delta $ustamp $uclock]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
355 set udate [tj_ctime $ustamp]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
356
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
357 # Check against max reminders ..
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
358 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'"
632
68b8cf87e86e tj: Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 631
diff changeset
359 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} {
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
360 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
361 tj_log "$uerrmsg on SQL:\n$usql"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
362 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
363 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
364
633
bc87660aa400 tj: Add max items as configurable setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 632
diff changeset
365 if {$nitems >= $tj_max_items} {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
366 # User has too many set already
633
bc87660aa400 tj: Add max items as configurable setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 632
diff changeset
367 tj_msg $upublic $unick $uchan "err_too_many" [list $nitems $tj_max_items]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
368 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
369 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
370
634
fd1c56676648 tj: Use uclock uniformly in tj_cmd.
Matti Hamalainen <ccr@tnsp.org>
parents: 633
diff changeset
371 set ucreated [utl_sql_stamp_to_datetime $uclock]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
372 if {$umode} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
373 # Insert new entry
631
9596cd122639 tj: Adjust database schema a bit, add new field 'uupdated'.
Matti Hamalainen <ccr@tnsp.org>
parents: 630
diff changeset
374 set usql "INSERT INTO tj (uid,uuser,ucreated,uupdated,udesc,utype,utarget) VALUES ('[utl_escape $uid]', '[utl_escape $uhand]', '$ucreated', '$ucreated', '[utl_escape $rdesc]', 0, '$rdate')"
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
375 if {[catch {tj_dbh eval $usql} uerrmsg]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
376 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
377 tj_log "$uerrmsg on SQL:\n$usql"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
378 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
379 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
380
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
381 set cid [tj_dbh last_insert_rowid]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
382 tj_msg $upublic $unick $uchan "tj_set" [list $cid $uid $uhand $rdesc $udate $utjstr]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
383 tj_log "tj_set $cid:$uid:$uhand:$rdesc:$rdate:$udate"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
384 } else {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
385 # Update existing entry
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
386 set usqlargs {}
631
9596cd122639 tj: Adjust database schema a bit, add new field 'uupdated'.
Matti Hamalainen <ccr@tnsp.org>
parents: 630
diff changeset
387 lappend usqlargs "uupdated='$ucreated'"
642
5cbff6baebef tj: Fix handling of description updating and setting.
Matti Hamalainen <ccr@tnsp.org>
parents: 641
diff changeset
388 if {[string length $rdesc] > 0 && $rdesc != "*"} {
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
389 lappend usqlargs "udesc='[utl_escape $rdesc]'"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
390 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
391 if {$rstamp != "invalid"} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
392 lappend usqlargs "utarget='$rdate'"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
393 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
394
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
395 if {[llength $usqlargs] > 0} {
636
c3911a8c28e5 tj: Oops, in 'set' command UPDATE clause we had forgotten to specify
Matti Hamalainen <ccr@tnsp.org>
parents: 635
diff changeset
396 set usql "UPDATE tj SET [join $usqlargs ,] WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'"
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
397 if {[catch {tj_dbh eval $usql} uerrmsg]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
398 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
399 tj_log "$uerrmsg on SQL:\n$usql"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
400 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
401 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
402 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
403
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
404 # Do a query
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
405 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'"
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
406 tj_dbh eval $usql {
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
407 set utjstr [tj_get_tj_str_delta [utl_sql_datetime_to_stamp $utarget] $uclock]
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
408 tj_msg $upublic $unick $uchan "tj_updated" [list $id $uid $uhand $udesc $udate $utjstr]
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
409 tj_log "tj_updated $id:$uid:$uhand:$udesc:$utarget"
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
410 }
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
411 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
412
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
413 } elseif {[tj_cmd_match "remind" $rcmd]} {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
414 # XXX TODO MAYBE .. reminder functionality .. perhaps some day.
620
47b15186373f tj: Clarify some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 618
diff changeset
415 # !tj remind #<id> <<dd.mm.yyyy [hh:mm]>|<message>>
47b15186373f tj: Clarify some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 618
diff changeset
416 # !tj remind #<id> <<dd.mm [hh:mm]>|<message>>
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
417 if {[llength $rarglist] < 3} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
418 tj_msg $upublic $unick $uchan "help_add"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
419 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
420 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
421
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
422 } elseif {[tj_cmd_match "list" $rcmd]} {
622
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
423 # !tj list [name]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
424 # List reminders
622
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
425 if {[utl_arg_get $rarglist rindex uname 1]} {
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
426 set uname [tj_correct_handle $uname]
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
427 } else {
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
428 set uname $uhand
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
429 }
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
430
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
431 # First, get count of items
622
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
432 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uname]'"
616
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
433 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} {
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
434 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
435 tj_log "$uerrmsg on SQL:\n$usql"
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
436 return 1
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
437 }
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
438
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
439 # Then, list items
616
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
440 set nitem 0
622
84a30765baa1 tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 621
diff changeset
441 set usql "SELECT * FROM tj WHERE uuser='[utl_escape $uname]' ORDER BY ucreated"
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
442 tj_dbh eval $usql {
616
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
443 incr nitem
639
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
444 set qtarget [utl_sql_datetime_to_stamp $utarget]
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
445 set ustr [tj_get_tj_str_delta $qtarget $uclock]
c11ee9fea4b8 tj: Use new datefmt_short and datefmt_long and fix up/implement rest of the
Matti Hamalainen <ccr@tnsp.org>
parents: 638
diff changeset
446 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $qtarget] [tj_ctimes [utl_sql_datetime_to_stamp $ucreated]] [tj_ctimes [utl_sql_datetime_to_stamp $uupdated]] $uid $udesc $ustr]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
447 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
448
616
20dba2c757de tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents: 615
diff changeset
449 if {!$nitem} {
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
450 tj_msg $upublic $unick $uchan "no_results" [list $uname]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
451 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
452
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
453 } elseif {[tj_cmd_match "delete" $rcmd]} {
621
a1efc28ef5a4 tj: Require #-prefix for ids in 'delete' command.
Matti Hamalainen <ccr@tnsp.org>
parents: 620
diff changeset
454 # !tj delete #<id>
a1efc28ef5a4 tj: Require #-prefix for ids in 'delete' command.
Matti Hamalainen <ccr@tnsp.org>
parents: 620
diff changeset
455 if {![utl_arg_get $rarglist rindex rarg 0] || ![tj_get_id $rarg rindex uid]} {
618
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
456 tj_msg $upublic $unick $uchan "help_delete"
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
457 return 1
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
458 }
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
459
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
460 # Check if the desired item exists
618
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
461 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'"
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
462 if {[catch {set nitems [tj_dbh onecolumn $usql]} uerrmsg]} {
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
463 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
464 tj_log "$uerrmsg on SQL:\n$usql"
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
465 return 1
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
466 }
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
467
626
319c2e73860c tj: When deleting a TJ, check if it exists and say so if it does not.
Matti Hamalainen <ccr@tnsp.org>
parents: 625
diff changeset
468 if {$nitems == 0} {
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
469 # No, error out
626
319c2e73860c tj: When deleting a TJ, check if it exists and say so if it does not.
Matti Hamalainen <ccr@tnsp.org>
parents: 625
diff changeset
470 tj_msg $upublic $unick $uchan "err_no_such_id" [list $uid]
319c2e73860c tj: When deleting a TJ, check if it exists and say so if it does not.
Matti Hamalainen <ccr@tnsp.org>
parents: 625
diff changeset
471 return 1
319c2e73860c tj: When deleting a TJ, check if it exists and say so if it does not.
Matti Hamalainen <ccr@tnsp.org>
parents: 625
diff changeset
472 }
319c2e73860c tj: When deleting a TJ, check if it exists and say so if it does not.
Matti Hamalainen <ccr@tnsp.org>
parents: 625
diff changeset
473
644
77c9feb5dcee tj: Add numerous comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 642
diff changeset
474 # Delete it
618
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
475 set usql "DELETE FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'"
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
476 if {[catch {set ndone [tj_dbh onecolumn $usql]} uerrmsg]} {
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
477 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
478 tj_log "$uerrmsg on SQL:\n$usql"
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
479 return 1
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
480 }
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
481
3b1fdba9a95c tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents: 617
diff changeset
482 tj_msg $upublic $unick $uchan "items_deleted" [list $uid $nitems]
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
483
628
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
484 # Check if we deleted the default ID
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
485 set udefid [tj_get_default_id $uhand]
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
486 if {[string tolower $uid] == [string tolower $udefid]} {
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
487 setuser $uhand XTRA "tj_default_id" $tj_default_id
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
488
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
489 tj_msg $upublic $unick $uchan "default_reset" [list $uid $tj_default_id]
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
490 }
eaf766018133 tj: If user deletes his or her default TJ ID, re-set the default to global default.
Matti Hamalainen <ccr@tnsp.org>
parents: 626
diff changeset
491
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
492 } elseif {[tj_cmd_match "default" $rcmd]} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
493 # !tj default #<id>
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
494 # Check for #id prefix
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
495 if {![utl_arg_get $rarglist rindex rarg 0] || ![tj_get_id $rarg rindex uid]} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
496 tj_msg $upublic $unick $uchan "help_default"
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
497 return 1
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
498 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
499
637
2f62fa434056 tj: Improve a comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 636
diff changeset
500 # If given ID is empty or *, clear to global default id
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
501 if {$uid == "" || $uid == "{}" || $uid == "*"} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
502 set uid $tj_default_id
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
503 } else {
630
b7e3a47ed072 tj: Add few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 628
diff changeset
504 # Check if a TJ exists with this id?
638
5260156d9521 tj: Oops, forgot to use LIKE instead of '=' here for comparing uid. Fixed.
Matti Hamalainen <ccr@tnsp.org>
parents: 637
diff changeset
505 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]' AND uid LIKE '[utl_escape $uid]'"
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
506 if {[catch {set nids [tj_dbh onecolumn $usql]} uerrmsg]} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
507 tj_msg $upublic $unick $uchan "err_sql" [list $uerrmsg]
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
508 tj_log "$uerrmsg on SQL:\n$usql"
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
509 return 1
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
510 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
511
647
98e2254056b2 tj: Adjust few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 646
diff changeset
512 if {$nids == 0} {
98e2254056b2 tj: Adjust few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 646
diff changeset
513 # No, error out
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
514 tj_msg $upublic $unick $uchan "err_no_such_id" [list $uid]
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
515 return 1
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
516 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
517 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
518
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
519 setuser $uhand XTRA "tj_default_id" $uid
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
520
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
521 tj_msg $upublic $unick $uchan "default_set" [list $uid]
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
522
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
523 } elseif {[tj_cmd_match "show" $rcmd]} {
620
47b15186373f tj: Clarify some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 618
diff changeset
524 # !tj show [#<id>] <name>
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
525 # Check for #id prefix
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
526 if {[utl_arg_get $rarglist rindex rarg 0]} {
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
527 set notdefault [tj_get_id $rarg rindex uid]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
528 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
529
646
cf62cdc44568 tj: Add comment.
Matti Hamalainen <ccr@tnsp.org>
parents: 644
diff changeset
530 # Check for name argument
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
531 if {![utl_arg_get $rarglist rindex rarg 0]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
532 tj_msg $upublic $unick $uchan "help_show"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
533 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
534 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
535
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
536 set uname [tj_correct_handle $rarg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
537 if {$uname == ""} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
538 tj_msg $upublic $unick $uchan "err_unknown_user" [list $rcmd]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
539 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
540 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
541
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
542 if {!$notdefault} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
543 set uid [tj_get_default_id $uname]
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
544 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
545
624
e7c88d4e917c tj: Only get clock once.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
546 tj_display_tjs $upublic $unick $uchan $uname $uid $uclock
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
547 } else {
620
47b15186373f tj: Clarify some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 618
diff changeset
548 # !tj [#<id>] [name]
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
549 set notdefault 0
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
550 set uname $uhand
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
551 set rindex 0
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
552 if {[utl_arg_get $rarglist rindex rarg 0]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
553 # Check for #id prefix
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
554 set notdefault [tj_get_id $rarg rindex uid]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
555
647
98e2254056b2 tj: Adjust few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 646
diff changeset
556 # Check if name is specified
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
557 if {[utl_arg_get $rarglist rindex rarg 0]} {
647
98e2254056b2 tj: Adjust few comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 646
diff changeset
558 # Validate it
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
559 set uname [tj_correct_handle $rarg]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
560 if {$uname == ""} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
561 tj_msg $upublic $unick $uchan "err_unknown_user" [list $rcmd]
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
562 return 1
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
563 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
564 }
625
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
565 }
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
566
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
567 if {!$notdefault} {
5eca657134a5 tj: Implement command to set/reset default ID for TJs.
Matti Hamalainen <ccr@tnsp.org>
parents: 624
diff changeset
568 set uid [tj_get_default_id $uname]
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
569 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
570
624
e7c88d4e917c tj: Only get clock once.
Matti Hamalainen <ccr@tnsp.org>
parents: 622
diff changeset
571 tj_display_tjs $upublic $unick $uchan $uname $uid $uclock
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
572 }
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
573
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
574 return 1
0
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
575 }
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576
1c4e2814cd41 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
578 #-------------------------------------------------------------------------
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
579 # Script initialization
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
580 #-------------------------------------------------------------------------
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
581 putlog "$tj_message"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
582
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
583 if {[catch {sqlite3 tj_dbh $tj_db_file} uerrmsg]} {
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
584 putlog "Could not open SQLite3 database '${tj_db_file}': ${uerrmsg}"
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
585 exit 2
125
42cf6a768c46 tj: Add support for years in the output.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
586 }
42cf6a768c46 tj: Add support for years in the output.
Matti Hamalainen <ccr@tnsp.org>
parents: 108
diff changeset
587
613
ea6ebcf42b47 TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents: 578
diff changeset
588 # end of script