hi,
i have software (aGsm) which gets me the information of our local game servers and save the information as html files.
i need a script to show this files in my hub in an arranged manner with details from the files.
can some plzz script it for me.
thanks,
achiever.
the files shows information like
extended infromation for HalfLife-TFC-CS server lol?!?!?
Address: 172.19.25.184:27015
Players: 16 / 32
Game : HalfLife-TFC-CS
Map : fy_iceworld_cz
Ping : 16
the in formation in bolds are constants and the values keep on changing from server to server.
i need this to be shown as
Game: Condition Zero Server: 172.19.25.184:27015 Map: fy_iceworld_cz Hostname: lol?!?!? Ping: 16 Players: 16/32 [Bill(3) TYrone!!!!!!!!(2) Dustin(1) Toby(0) Opie(0) Josh(0) Pat(0) Calvin(0) Clarence(0) Frank(0) Alfred(0) Fred(0) Ulric(0) Perry(0) Will(0) Frasier(0) -- which is in order of player-name(frags)]
and this information shown for all the servers listed.
plzz c the attached file,
i hope i was able to explain it properly.
thnks for help,
achiever.
List of servers on our LAN List of servers, our LAN
June 18, 2007 at 13:01:14
# Name Address Players State Game Launch!
1 Counter-Strike: Condition Zero 172.19.19.90:27015 13/13 running HalfLife-TFC-CS GO
2 lol?!?!? 172.19.25.184:27015 16/32 running HalfLife-TFC-CS GO
3 Condition Zero 172.19.3.20:27015 18/20 running HalfLife-TFC-CS GO
Do you like this?
can it be
# Game Host-Name Address Map Ping Players
game mentioned should be 1st, then the name which is really the host name and also ping and map info from the linked files
the state and launch will not be needed in hub
thanks,
achiever.
Quote from: achiever on 20 June, 2007, 15:33:50
can it be
# Game Host-Name Address Map Ping Players
game mentioned should be 1st, then the name which is really the host name and also ping and map info from the linked files
the state and launch will not be needed in hub
thanks,
achiever.
I'm afraid it is not easy to do since I am just parsing the HTML files. Can't you change the way your program fetches the info?
hmm i'll try to work it out :-(, but i m sure i'll not be able add nething to main file. still have go can u please think of some way to do this?
i have done changes to the sub files which now shows all the info in order.
so now can we take it directly from the subfiles only?
i m attaching the changed files
List of servers on our LAN List of our LAN servers
June 20, 2007 at 20:16:04
# Name Address Players State Game Launch!
1 :D:D 172.19.1.103:27015 6/32 running HalfLife-TFC-CS GO
2 Counter-Strike: Condition Zero 172.19.19.90:27015 13/13 running HalfLife-TFC-CS GO
3 *)((_.NeelZ._))(* 172.19.33.66:27015 13/32 running HalfLife-TFC-CS GO
4 pass-->hAha 172.19.30.40:27015 16/22 running HalfLife-TFC-CS GO
The sdf files contain way too few info.
ok i think i get it now, we can not pick only the information we want from html files as we can from text files to be displayed, correct?
so u posted the 1st file info only.
i have removed all the other info from the sub files except the required once can it be done now.
plzz have a look.
if not yet, cant we convert it to text files first then go do it?
thanks for being patient,
achiever.
I cannot fetch them from the text version either, if I only have the HTML, because I do not know which table header belongs to which column in the table. :(
i did not understand u difficulty?
do u need the info in a table manner?
or is it a dead end with no solution :'(
i have made it in table form.
plzz plzz try now :-\
attached files,
thanks
achiever.
Wouldn't that be easier to serve the HTML files with the PtokaX webserver and announce links in mainchat?
i run a lan hub and have no webserver. :(
but u were getting the display alright for main file?
then y not for the others, actually now the main lan file is not required all the the data needed is there in sub files.
Quote from: achiever on 20 June, 2007, 19:25:27
i run a lan hub and have no webserver. :(
So what? If the users are from the LAN anyway, you just make your program put the HTML files into the webroot of the builtin PtokaX webserver, create a script that checks the list periodically, then the script will post the links to the files (eg. http://192.168.77.88:1234/fpsserv1.html)
for the eg. page i m getting The page cannot be displayed
but u were making the display earlier,
Quote from: bastya_elvtars on 20 June, 2007, 13:19:38
List of servers on our LAN List of servers, our LAN
June 18, 2007 at 13:01:14
# Name Address Players State Game Launch!
1 Counter-Strike: Condition Zero 172.19.19.90:27015 13/13 running HalfLife-TFC-CS GO
2 lol?!?!? 172.19.25.184:27015 16/32 running HalfLife-TFC-CS GO
3 Condition Zero 172.19.3.20:27015 18/20 running HalfLife-TFC-CS GO
Do you like this?
cant it be done now?
sorry for being persistant, i have just tried too hard for this 1.
achiever
Ah, it is a bit hard to make you understand. :-)
I'll make you an example.
i really m confused now :P that all the files are almost the same.
i think ur example will make it clear to me :)
bastya ;D ;D ;D
i have finally got all the detals to come in 1 file the main lan file :D :D :D
now plzz can u make the script or its making it being the difficult part? ::)
thanks,
achiever
http://rnrdoctor2.sytes.net:81/lan.html
This is served by PtokaX.
oh! wow!
plzz explain how, or can u give me the link where i can find how to do it?
and did u c my last post???
thanks neways,
achiever.
Just create directories in the PtokaX root folder:
html
html\webstats
and put the html files into html\webstats directory.
Of course you can use an external webserver, like shttpd (http://shttpd.sourceforge.net/) for this as well, since the PtokaX webserver is broken as hell.
Now you will need a script that announces these files. OR you can create an index.html linking to all files there.
ok thanks,
i think i'll try this tomorrow now.
neways i would still be much happier with a script if a could show the file as its in hub.
thanks a lot bastya for ur help :)
achiever.
I'll prepare that script for you but have some questions:
- Is there only one file to be displayed?
- Is there anything else to be added to the displayed message, like links or other stuff?
u kno what i can dance on hereing that.
-yes just the main lan.html only like u asked earlier would be too good, as i have managed to get all info to it
-no just show it in hub on cammands +servers
u made my day after all :)
thanks,
achiever.
--[[
This is a sample script base dupon my HTML parser
It grabs the content of a specified HTML file
and displays it in given intervals or on-demand.
Requested by achiever.
Distributed under a modified BSD license, see at the end of the file]]
-- Settings.
Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.
Command = "servers" -- The command for getting the serverinfo. NO prefix!
Filename = "Y:/Servers/lan.html"
-- End of settings, only edit below if you know what you are doing.
function Main()
if Timer ~= 0 then
SetTimer (Timer*60000)
StartTimer()
end
end
function ChatArrival (user, data)
local cmd = string.match (data, "^%b<>%s+[%+%!%-%?%§](%S+)%|$")
if cmd == Command then
user:SendData(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
return 1
end
end
function OnTimer()
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
end
function HTML_ToText (file)
-- Declare variables, load the file. Make tags lowercase.
local nl = "\r\n"
local text
local f,err=io.open (file)
if f then
text = f:read ("*a")
f:close()
else
SendToOps ("*** "..err)
return
end
text = string.gsub (text,"(%b<>)",
function (tag)
return tag:lower()
end)
--[[
First we kill the developer formatting (tabs, CR, LF)
and produce a long string with no newlines and tabs.
We also kill repeated spaces as browsers ignore them anyway.
]]
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
-- Then we remove the header. We do this by stripping it first.
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
-- Kill all scripts. First we nuke their attribs.
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
-- Ok, same for styles.
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
-- Replace <td> and <th> with tabulators.
text = string.gsub (text, "(<%s*td[^>]*>)","\t")
text = string.gsub (text, "(<%s*th[^>]*>)","\t")
-- Replace <br> with linebreaks.
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
-- Replace <li> with an asterisk surrounded by spaces.
-- Replace </li> with a newline.
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
-- <p>, <div>, <tr>, <ul> will be replaced to a double newline.
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
-- Some petting with the <a> tags. :-P
--[[ local addresses = {}
local c = 0
for url,name in string.gfind (text, "<%s*a%s*href=[\'\"](%S-)[\'\"][^>]*>(.+)<%s*%/a%s*>") do
c = c + 1
string.gsub (name, "<%s*a%s*href=[^>]+>(.+)<%s*%/a[^>]*>",
function (nm)
nm = string.gsub (nm, "(%b<>)","")
nm = nm.."["..c.."]"
return nm
end)
table.insert (addresses, {url, name})
print(url, nm)
end ]]
-- Nuke all other tags now.
text = string.gsub (text, "(%b<>)","")
-- Replace entities to their correspondant stuff where applicable.
-- C# is owned badly here by using a table. :-P
-- A metatable secures entities, so you can add them natively as keys.
-- Enclosing brackets also get added automatically (capture!)
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%;)" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
[" "] = " ",
["•"] = " * ",
["‹"] = "<",
["›"] = ">",
["™"] = "(tm)",
["⁄"] = "/",
["<"] = "<",
[">"] = ">",
["©"] = "(c)",
["®"] = "(r)",
-- Then kill all others.
-- You can customize this table if you would like to,
-- I just got bored of copypasting. :-)
-- http://hotwired.lycos.com/webmonkey/reference/special_characters/
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
-- text = text..nl..nl..("-"):rep(27)..nl..nl
--
-- for k,v in ipairs (addresses) do
-- text = text.."["..k.."] "..v[1]..nl
-- end
return text
end
--[[
Copyright (c) 2007, bastya_elvtars
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
to endorse or promote products derived from this code without specific
prior written permission.
THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
[02:31] Syntax ...s\My Hub\scripts\new.lua:47: bad argument #1 to 'gsub' (string expected, got nil)
Updated the above code.
working good.
THANKS
achiever.
You're welcome. Now admit that you forgot to specify the exact file path. :P
no i did not i had actually used this
G:\Servers\lan.html
but i think the script requires
G:/Servers/lan.html
u c the difference of \ and /
still gives error when i use the former, thought i kno the round :P
bastya i m thankful to u for making this script,
achiever
You should either use \\ or / in pathnames. Single backslashes serve a different purpose.
actually i took the address from the html file adress bar which showed G:\Servers\lan.html
wow mutor this 1 is good too
now have 2 scripts to the same thing :))
thanks far all ur help Bastya & Mutor,
achiever.
C:/Documents and Settings/SWAGAT.JAGIRDAR/Desktop/SERVER
i want this path add in script but i dont know where to add so plaese can any one show me where to add?
this the path of html files og game server
--Script Configuration
local Aux = {
--Admin's Nick
OpNick = "Mutor",
-- Botname pulled from the hub or use "CustomName"
Bot = frmHub:GetHubBotName(),
--Always respond in PM? "yes"/"no"
PmOnly = "no",
--Path to files [relevant to scripts folder or use absolute path]
Path = "Servers",
--Index file name
Index = "lan.html"
}
Change the Path variable.
It is not my script, Mutor made it. :-) Therefore I am forwarding your request to him. :-P
Sorry was pated wrong script :o
--[[
This is a sample script base dupon my HTML parser
It grabs the content of a specified HTML file
and displays it in given intervals or on-demand.
Requested by achiever.
Distributed under a modified BSD license, see at the end of the file]]
-- Settings.
Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.
Command = "servers" -- The command for getting the serverinfo. NO prefix!
Filename = "C:/Documents and Settings/SWAGAT.JAGIRDAR/Desktop/SERVER/lan.html"
-- End of settings, only edit below if you know what you are doing.
function Main()
if Timer ~= 0 then
SetTimer (Timer*60000)
StartTimer()
end
end
function ChatArrival (user, data)
local cmd = string.match (data, "^%b<>%s+[%+%!%-%?%?](%S+)%|$")
if cmd == Command then
--user:SendData(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
return 1
end
end
function OnTimer()
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
end
function HTML_ToText (file)
-- Declare variables, load the file. Make tags lowercase.
local nl = "\r\n"
local text
local f,err=io.open (file)
if f then
text = f:read ("*a")
f:close()
else
SendToOps ("*** "..err)
end
text = string.gsub (text,"(%b<>)",
function (tag)
return tag:lower()
end)
--[[
First we kill the developer formatting (tabs, CR, LF)
and produce a long string with no newlines and tabs.
We also kill repeated spaces as browsers ignore them anyway.
]]
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
-- Then we remove the header. We do this by stripping it first.
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
-- Kill all scripts. First we nuke their attribs.
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
-- Ok, same for styles.
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
-- Replace <td> and <th> with tabulators.
text = string.gsub (text, "(<%s*td[^>]*>)","\t")
text = string.gsub (text, "(<%s*th[^>]*>)","\t")
-- Replace <br> with linebreaks.
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
-- Replace <li> with an asterisk surrounded by spaces.
-- Replace </li> with a newline.
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
-- <p>, <div>, <tr>, <ul> will be replaced to a double newline.
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
-- Some petting with the <a> tags. :-P
--[[ local addresses = {}
local c = 0
for url,name in string.gfind (text, "<%s*a%s*href=[\'\"](%S-)[\'\"][^>]*>(.+)<%s*%/a%s*>") do
c = c + 1
string.gsub (name, "<%s*a%s*href=[^>]+>(.+)<%s*%/a[^>]*>",
function (nm)
nm = string.gsub (nm, "(%b<>)","")
nm = nm.."["..c.."]"
return nm
end)
table.insert (addresses, {url, name})
print(url, nm)
end ]]
-- Nuke all other tags now.
text = string.gsub (text, "(%b<>)","")
-- Replace entities to their correspondant stuff where applicable.
-- C# is owned badly here by using a table. :-P
-- A metatable secures entities, so you can add them natively as keys.
-- Enclosing brackets also get added automatically (capture!)
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%;)" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
[" "] = " ",
["•"] = " * ",
["‹"] = "<",
["›"] = ">",
["™"] = "(tm)",
["⁄"] = "/",
["<"] = "<",
[">"] = ">",
["©"] = "(c)",
["®"] = "(r)",
-- Then kill all others.
-- You can customize this table if you would like to,
-- I just got bored of copypasting. :-)
-- http://hotwired.lycos.com/webmonkey/reference/special_characters/
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
-- text = text..nl..nl..("-"):rep(27)..nl..nl
--
-- for k,v in ipairs (addresses) do
-- text = text.."["..k.."] "..v[1]..nl
-- end
return text
end
--[[
Copyright (c) 2007, bastya_elvtars
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
to endorse or promote products derived from this code without specific
prior written permission.
THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
i think Bastya's script has this option of timed messages
Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.
just put this same as the refresh time of ur software. :)
some error here
Syntax D:\Hub\terminator\scripts\cs.lua:50: bad argument #1 to 'gsub' (string expected, got nil)
--[[
This is a sample script base dupon my HTML parser
It grabs the content of a specified HTML file
and displays it in given intervals or on-demand.
Requested by achiever.
Distributed under a modified BSD license, see at the end of the file]]
-- Settings.
Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.
Command = "s" -- The command for getting the serverinfo. NO prefix!
Filename = "C:\Documents and Settings\Vinay Bherwani\Desktop\SERVER\lan.html"
-- End of settings, only edit below if you know what you are doing.
function Main()
if Timer ~= 0 then
SetTimer (Timer*60000)
StartTimer()
end
end
function ChatArrival (user, data)
local cmd = string.match (data, "^%b<>%s+[%+%!%-%?%?](%S+)%|$")
if cmd == Command then
--user:SendData(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
return 1
end
end
function OnTimer()
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
end
function HTML_ToText (file)
-- Declare variables, load the file. Make tags lowercase.
local nl = "\r\n"
local text
local f,err=io.open (file)
if f then
text = f:read ("*a")
f:close()
else
SendToOps ("*** "..err)
end
text = string.gsub (text,"(%b<>)",
function (tag)
return tag:lower()
end)
--[[
First we kill the developer formatting (tabs, CR, LF)
and produce a long string with no newlines and tabs.
We also kill repeated spaces as browsers ignore them anyway.
]]
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
-- Then we remove the header. We do this by stripping it first.
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
-- Kill all scripts. First we nuke their attribs.
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
-- Ok, same for styles.
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
-- Replace <td> and <th> with tabulators.
text = string.gsub (text, "(<%s*td[^>]*>)","\t")
text = string.gsub (text, "(<%s*th[^>]*>)","\t")
-- Replace <br> with linebreaks.
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
-- Replace <li> with an asterisk surrounded by spaces.
-- Replace </li> with a newline.
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
-- <p>, <div>, <tr>, <ul> will be replaced to a double newline.
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
-- Some petting with the <a> tags. :-P
--[[ local addresses = {}
local c = 0
for url,name in string.gfind (text, "<%s*a%s*href=[\'\"](%S-)[\'\"][^>]*>(.+)<%s*%/a%s*>") do
c = c + 1
string.gsub (name, "<%s*a%s*href=[^>]+>(.+)<%s*%/a[^>]*>",
function (nm)
nm = string.gsub (nm, "(%b<>)","")
nm = nm.."["..c.."]"
return nm
end)
table.insert (addresses, {url, name})
print(url, nm)
end ]]
-- Nuke all other tags now.
text = string.gsub (text, "(%b<>)","")
-- Replace entities to their correspondant stuff where applicable.
-- C# is owned badly here by using a table. :-P
-- A metatable secures entities, so you can add them natively as keys.
-- Enclosing brackets also get added automatically (capture!)
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%;)" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
[" "] = " ",
["•"] = " * ",
["‹"] = "<",
["›"] = ">",
["™"] = "(tm)",
["⁄"] = "/",
["<"] = "<",
[">"] = ">",
["©"] = "(c)",
["®"] = "(r)",
-- Then kill all others.
-- You can customize this table if you would like to,
-- I just got bored of copypasting. :-)
-- http://hotwired.lycos.com/webmonkey/reference/special_characters/
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
-- text = text..nl..nl..("-"):rep(27)..nl..nl
--
-- for k,v in ipairs (addresses) do
-- text = text.."["..k.."] "..v[1]..nl
-- end
return text
end
--[[
Copyright (c) 2007, bastya_elvtars
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
to endorse or promote products derived from this code without specific
prior written permission.
THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
Please help for this
Thanks Swagat_j
Does the file exist and contain material?
Edit: Mutor has given me a filesizer checking snippet.
Edit2: Filename = "C:\Documents and Settings\Vinay Bherwani\Desktop\SERVER\lan.html" is wrong. Use it like this: Filename = "C:\\Documents and Settings\\Vinay Bherwani\\Desktop\\SERVER\\lan.html"
Try this version:
--[[
This is a sample script base dupon my HTML parser
It grabs the content of a specified HTML file
and displays it in given intervals or on-demand.
Requested by achiever.
Distributed under a modified BSD license, see at the end of the file]]
-- Settings.
Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.
Command = "s" -- The command for getting the serverinfo. NO prefix!
Filename = "C:\Documents and Settings\Vinay Bherwani\Desktop\SERVER\lan.html"
-- End of settings, only edit below if you know what you are doing.
function Main()
if Timer ~= 0 then
SetTimer (Timer*60000)
StartTimer()
end
end
function ChatArrival (user, data)
local cmd = string.match (data, "^%b<>%s+[%+%!%-%?%?](%S+)%|$")
if cmd == Command then
--user:SendData(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
return 1
end
end
function OnTimer()
SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
end
function HTML_ToText (file)
-- Declare variables, load the file. Make tags lowercase.
local nl = "\r\n"
local text
local f,err=io.open (file)
if f then
if f:seek("end") <= 0 then
SendToOps ("*** ERROR: empty file specified: "..file) return
end
text = f:read ("*a")
f:close()
else
SendToOps ("*** "..err)
end
text = string.gsub (text,"(%b<>)",
function (tag)
return tag:lower()
end)
--[[
First we kill the developer formatting (tabs, CR, LF)
and produce a long string with no newlines and tabs.
We also kill repeated spaces as browsers ignore them anyway.
]]
local devkill=
{
["("..string.char(10)..")"] = " ",
["("..string.char(13)..")"] = " ",
["("..string.char(15)..")"] = "",
["(%s%s+)"]=" ",
}
for pat, res in pairs (devkill) do
text = string.gsub (text, pat, res)
end
-- Then we remove the header. We do this by stripping it first.
text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
text = string.gsub (text, "(<head>,*<%/head>)", "")
-- Kill all scripts. First we nuke their attribs.
text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
text = string.gsub (text, "(<script>,*<%/script>)", "")
-- Ok, same for styles.
text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
text = string.gsub (text, "(<style>.*<%/style>)", "")
-- Replace <td> and <th> with tabulators.
text = string.gsub (text, "(<%s*td[^>]*>)","\t")
text = string.gsub (text, "(<%s*th[^>]*>)","\t")
-- Replace <br> with linebreaks.
text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
-- Replace <li> with an asterisk surrounded by spaces.
-- Replace </li> with a newline.
text = string.gsub (text, "(<%s*li%s*%s*>)"," * ")
text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
-- <p>, <div>, <tr>, <ul> will be replaced to a double newline.
text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
-- Some petting with the <a> tags. :-P
--[[ local addresses = {}
local c = 0
for url,name in string.gfind (text, "<%s*a%s*href=[\'\"](%S-)[\'\"][^>]*>(.+)<%s*%/a%s*>") do
c = c + 1
string.gsub (name, "<%s*a%s*href=[^>]+>(.+)<%s*%/a[^>]*>",
function (nm)
nm = string.gsub (nm, "(%b<>)","")
nm = nm.."["..c.."]"
return nm
end)
table.insert (addresses, {url, name})
print(url, nm)
end ]]
-- Nuke all other tags now.
text = string.gsub (text, "(%b<>)","")
-- Replace entities to their correspondant stuff where applicable.
-- C# is owned badly here by using a table. :-P
-- A metatable secures entities, so you can add them natively as keys.
-- Enclosing brackets also get added automatically (capture!)
local entities = {}
setmetatable (entities,
{
__newindex = function (tbl, key, value)
key = string.gsub (key, "(%#)" , "%%#")
key = string.gsub (key, "(%&)" , "%%&")
key = string.gsub (key, "(%;)" , "%%;")
key = string.gsub (key, "(.+)" , "("..key..")")
rawset (tbl, key, value)
end
})
entities =
{
[" "] = " ",
["•"] = " * ",
["‹"] = "<",
["›"] = ">",
["™"] = "(tm)",
["⁄"] = "/",
["<"] = "<",
[">"] = ">",
["©"] = "(c)",
["®"] = "(r)",
-- Then kill all others.
-- You can customize this table if you would like to,
-- I just got bored of copypasting. :-)
-- http://hotwired.lycos.com/webmonkey/reference/special_characters/
["%&.+%;"] = "",
}
for entity, repl in pairs (entities) do
text = string.gsub (text, entity, repl)
end
-- text = text..nl..nl..("-"):rep(27)..nl..nl
--
-- for k,v in ipairs (addresses) do
-- text = text.."["..k.."] "..v[1]..nl
-- end
return text
end
--[[
Copyright (c) 2007, bastya_elvtars
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the author nor the names of contributors may be used
to endorse or promote products derived from this code without specific
prior written permission.
THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
Tanx bastya this script has no error but i type in main chat +s it cant showing any html servers
Quote from: swagat_j on 16 July, 2007, 16:54:42
Tanx bastya this script has no error but i type in main chat +s it cant showing any html servers
Ain't there any error messages? Could you please post the file contents (HTML) as code?
Works for me.
List of servers on our Lan-X Only at AnnA's Hub enjoy...go...pro...go..
# Name Address Players State Game Launch!
1 !!.Re|0@D3D.!! - CS - 1.6 172.16.16.212:27015 3/23 running Half-Life/TFC GO
Generated by AnnA on July 16, 2007 exactly at 20:21:20
tnx its work for me too problem of path slash i took \(front slash) instead of / (back slash) thatz it.thz for ur co operation
ur forums roxs :)
hi guys .. m totally new to this .. can ne 1 tell me how do i make tht html file for LAN servers ??
thnx... !
Quote from: achiever on 20 June, 2007, 08:45:33
i have software (aGsm) which gets me the information of our local game servers and save the information as html files.
Sir
I think there is small problem but this time it is not in the script but in the software aGSM suggested by achiever
the problem is tht the when the servers are search through the software it creates different folder everytime in a specified format the name of the folder is like this 2007_12_01_22_09 (year_month_date_hour_min) everytime in this format only
So can the script be change to suit the software
Can't it be configured properly? Otherwise the script cannot guess the exact date of the query (ie. it cannot guess where to search, only by dirty tricks.)
i tried all possible things but the output is in different folder everytime.
Infact i asked achiever also but he also told me the same thing
I am also attaching the software u can personally try tht software
Uh, then I have to create a folder scanner that parses all folders and selects the latest one. This is not trivial, but can be done.
thank you
i think der is some more prob in the script
when i type the servers command for 4 to 5 times
then after the script didnt work
i had to restart the script again and again i had to
face the same prob and u please look forward to my request
<[HeavY]>
List of servers on our LAN List of servers on LAN
December 2, 2007 at 15:06:56
No. Name Address Players State Game Launch!
Generated by aGSM v2.35c on December 2, 2007 exactly at 15:06:56
<[HeavY]> Servers:-
*** Server command: +addserver testing
<[HeavY]> potter's Server added.Type +servers in main.
<potter> +addserver testing
*** Server command: +Servers
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
<potter> +Servers
*** Server command: +servers
<[HeavY]>
List of servers on our LAN List of servers on LAN
December 2, 2007 at 15:31:36
No. Name Address Players State Game Launch!
Generated by aGSM v2.35c on December 2, 2007 exactly at 15:31:36
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
*** Server command: +servers
<[HeavY]>
List of servers on our LAN List of servers on LAN
December 2, 2007 at 15:31:36
No. Name Address Players State Game Launch!
Generated by aGSM v2.35c on December 2, 2007 exactly at 15:31:36
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
*** Server command: +Servers
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
<potter> +Servers
*** Server command: +Servers
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
<potter> +Servers
*** Server command: +servers
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing
<potter> +servers
*** Server command: +servers
<[HeavY]>
List of servers on our LAN List of servers on LAN
December 2, 2007 at 15:32:44
No. Name Address Players State Game Launch!
Generated by aGSM v2.35c on December 2, 2007 exactly at 15:32:44
<[HeavY]> Servers:-
- [ 1 ] December 02 2007 15:31:28 [ potter's ] Server: testing