· 9 years ago · Sep 15, 2016, 08:38 PM
1#hide_me
2
3=begin
4
5This script checks for certain lines and alerts the person to their presence. It uses the familiar window in game, and an email system. You must have the mail gem installed.
6SMS is also enabled if your carrier has "email to text".
7
8Note: Any inattentive scripting is against Simutronics policy. This should NOT be used to script away from keyboard. It is ONLY meant as a detection device
9so you can catch script checks through text scroll while at the keyboard. Simutronics has the power to issue script warnings
10even if you pass a script check. This is NOT designed to protect against AFK scripting.
11
12There is no AS/DS checks here. This will not protect against those types of checks.
13
14Since this is public as of 09/15/2016, expect many of the keywords below to not be used by GMs, and update accordingly.
15
16v. 02 by Kalros/Haldrik
17
18-- v.02 changelog
19
20Added more variables.
21
22***************
23**What it does
24***************
25
26This script parses every game line and checks it against 3 patterns. Known script checks,
27danger script checks, and capital letters.
28
29If any line is triggered, it passes through to the exceptions/exemptions. If there is no exception,
30notification is sent. Script check patterns are ALWAYS sent.
31
32This tests against XML lines.
33
34****************
35** Instructions
36****************
37
381. You must install "mail gem". This may or may not work out of the box.
39Go to cmd prompt and type "gem install mail". If not, you may need to google how to install gems.
40
412. You must enable outgoing SMTP in gmail settings.
42
433. You must update @sendUserName and @sendPassword and @email1/@email2. You do not need to update the others if you use gmail.
44
454. Update exception patterns as needed if things are popping that should not be.
46
475. Review line 352, it contains a break if !running certain scripts. Uncomment if you want.
48
49=end
50
51require 'mail'
52
53$monitor_debug = true ## Debug option, turn off if you don't want to see patterns. Recommened TRUE during initial runs.
54$monitor_send_email = true
55
56## Start variables
57
58@sendAddress = "smtp.gmail.com"
59@sendPort = 587
60@sendDomain = "gmail.com"
61## CHANGE THIS TO YOUR USER NAME
62@sendUserName = "gemstoneruby" # this is your username excluding @gmail.com
63@sendPassword = "plaintextpassword" # CHANGE
64@fromEmail = "full email" # ex, gemstoneruby@gmail.com
65
66## TO EMAILS - Max of 2 emails currently
67@email1 = "999-999-9999@txt.att.net" # example of email to text for ATT
68@email2 = "youremail@gmail.com" # Email notification is sent here.
69
70
71options = { :address => @sendAddress,
72 :port => @sendPort,
73 :domain => @sendDomain,
74 :user_name => @sendUserName,
75 :password => @sendPassword,
76 :authentication => 'plain', # this might need to change if you don't use gmail.
77 :enable_starttls_auto => true }
78
79Mail.defaults do
80 delivery_method :smtp, options
81end
82
83
84## *** Trigger patterns
85## *** Insert any known script triggers here, these will ALWAYS fire.
86prior_script_triggers = /^A sudden fierce gust|gruff voice|\[SEND\]|^You are buffeted by the wind|tell me|please respond|fairy|whatcha doin[g]?|^You hear someone applauding|^Roundtime changed to \d\d|^The ground begins to shake violently, making it hard to|answer that voice|what is wrong|how many silvers|This is a violation|SAY where|Where are|why are|a soft voice whispers|^\[Consultation Lounge\]|^You feel yourself being pulled away/i
87
88## *** This is a list of certain keywords that GMS may/may not use.
89danger_triggers = /(ignor|continu|\btyp(e[sd]?|ing)\b|hello|respond|reply|answer|speak|spoken|whisper|scream|\bSEND\b|aloud|talk|\bscript(s?|ing|ed)\b|smil|frown|snort|\byell\b|exclaim|announc|declar|voic|say|claim|boom|shout|this place|you there|squeak|spider|alert|cheer|nod|jump|wav|stop|attention|\bsilver[s]?\b|responsive|wrong|spider|monkey|mouse|\brat\b|frog|demand)/i
90
91### Checks for CAPITAL letters length 5 to 100. See ignores below.
92capital_triggers = /([A-Z]{5,100})/
93
94## ***
95## *** Ignore line patterns below
96## ***
97
98## Rooms where all lines are ignored. Add rooms as necessary.
99## These are generally shops and/or resting nodes.
100rivers_rest_rooms = [10863,10911,10949,10992,10915,10863,10935,11002,10934,10943]
101fwi_rooms = [3672,3670,16349,12306,16363,3654,3845,16470,12285,12282]
102landing_rooms = [1776,408,405,6256,3785,420,3809,5612,3824,400,399,7389,7315,7000,16504,16393,16423,4141,1838,1837,9276, 325]
103icemule_rooms = [9999, 3778, 3370, 2466, 2464, 2422, 13055, 3363]
104solhaven_rooms = [12805,1507,5710,5719,13054,9397,5711,5719,5716,5722]
105tavaalor_rooms = [13930,13943,13938,10327,10379,10329,10325,10396,10364,10332,5906,5907,3523,3516,10332,10434,13954,37,13048,10082,3672,34,32,4019,640,4024,9687,4686,4663,13137,10070]
106teras_rooms = [5906,3727,3483,1957,1851,1838,1885,1886,1932,12511,11,1439,644]
107safe_rooms = [3668,10861,601,208,1572,3449,1263]
108#safe_rooms = [3668,10861,188,2300,228,601,208,1572] if $lmas_audience == true
109
110## This combins the ignore rooms list
111$always_ignore_rooms = /\b(#{(rivers_rest_rooms+fwi_rooms+landing_rooms+icemule_rooms+solhaven_rooms+tavaalor_rooms+teras_rooms+safe_rooms).join('|')})\b/
112
113## ***
114## ***
115## This section is a hodgepodge of ignore lines. It does not really matter which category you put them under.
116## Just follow the same syntax.
117
118## ** Need to update these with additional magic casting
119ignore_magic_lines = [
120 '^w+ (gestures while|makes a nearly)',
121 '^The (elemental aura|air) around you',
122]
123
124ignore_environmentals = [
125 '^A sleek red squirrel hops nervously',
126 '^A rat skitters across the ground near your feet',
127 '^A raggedly-dressed lass lopes by',
128 '^Horrified screams suddenly pierce the air',
129 '^The rhythmic, basso belch of a bullfrog resounds',
130 '^A sudden silence falls over the area as the constant',
131 '^A sudden, loud squawking from the nearby fog',
132 '^The soft \'whuffing\' of wings attracts your attention', # YOU MUST ESCAPE SOME CHARACTERS, SUCH AS SINGLE QUOTES
133 '^The sirenflowers whisper in soft, echoing tones to one another before',
134 '^You hear the booming',
135 '^A wailing and screaming',
136 '^A nearby shadow seems to shift, revealing',
137 '^The spirit whispers with a sinister voice',
138 '^The scent of ozone rains down',
139 '^A sudden rattling of chains',
140 '^Suddenly the winds begin to gust',
141 '^Dark flames arc toward the ground',
142 '^The nauseating stink of putrefaction moves',
143 '^An evil hiss fills the air',
144 '^ Hot steam spray to the',
145 '^A gravelly hiss announces',
146 '^A layer of heavy mist floats above the grass',
147 '^The web wavers back and forth',
148 '^Suddenly, the winds begin to gust',
149 '^Each step causes water to seep to the surface of the spongy soil',
150 '^The faint sounds of some large animal trudging',
151 '^Light screeching sounds draw your attention',
152 '^A scrawny black rat scurries over your feet',
153 '^The trap door aove your head',
154 '^Something moves in the shadows, a blur',
155 '^Waves of black anti-mana',
156 '^Waves of energy',
157 '^The air shakes and twists as waves',
158 '^The air ripples in sickening',
159 '^THA-THUMP',
160 'Some whispered voices',
161 'Streaks of blanched fire lance the air',
162 'Her smile so sweet',
163]
164
165ignore_creatures = [
166 #'^An? \w+ drags (herself|himself) in',
167 #'^An? \w+ centaur ranger (snorts|notices)',
168 #'^A jungle troll chieftain shouts, "Ird t\'sum',
169 #'^A fire giant shouts out',
170 #'^An? (ancient|grizzled)? ?(baesrukha|carceris|seeker|luminous spectre|nonomino|frenzied monk|frost giant|greater moor wight|phantasm|black forest ogre) (waves|points|nods) (an?|at|her|his|in|a few) (elongated, clawed|icy|decaying|rotting|spectral|skeletal|clawed|ghastly) (finger|hand)',
171 #'^An? (ancient|grizzled)? ?forest trali (shaman)? ?(stalks|kneels|faces|nods|scrutinizes)',
172 #'^A mammoth arachnid waves',
173 #'^The hairs on the mammoth arachnid\'s',
174 #'^(An?|The) (kiramon|snow)? ?(defender|worker|barghest|madrinol) (is buffeted|emits)',
175 #'^A wave of (dark|emerald) ethereal',
176 #'^A greater faeroth bellows causing the air to distort',
177 #'^An? (ancient|grizzled)? ?baesrukha (speaks|waves|screams|extends) (a few|her|his|in)',
178 #'^A (greater)? ?bog troll (says|shouts|yells|asks|mutters), (".+")',
179 #'^A hisskra chieftain (stalks|leaps) in',
180 #'^(The|An?) moor wight suddenly stops moving',
181 #'^A gaunt spectral servant whispers haunting',
182 #'^An? (ancient|grizzled)? ?(shadow|night|black|snow|hunch-backed) (steed|mare|forest ogre|madrinol|dogmatist) (rears|shakes|snorts|nods|waves) (back|her|his|at|as|and)',
183 #'^A spectral miner waves a hand through the',
184 #'^An? (\w+)? ?\w+ (stalks|trots) in',
185 #'^A moor witch screams an',
186 #'^A storm giant looks up at a passing',
187 #'^A shan (ranger|cleric|warrior|wizard) (slowly|waves|nods|swings)',
188 #'^A swamp hag screams an angry torrent of curses',
189 #'^A dreadnought raptor ignores the terrible',
190 #'^The (worker|defender) (clicks|chitters)',
191 #'^A giant weasel scampers',
192]
193
194ignore_spell_effects = [
195 '^You are buffeted by the (dark|emerald|icy|russet|formless|snapping)',
196 '^The invisible rash',
197 '^The shockwave (impacts|leaves|ripples|lifts|flings)',
198 '^The swarm (darts forward|continues to surround)',
199 '^You continue to struggle on the ground as the swarm',
200 '^A violent whirlwind continues swirling',
201 '^The (long)? ?thorny vine suddenly stops',
202 '^Dozens of long thorns suddenly grow',
203 '^ Some of the acid sticks to',
204 '^Acid continues to eat away',
205 '^While you\'re still a bit shaky', ## ESCAPED SINGLE QUOTE
206 '^The flames around you continue',
207 '^Your (heart|arm and fist|body|eyes) (stops|briefly|glaze|begins)',
208 '^You (continue|suddenly) (to)? ?feel',
209 '^A wave of power flows outward from you',
210 '^For a brief, terrible moment, your mind is opened',
211 '^The ground stops shaking as quickly',
212 '^You jump back, but',
213 '^You maintain your resolve',
214 '^You feel a powerful',
215 '^You stop singing',
216 '^You attempt to renew',
217 '^The air stops shimmering',
218 'You begin singing and focus ',
219 'Your SIGN',
220 'Glowing specks of sparkling',
221 'The air about you stops shimmering',
222]
223
224ignore_misc = [
225 #'^You (attach|add|forage|pick|put|push|remove|tap|gather|swap|open|carefully|grab|tuck|drop|climb|close|settle|reach|rummage|slip|give|toss|take|seize)',
226 '^Running your fingers',
227 '^With a quick flick of',
228 '^As you place',
229 '^You have earned the following',
230 '^ Talk about a close shave',
231 '^You (work the blade|notice some)',
232 '^\w+ (picks up|removes|puts|works) an?',
233 #'^Mana:',
234 '^\w+ skillfully weaves',
235 '^\w+ makes a nearly imperceptible',
236 '"For we shall all walk in (his|her) light',
237 '\[If you wish to teleport',
238 '\[You have been awarded an Urchin',
239 '^A small rat scurries',
240 '^A quick count reveals',
241 '^The wave of white',
242 '^As you carefully forage',
243 '^There appears to be an item',
244 '^If you wish to continue, throw the item',
245 '^You have been tasked',
246 '^A rat scurries across the floor',
247 '^An announcer shouts',
248 '^The wagon (?:shakes|bounces)'
249]
250
251ignore_city_environmentals = [
252 '^A crier hurries',
253 '^He continues, "Those citizens holding',
254 '^With a satisfied rumble, it stalks off',
255 '^You hear the voice of the clerk',
256 '^"Everybody is always in a hurry these',
257 '^The aardvark (surveys|narrows)',
258 '^A (robed|young lithe|dark-haired) (human|elven|half-elven) priestess (says|removes|stops)',
259 '^A city guardsman walks in',
260 '^You hear the voice of a (lithe|blond) (Ardenai|Loenthran) (druid|merchant) yelling',
261 '^The soldier stops in particular area',
262 '^The glow from the tree pulses slightly, sending forth shimmering waves of',
263 '^From nearby, you hear a .+ yell, "Slow down\!"',
264 '^The Loenthran merchant says, "(I\'ve got strings|You too can play)',
265 '^Several small conical-snotted critters',
266 '^A shadow crosses the small beam',
267]
268
269consolidated = [
270 '^Mana:',
271 '^\(Use <d>SKILLS BASE</d>',
272 '^\d+ days remain until the annual',
273 '\s*(CMAN|USAGE|INVENTORY|ARMOR|WEAPONS|COMBAT|CONTAINERS|FLUFF|REGISTERED|BOOST|LUMNIS)',
274 '\s*(SHIELD|LOCKER|Stalking|Mana|SIMUCOIN)',
275 '^ <d>LOCKER',
276 '\s*(To specify|This includes 15)',
277 '^ (Awesome|Cross|Massive|Backfist|Jab|Fast grab|Jump|Powerful|Reverse|Sharp|Flying|Knee)',
278 '^ Incredible',
279 '^\[If you wish to teleport',
280 '^d100',
281 '^With a graceless',
282 '^1 day remains',
283 "^<style id=\"\"/><style id=\"roomDesc\"/>", ## XML IGNORES, not part of automatic ignore
284 "^<streamWindow id=", ## XML IGNORES, not part of automatic ignore
285]
286
287$always_ignore_danger = /#{(consolidated+ignore_magic_lines+ignore_environmentals+ignore_spell_effects+ignore_misc+ignore_city_environmentals).join('|')}/
288
289## OLD IGNORE CODE FROM TGO, STILL USING. PROBALY DONT NEED.
290$always_ignore_capital = /\s*(Strength|Constitution|Dexterity|Agility|Discipline|Aura|Logic|Intuition|Wisdom|Influence)\s+\((STR|CON|DEX|AGI|DIS|AUR|LOG|INT|WIS|INF)\)\:\s+\d+\s+\(-?\d+\)\s+\.\.\.\s+\d+\s+\(-?\d+\)/
291
292#$always_ignore_test1 = /#{consolidated.join('|')}/
293## ** Ignore XML
294
295## This will ignore all XML with these strings. It bypasses EVERYTHING, including script patterns.
296## Room description was moved to consolidated as well as streamWindow to avoid automatic ignore.
297ignore_xml = [
298 "^<dialogData id=",
299 "^<indicator id=",
300 "<a exist=\"-?\\d+\" (noun|coord)=",
301 "^<pushStream id=",
302 "^<roundTime value=",
303 '.*<d cmd',
304 '<LaunchURL',
305 '^Where are you trying',
306 '^<right',
307 '^<left',
308]
309
310$always_ignore_xml = /#{ignore_xml.join('|')}/
311
312echo $always_ignore_xml
313echo $always_ignore_rooms
314echo $always_ignore_test1
315
316
317def sendMail(message, type)
318 for toEmail in [@email1, @email2]
319 Mail.new(
320 to: toEmail,
321 from: @fromEmail,
322 subject: type,
323 body: message
324 ).deliver!
325 end
326end
327
328## Section where exceptions are checked.
329def ignore_list(test_line)
330 echo "Inside def ignore_list. Line being tested is: #{test_line}" if $monitor_debug
331 ignore_reason = 'No ignore reason, returning false'; ignore_lines = false
332 #(ignore_reason = 'Ignoring line based on XML'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_xml
333 #(ignore_reason = 'Ignoring consolidated lines'; ignore_lines = true) if test_line =~ $always_ignore_test1
334 (ignore_reason = 'Ignoring line based on excluded rooms.'; echo ignore_reason if $monitor_debug; return true) if Room.current.id.to_s =~ $always_ignore_rooms
335 (ignore_reason = 'Ignoring line based on danger ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_danger
336 (ignore_reason = 'Ignoring lines based on capital letter ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_capital
337 (ignore_reason = 'Ignoring lines based on total line length.'; echo ignore_reason if $monitor_debug; return true) if test_line.length > 200
338 echo ignore_reason if $monitor_debug
339 return ignore_lines
340end
341
342if $frontend == 'stormfront'
343 fam_window_begin = "<pushStream id=\"familiar\" ifClosedStyle=\"watching\"/>"
344 fam_window_end = "<popStream/>\r\n"
345else
346 fam_window_begin = "\034GSe\r\n"
347 fam_window_end = "\034GSf\r\n"
348end
349
350## *** Start of main loop
351
352status_tags #enable XMLs
353while line = get
354
355 ## UNCOMMENT THIS LINE IF YOU WANT
356 #break unless running?('sbounty') or running?('grguild') or running?('bigshot') or $monitor_debug == true ## Scripts that need to be running for monitor to stay running.
357
358 ## Always send emails if a prior script pattern is triggered.
359 next if line =~ $always_ignore_xml
360 if line =~ prior_script_triggers
361 echo "Inside prior_script triggers." if $monitor_debug
362 echo line if $monitor_debug
363 echo "inside prior_script triggers, past next if for channels"
364 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
365 puts("#{fam_window_begin}Unrecognized game line. Prior scriptcheck pattern detected.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
366 sendMail(line, "Prior scriptcheck patterns.") if $monitor_send_email
367 next
368 end
369
370 if line =~ capital_triggers
371 echo "Inside capital triggers before ignore." if $monitor_debug
372 next if ignore_list(line)
373 echo "Inside capital triggers after ignore." if $monitor_debug
374 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
375 puts("#{fam_window_begin}Unrecognized game line. Capital letters pattern.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
376 sendMail(line, "Capital letters patterns.") if $monitor_send_email
377 next
378 end
379
380 if line =~ danger_triggers
381 echo "Inside danger triggers before ignore." if $monitor_debug
382 next if ignore_list(line)
383 echo "Inside danger triggers after ignore." if $monitor_debug
384 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
385 puts("#{fam_window_begin}Unrecognized game line. Danger patterns detected.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
386 sendMail(line, "Danger word patterns.") if $monitor_send_email
387 next
388 end
389end
390status_tags