-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchobby_id_scraper.lua
55 lines (51 loc) · 1.7 KB
/
chobby_id_scraper.lua
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
function widget:GetInfo()
return {
name = "Shaman Scrapper",
desc = "Scraps user info and pours it into the ADVENT database.",
author = "_Shaman",
date = "11 July 2016",
license = "GNU LGPL, v2.1 or later",
layer = -100000,
enabled = true -- loaded by default?
}
end
local users = {}
local open = io.open
local textfile = open("luaui\\scraper.txt", 'r')
if not textfile then
local textfile,error = open("luaui\\scraper.txt",'w')
assert(textfile,error)
textfile:write("")
textfile:close()
end
for line in io.lines("luaui\\scraper.txt") do
local words = {}
local i = 1
line = line:gsub("#","")
line = line:gsub("(","")
line = line:gsub(")","")
line = line:gsub(":flag_","")
line = line:gsub(":","")
for w in string.gmatch(line,"%s+") do words[i] = w; i=i+1; end -- STEAMID COUNTRY_CODE USERNAME (#LOBBYID)
users[words[4]] = true
end
textfile:close()
local function Scraper(listener, userName)
local userInfo = lobby:GetUser(userName)
if userInfo and users[userInfo.accountID] == nil and userInfo.steamID then
local textfile = open("luaui\\scraper.txt", "a")
if userInfo.country == "??" then
textfile:write(userInfo.steamID .. " :grey_question: " .. userName .. "(#" .. userInfo.accountID .. ")\n")
else
textfile:write(userInfo.steamID .. " :flag_" .. string.lower(userInfo.country) .. ": " .. userName .. "(#" .. userInfo.accountID .. ")\n")
end
textfile:close()
users[userInfo.accountID] = true
end
end
function widget:Initialize()
VFS.Include(LUA_DIRNAME .. "widgets/chobby/headers/exports.lua", nil, VFS.RAW_FIRST)
lobby:AddListener("OnAddUser", Scraper)
lobby:AddListener("OnUpdateUserStatus", Scraper)
end
--local textfile = open("luaui\\scraper.txt", 'r')