description overwrite
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

description overwrite

Started by dragos_sto, 03 May, 2005, 18:58:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dragos_sto

need some help whit tis script
i try to overwrite description for users based on ip
the code i modify it bellow
     
-- welcomemesses script by AmsterdamBulldogs

login = {
	["BotName"] = frmHub:GetHubBotName().."_Login",
	["Hubowner"] = "dragos_sdcxp",
	["webadres"] = "http://10.48.8.252",
	["Forumadres"] = "Nu este momentan disponibila",
	["helpcommand"] = "Click dreapta"
}
local kb = "1024"
local mb = kb*kb
local gb = mb*kb
local tb = gb*kb

function NewUserConnected(user)
	Message(user)
end

function OpConnected(user)
	Message(user)
end

--// Profile Counter
function ProfileCounter(profile)
	local table, count = GetUsersByProfile(profile), 0
	for i, User in table do 
		if GetItemByName(User) then
			count = count + 1
		end
	end
	return count
end

--//Reg User Count
function OnlineRegUsers()
	local table, count = frmHub:GetOnlineUsers(), 0
	for i, User in table do
		if User.iProfile >=0 then
			count = count + 1
		end
	end
	return count
end
--//ip calculate 
function compip(ips)
	local _,_,a,b,c,d = string.find(ips, "(%d+).(%d+).(%d+).(%d+)")
	return ((a*16777216) + (b*65536) + (c*256) + d)
end

