-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.tcl
executable file
·136 lines (122 loc) · 3.04 KB
/
test.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/tclsh
###############################################################
#
# Test script for eggdrop scripts
#
###############################################################
# CONFIG
set scriptname "giphy.tcl"
set channel "#testchannel"
set nickname "user"
set uhost "uhost"
set handle "handle"
# start script
set scriptVersion 0.1
set binds [dict create]
puts "Eggdrop script tester $scriptVersion"
proc setudef {type value} {
puts "SETUDEF: $type $value"
}
# handle eggdrop binds
proc bind {type perms cmd proc} {
puts "BIND: $type $perms $cmd $proc"
global binds
# create type if not exists
if {![dict exists $binds $type]} {
dict set binds $type [dict create]
}
# get existing commands of the same type
set d [dict get $binds $type]
# add command to dict
dict set binds $type [dict append d $cmd $proc]
}
# output eggdrop putserv command to stdout
proc putserv {output} {
puts "PUTSERV: $output";
}
# output egggdrop putlog command to stdout
proc putlog {output} {
puts "PUTLOG: $output";
}
proc matchattr {handle flags {channel ""}} {
return 0
}
proc channel {func name setting} {
return 1
}
# emulate pubm binds
proc pubm {{value ""}} {
puts "PUBM: $value";
global binds
global nickname
global channel
global uhost
global handle
set pubm [dict get $binds "pubm"]
dict for {mask proc} $pubm {
$proc $nickname $uhost $handle $channel $value
}
# if {[dict exists $pubm $cmd]} {
# set p [dict get $pubm $cmd]
# $p $nickname $uhost $handle $channel $value
# return
# }
# puts "ERROR: $cmd does not exists in pubm";
}
# emulate public command
proc pub {cmd {value ""}} {
puts "PUB: $cmd $value";
global binds
global nickname
global channel
global uhost
global handle
set pub [dict get $binds "pub"]
if {[dict exists $pub $cmd]} {
set p [dict get $pub $cmd]
$p $nickname $uhost $handle $channel $value
return
}
puts "ERROR: $cmd does not exists in pub";
}
# emulate msg command
proc msg {cmd {value ""}} {
puts "MSG: $cmd $value";
global binds
global nickname
global uhost
global handle
set msg [dict get $binds "msg"]
if {[dict exists $msg $cmd]} {
set p [dict get $msg $cmd]
$p $nickname $uhost $handle $value
return
}
puts "ERROR: $cmd does not exists in msg";
}
# emulate dcc command
proc dcc {cmd {value ""}} {
puts "DCC: $cmd $value";
global binds
global nickname
global uhost
global handle
set dcc [dict get $binds "dcc"]
if {[dict exists $dcc [string range $cmd 1 999]]} {
set p [dict get $dcc [string range $cmd 1 999]]
$p $nickname $uhost $handle $value
return
}
puts "ERROR: $cmd does not exists in dcc";
}
source $scriptname
# TESTS GO HERE
pub "!giphy"
after 1000
pub "!giphy" "ice hockey fight"
after 1000
pub ".giphy" "arnold schwarzenegger"
after 1000
pub ".giphy" "i'm bored"
after 1000
pub ".giphy" "heavy metal"