-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhost.tcl
More file actions
56 lines (47 loc) · 1.24 KB
/
Copy pathhost.tcl
File metadata and controls
56 lines (47 loc) · 1.24 KB
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
46
47
48
49
50
51
52
53
54
55
56
# host.tcl
#
# This script resolves host names or ip addresses using the tool "host" with
# the !host command.
#
# Usage:
# !host name|ip resolve name or ip address
#
# Enable for a channel with: .chanset #channel +host
# Disable for a channel with: .chanset #channel -host
#
# See https://github.com/hwipl/eggdrop-scripts for the latest version and
# additional information including the license (MIT).
# tested versions, might run on earlier versions
package require Tcl 8.6
package require eggdrop 1.8.4
namespace eval ::host {
# channel flag for enabling/disabling
setudef flag host
# path to host tool
variable hostCmd "/usr/bin/host"
}
proc ::host::lookup { nick host hand chan arg } {
variable hostCmd
# check channel flag if enabled in this channel
if {![channel get $chan host]} {
return 0
}
# check if hostname/ip parameter is given
if {$arg == ""} {
return 0
}
# run host and capture output
if {[catch {exec $hostCmd [lindex $arg 0]} output]} {
putlog "Error executing $hostCmd: $output"
return 0
}
# send every output line as a message
foreach i [split $output "\n"] {
puthelp "PRIVMSG $chan :$i"
}
return 1
}
namespace eval ::host {
bind pub - !host ::host::lookup
putlog "Loaded host.tcl"
}