· 9 years ago · Sep 15, 2016, 11:04 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.
86priorScriptTriggersTemp = "^F vCqqmL 0ymYhm PCvD|PYC00 gdyhm|[WHki]|^jdC MYm OC00mDmq Ob Dnm NyLq|DmZZ em|KZmMvm YmvKdLq|0MyYb|NnMDhnM qdyL[P]?|^jdC nmMY vdemdLm MKKZMCqyLP|^RdCLqDyem hnMLPmq Dd qq|^lnm PYdCLq OmPyLv Dd vnMUm gydZmLDZb, eMUyLP yD nMYq Dd|MLvNmY DnMD gdyhm|NnMD yv NYdLP|ndN eMLb vyZgmYv|lnyv yv M gydZMDydL|WFj NnmYm|EnmYm MYm|Nnb MYm|M vd0D gdyhm NnyvKmYv|^[tdLvCZDMDydL odCLPm]|^jdC 0mmZ bdCYvmZ0 OmyLP KCZZmq MNMb"
87
88## *** This is a list of certain keywords that GMS may/may not use.
89dangerTriggersTemp = "(yPLdY|hdLDyLC|\bDbK(m[vq]?|yLP)\b|nmZZd|YmvKdLq|YmKZb|MLvNmY|vKmMU|vKdUmL|NnyvKmY|vhYmMe|\bWHki\b|MZdCq|DMZU|\bvhYyKD(v?|yLP|mq)\b|veyZ|0YdNL|vLdYD|\bbmZZ\b|mfhZMye|MLLdCLh|qmhZMY|gdyh|vMb|hZMye|Odde|vndCD|Dnyv KZMhm|bdC DnmYm|v8CmMU|vKyqmY|MZmYD|hnmmY|Ldq|cCeK|NMg|vDdK|MDDmLDydL|\bvyZgmY[v]?\b|YmvKdLvygm|NYdLP|vKyqmY|edLUmb|edCvm|\bYMD\b|0YdP|qmeMLq)/y"
90### Checks for CAPITAL letters length 5 to 100. See ignores below.
91capital_triggers = /([A-Z]{5,100})/
92
93## ***
94## *** Ignore line patterns below
95## ***
96
97## Rooms where all lines are ignored. Add rooms as necessary.
98## These are generally shops and/or resting nodes.
99rivers_rest_rooms = [10863,10911,10949,10992,10915,10863,10935,11002,10934,10943]
100fwi_rooms = [3672,3670,16349,12306,16363,3654,3845,16470,12285,12282]
101landing_rooms = [1776,408,405,6256,3785,420,3809,5612,3824,400,399,7389,7315,7000,16504,16393,16423,4141,1838,1837,9276, 325]
102icemule_rooms = [9999, 3778, 3370, 2466, 2464, 2422, 13055, 3363]
103solhaven_rooms = [12805,1507,5710,5719,13054,9397,5711,5719,5716,5722]
104tavaalor_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]
105teras_rooms = [5906,3727,3483,1957,1851,1838,1885,1886,1932,12511,11,1439,644]
106safe_rooms = [3668,10861,601,208,1572,3449,1263]
107#safe_rooms = [3668,10861,188,2300,228,601,208,1572] if $lmas_audience == true
108
109## This combins the ignore rooms list
110$always_ignore_rooms = /\b(#{(rivers_rest_rooms+fwi_rooms+landing_rooms+icemule_rooms+solhaven_rooms+tavaalor_rooms+teras_rooms+safe_rooms).join('|')})\b/
111
112## ***
113## ***
114## This section is a hodgepodge of ignore lines. It does not really matter which category you put them under.
115## Just follow the same syntax.
116
117## ** Need to update these with additional magic casting
118ignore_magic_lines = [
119 '^w+ (gestures while|makes a nearly)',
120 '^The (elemental aura|air) around you',
121]
122
123ignore_environmentals = [
124 '^A sleek red squirrel hops nervously',
125 '^A rat skitters across the ground near your feet',
126 '^A raggedly-dressed lass lopes by',
127 '^Horrified screams suddenly pierce the air',
128 '^The rhythmic, basso belch of a bullfrog resounds',
129 '^A sudden silence falls over the area as the constant',
130 '^A sudden, loud squawking from the nearby fog',
131 '^The soft \'whuffing\' of wings attracts your attention', # YOU MUST ESCAPE SOME CHARACTERS, SUCH AS SINGLE QUOTES
132 '^The sirenflowers whisper in soft, echoing tones to one another before',
133 '^You hear the booming',
134 '^A wailing and screaming',
135 '^A nearby shadow seems to shift, revealing',
136 '^The spirit whispers with a sinister voice',
137 '^The scent of ozone rains down',
138 '^A sudden rattling of chains',
139 '^Suddenly the winds begin to gust',
140 '^Dark flames arc toward the ground',
141 '^The nauseating stink of putrefaction moves',
142 '^An evil hiss fills the air',
143 '^ Hot steam spray to the',
144 '^A gravelly hiss announces',
145 '^A layer of heavy mist floats above the grass',
146 '^The web wavers back and forth',
147 '^Suddenly, the winds begin to gust',
148 '^Each step causes water to seep to the surface of the spongy soil',
149 '^The faint sounds of some large animal trudging',
150 '^Light screeching sounds draw your attention',
151 '^A scrawny black rat scurries over your feet',
152 '^The trap door aove your head',
153 '^Something moves in the shadows, a blur',
154 '^Waves of black anti-mana',
155 '^Waves of energy',
156 '^The air shakes and twists as waves',
157 '^The air ripples in sickening',
158 '^THA-THUMP',
159 'Some whispered voices',
160 'Streaks of blanched fire lance the air',
161 'Her smile so sweet',
162]
163
164ignore_creatures = [
165 #'^An? \w+ drags (herself|himself) in',
166 #'^An? \w+ centaur ranger (snorts|notices)',
167 #'^A jungle troll chieftain shouts, "Ird t\'sum',
168 #'^A fire giant shouts out',
169 #'^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)',
170 #'^An? (ancient|grizzled)? ?forest trali (shaman)? ?(stalks|kneels|faces|nods|scrutinizes)',
171 #'^A mammoth arachnid waves',
172 #'^The hairs on the mammoth arachnid\'s',
173 #'^(An?|The) (kiramon|snow)? ?(defender|worker|barghest|madrinol) (is buffeted|emits)',
174 #'^A wave of (dark|emerald) ethereal',
175 #'^A greater faeroth bellows causing the air to distort',
176 #'^An? (ancient|grizzled)? ?baesrukha (speaks|waves|screams|extends) (a few|her|his|in)',
177 #'^A (greater)? ?bog troll (says|shouts|yells|asks|mutters), (".+")',
178 #'^A hisskra chieftain (stalks|leaps) in',
179 #'^(The|An?) moor wight suddenly stops moving',
180 #'^A gaunt spectral servant whispers haunting',
181 #'^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)',
182 #'^A spectral miner waves a hand through the',
183 #'^An? (\w+)? ?\w+ (stalks|trots) in',
184 #'^A moor witch screams an',
185 #'^A storm giant looks up at a passing',
186 #'^A shan (ranger|cleric|warrior|wizard) (slowly|waves|nods|swings)',
187 #'^A swamp hag screams an angry torrent of curses',
188 #'^A dreadnought raptor ignores the terrible',
189 #'^The (worker|defender) (clicks|chitters)',
190 #'^A giant weasel scampers',
191]
192
193ignore_spell_effects = [
194 '^You are buffeted by the (dark|emerald|icy|russet|formless|snapping)',
195 '^The invisible rash',
196 '^The shockwave (impacts|leaves|ripples|lifts|flings)',
197 '^The swarm (darts forward|continues to surround)',
198 '^You continue to struggle on the ground as the swarm',
199 '^A violent whirlwind continues swirling',
200 '^The (long)? ?thorny vine suddenly stops',
201 '^Dozens of long thorns suddenly grow',
202 '^ Some of the acid sticks to',
203 '^Acid continues to eat away',
204 '^While you\'re still a bit shaky', ## ESCAPED SINGLE QUOTE
205 '^The flames around you continue',
206 '^Your (heart|arm and fist|body|eyes) (stops|briefly|glaze|begins)',
207 '^You (continue|suddenly) (to)? ?feel',
208 '^A wave of power flows outward from you',
209 '^For a brief, terrible moment, your mind is opened',
210 '^The ground stops shaking as quickly',
211 '^You jump back, but',
212 '^You maintain your resolve',
213 '^You feel a powerful',
214 '^You stop singing',
215 '^You attempt to renew',
216 '^The air stops shimmering',
217 'You begin singing and focus ',
218 'Your SIGN',
219 'Glowing specks of sparkling',
220 'The air about you stops shimmering',
221]
222
223ignore_misc = [
224 #'^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)',
225 '^Running your fingers',
226 '^With a quick flick of',
227 '^As you place',
228 '^You have earned the following',
229 '^ Talk about a close shave',
230 '^You (work the blade|notice some)',
231 '^\w+ (picks up|removes|puts|works) an?',
232 #'^Mana:',
233 '^\w+ skillfully weaves',
234 '^\w+ makes a nearly imperceptible',
235 '"For we shall all walk in (his|her) light',
236 '\[If you wish to teleport',
237 '\[You have been awarded an Urchin',
238 '^A small rat scurries',
239 '^A quick count reveals',
240 '^The wave of white',
241 '^As you carefully forage',
242 '^There appears to be an item',
243 '^If you wish to continue, throw the item',
244 '^You have been tasked',
245 '^A rat scurries across the floor',
246 '^An announcer shouts',
247 '^The wagon (?:shakes|bounces)'
248]
249
250ENCODING = "MOhqm0PnycUZeLdK8YvDCgNfb7FJtiHT52BrxoAkas9RWlXpEujSGI64VzQ31w"
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
269def encode(text)
270 return text.tr(ALPHABET, ENCODING)
271end
272
273def decode(text)
274 return text.tr(ENCODING, ALPHABET)
275end
276
277
278consolidated = [
279 '^Mana:',
280 '^\(Use <d>SKILLS BASE</d>',
281 '^\d+ days remain until the annual',
282 '\s*(CMAN|USAGE|INVENTORY|ARMOR|WEAPONS|COMBAT|CONTAINERS|FLUFF|REGISTERED|BOOST|LUMNIS)',
283 '\s*(SHIELD|LOCKER|Stalking|Mana|SIMUCOIN)',
284 '^ <d>LOCKER',
285 '\s*(To specify|This includes 15)',
286 '^ (Awesome|Cross|Massive|Backfist|Jab|Fast grab|Jump|Powerful|Reverse|Sharp|Flying|Knee)',
287 '^ Incredible',
288 '^\[If you wish to teleport',
289 '^d100',
290 '^With a graceless',
291 '^1 day remains',
292 "^<style id=\"\"/><style id=\"roomDesc\"/>", ## XML IGNORES, not part of automatic ignore
293 "^<streamWindow id=", ## XML IGNORES, not part of automatic ignore
294]
295
296$always_ignore_danger = /#{(consolidated+ignore_magic_lines+ignore_environmentals+ignore_spell_effects+ignore_misc+ignore_city_environmentals).join('|')}/
297
298## OLD IGNORE CODE FROM TGO, STILL USING. PROBALY DONT NEED.
299$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+\)/
300
301#$always_ignore_test1 = /#{consolidated.join('|')}/
302## ** Ignore XML
303
304## This will ignore all XML with these strings. It bypasses EVERYTHING, including script patterns.
305## Room description was moved to consolidated as well as streamWindow to avoid automatic ignore.
306ignore_xml = [
307 "^<dialogData id=",
308 "^<indicator id=",
309 "<a exist=\"-?\\d+\" (noun|coord)=",
310 "^<pushStream id=",
311 "^<roundTime value=",
312 '.*<d cmd',
313 '<LaunchURL',
314 '^Where are you trying',
315 '^<right',
316 '^<left',
317]
318
319$always_ignore_xml = /#{ignore_xml.join('|')}/
320
321echo $always_ignore_xml
322echo $always_ignore_rooms
323echo $always_ignore_test1
324
325priorScriptTriggersTemp = decode(priorScriptTriggersTemp)
326prior_script_triggers = /#{priorScriptTriggersTemp}/i
327
328def sendMail(message, type)
329 for toEmail in [@email1, @email2]
330 Mail.new(
331 to: toEmail,
332 from: @fromEmail,
333 subject: type,
334 body: message
335 ).deliver!
336 end
337end
338
339## Section where exceptions are checked.
340def ignore_list(test_line)
341 echo "Inside def ignore_list. Line being tested is: #{test_line}" if $monitor_debug
342 ignore_reason = 'No ignore reason, returning false'; ignore_lines = false
343 #(ignore_reason = 'Ignoring line based on XML'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_xml
344 #(ignore_reason = 'Ignoring consolidated lines'; ignore_lines = true) if test_line =~ $always_ignore_test1
345 (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
346 (ignore_reason = 'Ignoring line based on danger ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_danger
347 (ignore_reason = 'Ignoring lines based on capital letter ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_capital
348 (ignore_reason = 'Ignoring lines based on total line length.'; echo ignore_reason if $monitor_debug; return true) if test_line.length > 200
349 echo ignore_reason if $monitor_debug
350 return ignore_lines
351end
352
353if $frontend == 'stormfront'
354 fam_window_begin = "<pushStream id=\"familiar\" ifClosedStyle=\"watching\"/>"
355 fam_window_end = "<popStream/>\r\n"
356else
357 fam_window_begin = "\034GSe\r\n"
358 fam_window_end = "\034GSf\r\n"
359end
360
361dangerTriggersTemp = decode(dangerTriggersTemp)
362danger_triggers = /#{dangerTriggersTemp}/
363
364## *** Start of main loop
365
366status_tags #enable XMLs
367while line = get
368
369 ## UNCOMMENT THIS LINE IF YOU WANT
370 #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.
371
372 ## Always send emails if a prior script pattern is triggered.
373 next if line =~ $always_ignore_xml
374 if line =~ prior_script_triggers
375 echo "Inside prior_script triggers." if $monitor_debug
376 echo line if $monitor_debug
377 echo "inside prior_script triggers, past next if for channels"
378 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
379 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}")
380 sendMail(line, "Prior scriptcheck patterns.") if $monitor_send_email
381 next
382 end
383
384 if line =~ capital_triggers
385 echo "Inside capital triggers before ignore." if $monitor_debug
386 next if ignore_list(line)
387 echo "Inside capital triggers after ignore." if $monitor_debug
388 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
389 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}")
390 sendMail(line, "Capital letters patterns.") if $monitor_send_email
391 next
392 end
393
394 if line =~ danger_triggers
395 echo "Inside danger triggers before ignore." if $monitor_debug
396 next if ignore_list(line)
397 echo "Inside danger triggers after ignore." if $monitor_debug
398 puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
399 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}")
400 sendMail(line, "Danger word patterns.") if $monitor_send_email
401 next
402 end
403end
404status_tags