SHOW:
|
|
- or go back to the newest paste.
| 1 | local side = 'back' --Define rednet side | |
| 2 | local file = fs.open("/blacklist", "r")
| |
| 3 | - | local IDblack = file.readLine(1)--All blacklisted IDs |
| 3 | + | local allBlacklists = textutils.unserialise(file.readAll()) --Un-serialise the contents of the file. Convert text to table basically. |
| 4 | - | local black = file.readLine(2) --All blacklisted messages |
| 4 | + | local IDblack = allBlacklists.ids --Set IDblack to ids sub-table of allBlacklists |
| 5 | local black = allBlacklists.msg --Same story | |
| 6 | file.close() | |
| 7 | ||
| 8 | rednet.open(side) --Open rednet | |
| 9 | ||
| 10 | ||
| 11 | ||
| 12 | id, msg = rednet.receive() --Receive the message | |
| 13 | ||
| 14 | ||
| 15 | local detected = false --Define a new variable called detected | |
| 16 | ||
| 17 | print("ID = " .. id)
| |
| 18 | print("msg = " .. msg)
| |
| 19 | ||
| 20 | ||
| 21 | for i=1,#IDblack do --Do the following block of code Length of IDblack times. i stores the current run. | |
| 22 | print("IDBLACK" .. IDblack[i])
| |
| 23 | if id == IDblack[i] then --If the current run found that IDblack contains an ID then do the following block of code | |
| 24 | for j=1,#black do --Do the following block of code amount of entries in black times. | |
| 25 | print("black" .. black[j])
| |
| 26 | if msg == black[j] then --If current run found that black contains the sent message then | |
| 27 | detected = true --Set detected to true | |
| 28 | print("Detected")
| |
| 29 | break --And exit the loop | |
| 30 | end | |
| 31 | end | |
| 32 | end | |
| 33 | if detected == true then | |
| 34 | break | |
| 35 | end | |
| 36 | end | |
| 37 | ||
| 38 | if detected == true then --Do the alerting only if detected was set to true. | |
| 39 | print('Blocked ID: '..id..' Detected... Denying Access')
| |
| 40 | rednet.send(id, 'You Are Blacklisted!') | |
| 41 | end |