Simpel send hubrules in own language / or help.txt files
 

Simpel send hubrules in own language / or help.txt files

Started by -RICK-, 27 April, 2006, 01:32:00

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

-RICK-

-- RICK--
-- 2006
-- Lua 5.0
-- login multilanguage on request
-- Sends PM to new connected Users and they can choose what language they want
-- Make folder Loginmessages and put in there Language.txt (put languase's u have in it englich dutch ect)
-- Put in same folder all language.txt files
-- it also can be used for all your help files (for choosen profiles)

--[[
Example
-----------------------------------------------
Language.txt
put your languase's in here
dutch
english
------------------------------------------
english.txt
put your english text in here
-------------------------------------------
dutch.txt
putt your dutch text in here
-------------------------------------------
-- or set login to 0 and you can use it for
-- all your help files activated by pm to bot
]]--


sBotName = "testhelp"   -- botname
Login = 1               -- show login text

tsettings = {           --Who recieves massages at login or/and have acces to text files  1= recieve or/and have acces
["AllowedProfiles"] ={ 
[0] = 1,   -- Masters				
[1] = 1,   -- Operators	   			
[2] = 0,   -- Vips		      	
[3] = 0,   -- Regs	
[4] = 1,   -- Moderator
[5] = 1,   -- Netfounder		      			
[-1] = 1,  -- Users			     
}
}

function Main() 
	frmHub:RegBot(sBotName) 	
end 

function ToArrival(user, data)
	data=string.sub(data,1,string.len(data)-1)
	local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)")
        cmd = string.lower(cmd)
		showtext(user, cmd)		
		return 1
	end

NewUserConnected = function(user)
    if tsettings["AllowedProfiles"][user.iProfile] == 1 and Login == 1 then
        cmd = "Language"
        showtext(user, cmd)
    end
end
OpConnected=NewUserConnected

function showtext(user, cmd)
    if tsettings["AllowedProfiles"][user.iProfile] == 1 then
        local contents ="\r\n\r\n"
        local bFile = io.open("Loginmessages/"..cmd..".txt") 
        if bFile then 
            for line in io.lines("Loginmessages/"..cmd..".txt") do
                line = ("\t"..line)
                contents = contents..line.."\r\n"
            end
            user:SendPM(sBotName,"\r\n"..contents.."\r\n|")
        end
    end
end
   

Markitos

Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Cheers

-RICK-

its a standard thing in my compiler its not needed but it doesnt harm :)

jiten

Quote from: Markitos on 27 April, 2006, 08:58:13
Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Not really. There's a difference between the usage of a single $ and a %$.

The first one is the opposite of ^, and should be used to define the exact ending of a string - this is what happens in the second string.find.

However, as you can see the latter - %$ - contains a escape for the magic character $, so it matches the $ itself.

Markitos

Quote from: jiten on 28 April, 2006, 18:44:22
Quote from: Markitos on 27 April, 2006, 08:58:13
Just a curiosity...is local s,e,cmd = string.find(data,"%$%b<>%s+(%S+)") the same of %b<>%s+(%S+)$???

Not really. There's a difference between the usage of a single $ and a %$.

The first one is the opposite of ^, and should be used to define the exact ending of a string - this is what happens in the second string.find.

However, as you can see the latter - %$ - contains a escape for the magic character $, so it matches the $ itself.
thnks

[HE]Newbie

-- A bit late i know

-- Is there no way to let the hub reconize wich land the user is from, like Verlihub can ( if i'm right ). Would be much easyer and think much users are irritating of the PM on logon
There will be 1 day, that i learn

nlgezel.hopto.org:411

Dessamator

Indeed it is, u can use the geoip script to find out where a user is from.
You can change this :
user:SendPM(sBotName,"\r\n"..contents.."\r\n|")
to this:
user:SendData(sBotName,"\r\n"..contents.."\r\n|")

to avoid those "irritating " PMs.
Ignorance is Bliss.

-RICK-


Dessamator

Ur welcome, btw im not sure why you 're using an endpipe in the sendpm, its not needed under normal conditions.
Ignorance is Bliss.

SMF spam blocked by CleanTalk