Mercurial > hg > egg-tcls
annotate tj.tcl @ 622:84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 10 Feb 2021 15:27:10 +0200 |
parents | a1efc28ef5a4 |
children | e7c88d4e917c |
rev | line source |
---|---|
70 | 1 ########################################################################## |
0 | 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 | 5 # |
6 # This script is freely distributable under GNU GPL (version 2) license. | |
7 # | |
70 | 8 ########################################################################## |
0 | 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 | 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 | 17 |
18 | |
70 | 19 ########################################################################## |
0 | 20 # No need to look below this line |
70 | 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 | 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 | 28 |
70 | 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 | 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 | 67 } |
68 } | |
69 return "" | |
70 } | |
71 | |
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 | 90 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
91 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
|
92 global tj_default_id |
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 set uid $tj_default_id |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
102 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
|
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 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
106 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
107 proc 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
|
108 return [clock format $ustamp -format [tj_qm "datefmt"]] |
0 | 109 } |
110 | |
111 | |
70 | 112 # ------------------------------------------------------------------------ |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
119 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
|
120 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
121 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
|
122 } |
0 | 123 } |
124 | |
125 | |
614
8c61b4032648
tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents:
613
diff
changeset
|
126 # 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
|
127 # 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
|
128 proc tj_get_tj_str {useconds} { |
505 | 129 |
614
8c61b4032648
tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents:
613
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 set uminutes [expr ($urem / 60)] |
0 | 137 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
144 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
|
145 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
|
146 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
|
147 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
148 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
|
149 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
150 return $ustr |
0 | 151 } |
152 | |
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 proc tj_get_tj_str_delta { ustamp } { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
155 set udelta [expr $ustamp - [clock seconds]] |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
156 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
157 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
|
158 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
|
159 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
|
160 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
161 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
|
162 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
|
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 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
165 # return [utl_str_map_values [tj_qm $ufmt] [list ]] |
614
8c61b4032648
tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents:
613
diff
changeset
|
166 return [tj_get_tj_str $useconds] |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
167 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
168 |
0 | 169 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
170 proc tj_display_tjs {upublic unick uchan 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
|
171 set uclock [clock seconds] |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
172 set nresults 0 |
615
1dac9129eb0f
tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents:
614
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 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
|
177 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
|
178 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
179 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
|
180 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
|
181 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
|
182 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
183 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
|
184 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
|
185 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
186 |
614
8c61b4032648
tj: Cleanup. Rename some variables to be more descriptive. Add a comment.
Matti Hamalainen <ccr@tnsp.org>
parents:
613
diff
changeset
|
187 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
|
188 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
189 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
190 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
|
191 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
|
192 } |
0 | 193 } |
194 | |
195 | |
70 | 196 # ------------------------------------------------------------------------ |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
197 proc tj_cmd {unick $uhost uhand uchan uargs upublic} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
198 global tj_messages tj_default_id tj_default_time tj_default_desc |
0 | 199 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
200 # 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
|
201 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
|
202 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
|
203 return 1 |
0 | 204 } |
205 | |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
206 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
|
207 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
|
208 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
209 # 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
|
210 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
|
211 set rcmd [lindex $rarglist 0] |
617
ce7a666991e3
tj: Cleanup, set rindex only once.
Matti Hamalainen <ccr@tnsp.org>
parents:
616
diff
changeset
|
212 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
|
213 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
214 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
|
215 # 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
|
216 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
|
217 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
|
218 } |
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 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
220 } elseif {[tj_cmd_match "set" $rcmd]} { |
620 | 221 # !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
|
222 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
|
223 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
|
224 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
|
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 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
227 # 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
|
228 if {[tj_get_id $rarg rindex uid]} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
229 set rdesc "" |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
230 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
231 set rdesc $tj_default_desc |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
232 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
233 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
234 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
|
235 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
|
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 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
238 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
239 # 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
|
240 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
|
241 # 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
247 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
|
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 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
250 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
251 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
|
252 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
253 # 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
|
254 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
|
255 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
|
256 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
|
257 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
258 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
259 } 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
|
260 # 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
|
261 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
|
262 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 } |
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 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
|
271 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
272 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
|
273 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
|
274 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
|
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 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
277 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
278 # Compute target timestamp |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
279 set rstamp [expr [clock seconds] + ($rdays * 24 * 60 * 60) + ($rhours * 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
|
280 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
281 # Only description, if any |
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 {![tj_arg_rest $rarglist 1 rdesc]} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
283 tj_msg $upublic $unick $uchan "err_invalid_format" [list] |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
284 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
|
285 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
286 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
|
287 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
288 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
289 # 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
|
290 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
|
291 set nres 0 |
615
1dac9129eb0f
tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents:
614
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 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
|
296 set ctarget $utarget |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
297 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
|
298 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
299 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
300 # Check for DB sanity |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
301 if {$nres > 1} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
302 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
|
303 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
|
304 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
|
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 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
313 |
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 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
|
315 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
|
316 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
317 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
|
318 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
|
319 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
320 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
321 set utjstr [tj_get_tj_str_delta $rstamp] |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
322 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
|
323 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
324 # Max reminders .. |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
325 set usql "SELECT COUNT(*) FROM tj WHERE uuser='[utl_escape $uhand]'" |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
326 if {[catch {set nreminders [tj_dbh onecolumn $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
|
327 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
|
328 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
|
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 for maximum reminders |
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 {$nreminders > 5} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
334 tj_msg $upublic $unick $uchan "err_too_many" [list $nreminders] |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
335 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
|
336 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
337 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
338 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
|
339 # Insert new entry |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
340 set usql "INSERT INTO tj (uid,uuser,ucreated,udesc,utype,utarget) VALUES ('[utl_escape $uid]', '[utl_escape $uhand]', [unixtime], '[utl_escape $rdesc]', 0, '$rdate')" |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 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
|
345 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
346 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
347 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
|
348 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
|
349 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
|
350 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
351 # 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
|
352 set usqlargs {} |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
353 if {[string length $rdesc] > 0} { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
354 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
|
355 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
356 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
|
357 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
|
358 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
359 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
360 if {[llength $usqlargs] > 0} { |
615
1dac9129eb0f
tj: Change #id handling to be case-insensitive.
Matti Hamalainen <ccr@tnsp.org>
parents:
614
diff
changeset
|
361 set usql "UPDATE tj SET [join $usqlargs ,] 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
367 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
368 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
369 tj_msg $upublic $unick $uchan "tj_updated" [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
|
370 tj_log "tj_updated $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
|
371 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
372 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
373 } elseif {[tj_cmd_match "remind" $rcmd]} { |
620 | 374 # !tj remind #<id> <<dd.mm.yyyy [hh:mm]>|<message>> |
375 # !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
|
376 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
|
377 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
|
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 } 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
|
382 # !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
|
383 # List reminders |
622
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
384 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
|
385 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
|
386 if {$uname != $uhand && !$qadmin} { |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
387 tj_msg $upublic $unick $uchan "access_denied" |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
388 return 1 |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
389 } |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
390 } else { |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
391 set uname $uhand |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
392 } |
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
393 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
394 set uclock [clock seconds] |
616
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
395 |
622
84a30765baa1
tj: Add ability for administrator users to 'list' other peoples TJs.
Matti Hamalainen <ccr@tnsp.org>
parents:
621
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 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
|
400 return 1 |
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
401 } |
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
402 |
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
403 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
|
404 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
|
405 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
|
406 incr nitem |
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
407 set ustamp [utl_sql_datetime_to_stamp $utarget] |
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
408 tj_msg $upublic $unick $uchan "list_item" [list $nitem $nitems [tj_ctime $ustamp] $uid $udesc] |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
409 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
410 |
616
20dba2c757de
tj: Improve output of 'list' command, and make it configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
615
diff
changeset
|
411 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
|
412 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
|
413 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
414 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
415 } 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
|
416 # !tj delete #<id> |
a1efc28ef5a4
tj: Require #-prefix for ids in 'delete' command.
Matti Hamalainen <ccr@tnsp.org>
parents:
620
diff
changeset
|
417 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
|
418 tj_msg $upublic $unick $uchan "help_delete" |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
419 return 1 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
420 } |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
421 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
422 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
|
423 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
|
424 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
|
425 tj_log "$uerrmsg on SQL:\n$usql" |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
426 return 1 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
427 } |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
428 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
429 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
|
430 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
|
431 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
|
432 tj_log "$uerrmsg on SQL:\n$usql" |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
433 return 1 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
434 } |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
435 |
3b1fdba9a95c
tj: Implement initial 'delete' command functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
617
diff
changeset
|
436 tj_msg $upublic $unick $uchan "items_deleted" [list $uid $nitems] |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
437 } elseif {[tj_cmd_match "show" $rcmd]} { |
620 | 438 # !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
|
439 # 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
|
440 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
|
441 tj_get_id $rarg rindex uid |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
442 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
443 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
444 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
|
445 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
|
446 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
|
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 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
449 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
|
450 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
|
451 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
|
452 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
|
453 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
454 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
455 tj_display_tjs $upublic $unick $uchan $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
|
456 } else { |
620 | 457 # !tj [#<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
|
458 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
|
459 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
|
460 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
|
461 # 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
|
462 tj_get_id $rarg rindex uid |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
463 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
464 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
|
465 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
|
466 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
|
467 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
|
468 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
|
469 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
470 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
471 } else { |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
472 set uid $tj_default_id |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
473 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
474 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
475 tj_display_tjs $upublic $unick $uchan $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
|
476 } |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
477 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
478 return 1 |
0 | 479 } |
480 | |
481 | |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
482 #------------------------------------------------------------------------- |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
483 # 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
|
484 #------------------------------------------------------------------------- |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
485 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
|
486 |
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
487 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
|
488 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
|
489 exit 2 |
125
42cf6a768c46
tj: Add support for years in the output.
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
490 } |
42cf6a768c46
tj: Add support for years in the output.
Matti Hamalainen <ccr@tnsp.org>
parents:
108
diff
changeset
|
491 |
613
ea6ebcf42b47
TJ: Initial commit of the TJ2.0 refactoring effort. Instead of using Eggdrop
Matti Hamalainen <ccr@tnsp.org>
parents:
578
diff
changeset
|
492 # end of script |