--GetOnlineUsers
function Message(user)
local timeanddate = os.date("%d-%m-%Y  %H:%M:%S")
local tmp = os.clock() 
local weeks, days, hours, minutes, seconds = math.floor(tmp/604800), math.floor(math.mod(tmp/86400, 7)), math.floor(math.mod(tmp/3600, 24)), math.floor(math.mod(tmp/60, 60)), math.floor(math.mod(tmp/1, 60))
	if frmHub:GetHubTopic() == nil then
		topic = "No topic set"
	else
		topic = frmHub:GetHubTopic()
	end
	if frmHub:GetHubName() ==nil then
		HubName = "No hub name"
	else
		HubName = frmHub:GetHubName()
	end
	if frmHub:GetHubAddress() ==nil then 
		HubAddress = "Hub owner not specify"
	else
		HubAddress = frmHub:GetHubAddress()
	end
	
	if user.sMyInfoString then
      local disp = ""
      doGetProfile =  GetProfileName(user.iProfile) or "Not registerd (request reg white +reqreg )"
      hubshare = string.format("%0.3f", frmHub:GetCurrentShareAmount()/(tb)).." TB"
      local s,e,name,desc,speed,email,share = string.find(user.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
--try to modify description
      local ipuser = compip(user.sIP)
      desc = "Dont work"
      if ipuser == (127*16777216 + 1) then desc = "Test"	
      	elseif ipuser > (10*16777216 + 48*65536 + 8*256 ) and ipuser < (10*16777216 + 48*65536 + 8*256 + 255) then desc = "DTNET ... ADY 0722144079"
      		elseif ipuser > (10*16777216 + 48*65536 + 9*256 ) and ipuser < (10*16777216 + 48*65536 + 9*256 + 255) then desc = "DTNET ... Bogdan 0744910529"
      			elseif ipuser == (10*16777216 + 48*65536 + 10*256 + 14) then desc = "Sebastian"	
			      	elseif ipuser > (10*16777216 + 48*65536 + 10*256 ) and ipuser < (10*16777216 + 48*65536 + 10*256 + 255) then desc = "DTNET ... ADY 0722144079"
				      	elseif ipuser > (10*16777216 + 48*65536 + 11*256 ) and ipuser < (10*16777216 + 48*65536 + 11*256 + 255) then desc = "DTNET ... Dragos 0723657274"
					      	elseif ipuser > (10*16777216 + 48*65536 + 12*256 ) and ipuser < (10*16777216 + 48*65536 + 15*256 + 255) then desc = "Sebastian"
      end
      SendToAll( "$MyINFO $ALL "..name.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
--dont work
      if share then
         minshare = string.format("%0.3f", tonumber(share)/gb).." GB"
      else
         minshare = "Corrupt"
      end
      border1 = "  <=========================Mesaj de Bun Venit: "..user.sName.."================================>"
      border2 = "  <================Sa Aveti ce Discuta si Downloada "..user.sName.."=========================>"
      disp = "\r\n\r\n"..border1.."\r\n"
      disp = disp.."	?Numele Hubului:			"..HubName.."\r\n" 
      disp = disp.."	?Descriere:			"..frmHub:GetHubDescr().."\r\n"
      disp = disp.."	?Data si ora pe hub:		"..timeanddate.."\r\n"
      disp = disp.."	?Topicul Hubului:			"..topic.."\r\n"
      disp = disp.."\r\n"
      disp = disp.."	?Ipul Tau:				"..user.sIP.."\r\n"
      disp = disp.."	?Marimea Sherului Tau:			"..minshare.."\r\n"
      disp = disp.."	?Cerinta Pentru Minim Sher:			"..frmHub:GetMinShare()/(1024*1024).." MB\r\n"
      disp = disp.."	?Profilul Tau pe hub:			"..doGetProfile.."\r\n"
      disp = disp.."	?Sherul Total pe Hub:		"..hubshare.."\r\n"
      disp = disp.."	?Propietar Hub:	        		"..login.Hubowner.."\r\n"
      disp = disp.."	?Adresa Habului:	        		"..HubAddress..":"..frmHub:GetHubPort().."\r\n"
      disp = disp.."	?Adresa Web a Habului:	        	"..login.webadres.."\r\n"
      disp = disp.."	?Adresa Forumului:	       		"..login.Forumadres.."\r\n"
      disp = disp.."	?Sunt Acum  			"..frmHub:GetUsersCount().." useri din "..frmHub:GetMaxUsers().. "\r\n"--"\r\n\t\t\t\t\t Dupa  "..weeks.." Saptamani "..days.." Zile "..hours.." Ore "..minutes.." Minute si "..seconds.." Secunde \r\n 
      disp = disp.."	?Dintrecare  : 		"..OnlineRegUsers().." useri Inregistrati sunt Online\r\n"
      disp = disp.."	?Comenzi Disponibile	                "..login.helpcommand.."\r\n"
      disp = disp.."	?This hub is Powered by:		? "..login.Hubowner.." - Made by _sdcxp_?\r\n"..border2.."\r\n"

	  user:SendData(login.BotName, disp)

	  disp = nil
   end
end

some one pls help or a hint

bastya_elvtars

Please post English then, or you ca post Hungarian for me as well. :P
Everything could have been anything else and it would have just as much meaning.

dragos_sto

#2
i thing ,what it write in romanian dont have  influence on sintax and not  affect the code

if you look on this forum it the robocop login
this it the script i modify whit few change


and sorry for my English

bastya_elvtars

QuoteOriginally posted by dragos_sto
i thing ,what it write in romanian dont have  influence on sintax and not  affect the code

if you look on this forum it the robocop login
this it the script i modify whit few change


and sorry for my English

OK, I see it now. Then, what is the problem? Do you want to convert this script, or you already did, just keeps crashing?

-- // offtopic

Use sztaki.hu if you speak Hungarian...
Everything could have been anything else and it would have just as much meaning.

dragos_sto

#4
sorry fot misunderstanding, what i want it some body to giveme one  suggestion,or what i did wrong

the script above dont overwrite users description

example if connect to server from same computer the description i  want to be seen from user to be "test"

bastya_elvtars

Then you have to resend user's myinfo at every MyINFOArrival, and with splitted myinfos, I am pretty unsure whether this will work correctly.
Everything could have been anything else and it would have just as much meaning.

dragos_sto

10x a lot i will try

dragos_sto

10x to bastya_elvtars for advice
i develop next code , but still dont work
         
function MyINFOArrival(User, Data)
	SendToAll(changedesc(User, Data))
	
end
function changedesc(user, data)
--get user info
	local s,e,name,desc,tag,speed,email,share = string.find(user.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)<([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
--change description	
	desc = "Test"
--rebuild Myinfo ALL
	desc = "$MyINFO $ALL "..name.." "..desc.."<"..tag.."$ $"..speed.."$"..email.."$"..share.."$"
	return desc
end


the  strange  thing will happen it when one master connect users se the new description ,
but for unreg user dont work

bastya_elvtars

Please remove the OpConnected and NewUserConnected part. Only do things on MyINFOArrival and also review the return value of changedesc, it contains typos.
Everything could have been anything else and it would have just as much meaning.

dragos_sto

#9
ok 10x to ppk and for explain and to bastya_elvtars
try to help me , but will not workind for the moment ,maybe in future will work .
ppk answer to my problem here

dragos_sto

-- BotName --
HubBot = frmHub:GetHubBotName()
--time after user connect to overwrite the description
TimeOverWrite = 60 -- time in second
-- range ip overwrite ="begin ip range-end ip range-description"
-- not teste whit space in description
RangeDesc = {[1]="10.39.2.1-10.39.7.255-Mitnet_Ghencea", [2]="10.39.1.1-10.39.1.255-Dtnet",
      [3]="172.16.0.1-172.16.255.255-Crimenet", [4]="10.48.10.14-10.48.10.14-Sebastian_Net",
      [5]="10.48.15.1-10.48.15.255-Sebastian_net",[6]="10.48.8.1-10.48.10.13-Mitnet_DrTaberei",
      [7]="10.48.10.15-10.48.11.255-Mitnet_DrTaberei"}
 
-- Info Path --
InfoLog = "UserInfo/" -- Create this folder before starting the script

function Main()
   SetTimer(TimeOverWrite*1000)
end
   
-- New User Connect Info Arrival
function MyINFOArrival(curUser,data)
if GetTimer() == nil then StartTimer() end
end

function OnTimer()
   OverWrite(HubBot)
   StopTimer()
end

function rebuilmyinfo(curUser)
   local descript,userip = nil,calcip(curUser.sIP)
   if userip ~= 0 then
         for index,descIP in RangeDesc do
            local _,_,startRange,endRange,RangeDescript = string.find(descIP, "(.*)-(.*)-(.*)")
            startRange = calcip(startRange)
            endRange = calcip(endRange)
            if userip>=startRange and userip<=endRange then
               descript = RangeDescript
            end
         end
      if descript == nil then descript = "Extern" end
      local _,_,nick,orgdescr,rest = string.find(curUser.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)<(.*)")
      SendToAll("$MyINFO $ALL "..nick.." "..descript.."<"..rest)
      end
end

function calcip(ipcalc)
   local _,_,a,b,c,d = string.find(ipcalc, "(%d+).(%d+).(%d+).(%d+)")
   local calc = 0
   if (tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d)) then
      calc = a*16777216 + b*65536 + c*256 + d   
      return calc
      else return 0
   end
end

function OverWrite(curUser)
   local tableover = frmHub:GetOnlineUsers()
   for i, Userover in tableover do
      rebuilmyinfo(Userover)
   end
end

wegface

#11
I would like a script that can do this but based on nick rather than i.p. Would anyone be able to change it for me please?
(edit) can be much simpler no need for profile check etc as all op hub.

dragos_sto

i made something , not tested
-- BotName -- 
HubBot = frmHub:GetHubBotName() 
--time after user connect to overwrite the description 
TimeOverWrite = 60 -- time in second 
-- not teste whit space in description 
RangeDesc = {[1]="Nick-New_Description",[2]="secondnick-Other_description"} 
InfoOver={}
-- Info Path -- 

function Main()
	SetTimer(TimeOverWrite*1000) 
end
	
-- New User Connect Info Arrival
function MyINFOArrival(curUser,data)
	InfoOver[curUser.sName] = 1
	if GetTimer() == nil then StartTimer() end
end

function OnTimer()
	OverWrite(HubBot)
	StopTimer()
end

function rebuilmyinfo(InfoUser,descript,Userover,wherto)
	local _,_,nick,orgdescr,rest = string.find(InfoUser.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)<(.*)")
	if wherto == 1 then 
		SendToAll("$MyINFO $ALL "..nick.." "..descript.."<"..rest)
	else 
		SendToNick(Userover.sName,"$MyINFO $ALL "..nick.." "..descript.."<"..rest)
	end
end



function OverWrite(curUser)
	local tableover = frmHub:GetOnlineUsers()
	for i, Userover in tableover do
		if InfoOver[Userover.sName] == 1 then 
			for index,descNick in RangeDesc do
				local _,_,Nickchange,Descript = string.find(descNick, "(.*)-(.*)")
				if Userover.sName == Nickchange then 
					rebuilmyinfo(Userover,Descript,HubBot,1)
				end
				for j, User2over in tableover do
					if User2over.sName == Nickchange then
						rebuilmyinfo(User2over,Descript,Userover,0)
					end						
				end
			end
		end
	InfoOver[Userover] = nil
	end
	tableover = nil
end

wegface

Working fine :))
Thanks alot.

dragos_sto


rotten

i like your ip based version of the script very much, altough i have a little additional request.

can you make it so that it adds the tag before the description instead of overwriting it alone?

SMF spam blocked by CleanTalk