Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3930554
D1366.id3495.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D1366.id3495.diff
View Options
diff --git a/Wearg/ServersLog.tcl b/Wearg/ServersLog.tcl
--- a/Wearg/ServersLog.tcl
+++ b/Wearg/ServersLog.tcl
@@ -3,6 +3,19 @@
bind pub - .+log pub:log
bind dcc - +log dcc:log
+bind pubm - "#* \[*\] *" pubm:log
+
+proc pubm:log {nick uhost handle chan text} {
+ regexp "\\\[(.*)\\\] (.*)" $text match component entry
+
+ if {[is_known_component $component]} {
+ add_to_servers_log $emitter "$network $source" $component $entry
+ putcmdlog "<<$nick>> !$handle! .+log $text"
+ } {
+ putserv "PRIVMSG $chan :$nick, if you wish to log that, confirm with .+log $text"
+ }
+}
+
proc pub:log {nick uhost handle chan arg} {
set callback [get_putbymode_chan_callback $chan $nick]
handle_send_to_servers_log [resolve_nick $nick] $chan $arg $callback
@@ -13,6 +26,20 @@
handle_send_to_servers_log $handle $username $arg "dcc $idx"
}
+proc is_known_component {candidate} {
+ # If "Dwellers" is a known component, are known:
+ # - Dwellers
+ # - Dwellers/DevCentral
+
+ foreach component [registry get serverslog.knowncomponents] {
+ if {[regexp ^${component}(/.+)?$ $candidate]} {
+ return 1
+ }
+ }
+
+ return 0
+}
+
proc handle_send_to_servers_log {emitter source arg callback} {
global network
diff --git a/tests/ServersLog.test b/tests/ServersLog.test
new file mode 100644
--- /dev/null
+++ b/tests/ServersLog.test
@@ -0,0 +1,48 @@
+package require tcltest
+namespace import ::tcltest::*
+
+###
+### Init
+###
+
+# Tested code
+source init.tcl
+source $dir/Wearg/ServersLog.tcl
+
+###
+### Mocks
+###
+
+proc registry {command key {value ""}} {
+ if {$command == "get" && $key == "serverslog.knowncomponents"} {
+ return "Alpha Beta"
+ }
+
+ error "Unexpected registry call: $command $key $value"
+}
+
+###
+### Tests
+###
+
+test is_known_component_when_known {} -body {
+ is_known_component Alpha
+} -result 1
+
+test is_known_component_when_known_parent {} -body {
+ is_known_component Beta/Delta
+} -result 1
+
+test is_known_component_with_trailing_slash {} -body {
+ is_known_component Beta/
+} -result 0
+
+test is_known_component_when_unknown {} -body {
+ is_known_component Gamma
+} -result 0
+
+###
+### Cleanup
+###
+
+cleanupTests
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 14:28 (2 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2312624
Default Alt Text
D1366.id3495.diff (2 KB)
Attached To
Mode
D1366: Allow [Foo] Done something syntax for servers log
Attached
Detach File
Event Timeline
Log In to Comment