-
Notifications
You must be signed in to change notification settings - Fork 7
/
steiner-exec.tcl
executable file
·45 lines (42 loc) · 2.07 KB
/
steiner-exec.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#########################################################################################
# Name steiner:exec
# Description Executes a command on your system's shell. Only works for people with the correct flags
# Version 1.2.1 (2014-03-05)
# Contact ScottSteiner@irc.rizon.net
# Website https://github.com/ScottSteiner/eggdrop-scripts
# Copyright 2010-2014, ScottSteiner <nothingfinerthanscottsteiner@gmail.com>
# License GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
#########################################################################################
if {[catch {source scripts/steiner-settings.tcl} err]} {
putlog "Error: Could not load 'scripts/steiner-settings.tcl' file.";
}
namespace eval steiner {
namespace eval exec {
# Protected functions
set flag $steiner::settings::exec::flag
if {$steiner::settings::exec::enablepublic} { foreach cmd {date sysinfo uname uptime} { bind pub ${flag}|${flag} ${steiner::settings::prefix}$cmd steiner::exec::public } }
# Public functions
if {$steiner::settings::exec::enablepublic} { foreach cmd {stats times} { bind pub -|- ${steiner::settings::prefix}$cmd steiner::exec::public } }
proc public {nick uhost hand chan arg} {
if {[string tolower [lindex [split $arg] 0]] == "-p"} { set targ "$nick" } else { set targ "$chan" }
set cmd [string range [lindex $::lastbind 0] 1 end]
puthelp "PRIVMSG $targ :[execute $cmd]"
}
proc execute { cmd } {
if {$cmd == "sysinfo"} { set cmd "/usr/local/bin/sysinfo" }
if {$cmd == "uname"} { set cmd "uname -a" }
if {$cmd == "date"} { return [clock format [clock seconds] -format {%Y-%m-%d %T %Z}] }
if {$cmd == "stats"} { return "Channel stats can be found at http://scottsteiner.github.io" }
if {$cmd == "times"} {
foreach city [dict keys $steiner::settings::exec::times] {
set timezone [dict get $steiner::settings::exec::times $city]
lappend info "$city [clock format [clock seconds] -format {%I:%M %p %Z} -timezone $timezone]"
}
set output [join $info " | "]
return "$output"
}
catch { eval exec $cmd } output
return "$output"
}
}
}