-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmegahal.tcl
executable file
·158 lines (132 loc) · 5.23 KB
/
megahal.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# This is an accompanying TCL script to go with the MegaHAL eggdrop module
# It is optional but strongly recommended
# Should the bot learn what is said to it or only converse? Set to on/off.
set learnmode on
# What is the max size the brain should grow to?
# Set to the max number of nodes not ram
set maxsize 10000000
# Flood protection: how many max lines per how many seconds should it respond to?
set floodmega 60:60
# Which channels NOT to respond in when the botnick is mentioned (use space delimited list)
# Note: this includes the 'botnick: ' learning trigger
set respondexcludechans "general #general random #random"
# Which keywords besides the botnick should be responded to (use space delimited list)
# Examples can include alternative bot nicknames, people's names, special words like hello, music, etc
set responsekeywords ""
# How often should it talk in response to anything that is said in the channels?
# Set to # of lines or to 0 to turn this off.
set talkfreq 40
# Which channels NOT to talk in in response to all chatter (use space delimited list)
set talkexcludechans "general #general random #random"
# How often should it learn phrases that are said in the channels?
# Set to # of lines or to 0 to turn this off.
set learnfreq 100
# The following settings change the 'psychotic' level or personality of the AI slightly
# Max context size
# Valid values are 1-5
# 2 is highly recommended, 3 is much more boring but it will also produce much more coherent sentences
# 1 will make it babble incoherently a lot of the time and 4-5 will turn it into a parrot instead of a fun AI
set maxcontext 3
# Surprise mode on or off (0/1)
# This changes the way it constructs sentences.
# If on, it tries to find unconventional combinations of words which means much more fun but also more incoherent sentences
# If off, sentences are safer but more parrot-like so this is only recommended if the brain size is huge )in which case the bot has many safe options to use).
set surprise 0
# Max reply words
# This can help avoid long incoherent sentences that seem to run forever without making sense
# It limits the AI to create shorter sentences
# Recommended setting is about 25-40, set to 0 to allow unlimited size
set maxreplywords 25
#####################################################################
learningmode $learnmode
#Remove binding, since botnick is set in megahal.c
#TODO check if unbinding is required
# bind the botnick
#catch "unbind pub - hal: *pub:hal:"
#bind pub - ${nick}: *pub:hal:
#catch "unbind dcc - hal *dcc:hal"
#bind dcc - $nick *dcc:hal
set megabotnick $nick
# Save every 15minutes.
# Save and trim the brain once every hour
bind time - "*/15 * * * *" auto_brainsave
proc auto_brainsave {min b c d e} {
global maxsize
trimbrain $maxsize
savebrain
}
bind pub m ".savebrain" pub_savebrain
proc pub_savebrain {nick uhost hand chan arg} {
savebrain
puthelp "PRIVMSG $chan :Brain saved"
}
bind pub n ".trimbrain" pub_trimbrain
proc pub_trimbrain {nick uhost hand chan arg} {
global maxsize
set arg1 [lindex $arg 0]
if {$arg1 == "" || ![isnum $arg1]} {
set arg1 $maxsize
}
trimbrain $arg1
puthelp "PRIVMSG $chan :Brain trimmed"
}
bind pub n ".lobotomy" pub_lobotomy
proc pub_lobotomy {nick uhost hand chan arg} {
savebrain
file delete megahal.old
file copy megahal.brn megahal.old
file delete megahal.brn
reloadbrain
savebrain
puthelp "PRIVMSG $chan :Lobotomy completed! Creating a new brain..."
}
bind pub - ".braininfo" pub_braininfo
proc pub_braininfo {nick uhost hand chan arg} {
global learnmode
set for [treesize -1 0]
set back [treesize -1 1]
puthelp "PRIVMSG $chan :My current vocabulary consists of [lindex $for 0] words, my brain size is [expr [lindex $for 1]+[lindex $back 1]] nodes, and learning mode is $learnmode"
# if {[file exists megahal.old]} {
# puthelp "PRIVMSG $chan :This brain has been growing for [duration [expr [unixtime] - [file mtime megahal.old]]]"
# }
}
bind pub n ".learningmode" pub_learningmode
proc pub_learningmode {nick uhost hand chan arg} {
global learnmode
set arg1 [lindex $arg 0]
if {$arg1 == "" || ($arg1 != "on" && $arg1 != "off")} {
puthelp "PRIVMSG $chan :Usage: .learningmode on/off"
return
}
set learnmode $arg1
learningmode $learnmode
puthelp "PRIVMSG $chan :Learning mode is now set to $arg1"
}
bind pub m ".talkfrequency" pub_talkfrequency
proc pub_talkfrequency {nick uhost hand chan arg} {
global talkfreq
set arg1 [lindex $arg 0]
if {$arg1 == ""} {
puthelp "PRIVMSG $chan :Talking frequency is set to $talkfreq lines"
return
}
set talkfreq $arg1
puthelp "PRIVMSG $chan :Talking frequency is now set to $arg1 lines"
}
bind pub n ".restorebrain" pub_restorebrain
proc pub_restorebrain {nick uhost hand chan arg} {
if {[file exists megahal.old]} {
file delete megahal.brn
file copy megahal.old megahal.brn
reloadbrain
puthelp "PRIVMSG $chan :Old brain restored!"
} else {
puthelp "PRIVMSG $chan :Old brain not found!"
}
}
proc isnum {num} {
for {set x 0} {$x < [string length $num]} {incr x} {
if {[string trim [string index $num $x] 0123456789.] != ""} {return 0}
}
return 1
}