vicarious
 

News:

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

vicarious

Started by Thor, 24 June, 2006, 16:49:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Thor

This is an offline messanger script, but different from the existing scripts: if the script is enabled to the operator (just operators can use), the hub will register a bot in the hub with the op's name, and with the given prefix (optionally). If you don't use prefix on the hub, set the originalprefix and offprefix in the start of the script to "". So, the script register a bot on the hub, while the op is offline, and it recieves the private messages. When the op log in to the hub, script will inform him/her, if he/she has new messages, and he/she can read it with the !or command. After reading, the message(s) easily can delete with the !od command. The script contains an e-mail part (stripped from TTB-s Hub-backup script, thanks to him ;)) which will send an e-mail to the given e-mail adress when the maximum number of messages reached. The e-mail adress and the maximum number of messages can set up with commands, just check the help of the script (with !oh command,when script started, it will be send to the ops). And, optionally, you can set up an away message, that will send to the users, when they write to the "clone-op" bot. Because the e-mail sending part, scripts needs some external file (blat files), so please download the attachment, or download it from the script database: http://ptxscriptdb.psycho-chihuahua.net/download.php?view.260 If you get it, just unpack it to the scripts folder, start it and enjoy. This script works with LUA 5.02 and with LUA 5.1.1 also. If you have some problem, write here ;)

Markitos

#1
Hi m8!
Your script does not seem to work. It shows me 0 messages when i log on but i already wrote something in the "Clone-OP".
I got some requests,opinions and doubts:

local line = file:read()
	curUser:SendPM(bot,"\r\n"..border.."\r\n\t\t\tNEW MESSAGES WHILE YOU WERE OFFLINE: (TOTALLY: "..offlineops[curUser.sName]["settings"]["msgs"]..")\r\n"..border.."\r\n")
	while line do
		curUser:SendPM(bot,line)
		line = file:read()
	end


Why are you reading 2 times the file? Is it the correct form ???
function OpDisconnected(curUser)
	if offlineops[curUser.sName] ~= nil then
		if offlineops[curUser.sName] ~= nil then
  ;D
bot = frmHub:GetHubBotName()
offprefix = "[OP]"
originalprefix = "[OP]"

This could be in a table + that border locals could be in the "table" as globals assuming that you are using several times in the script.

local _,_,sPrefix,sComd,sParam = string.find(msg,"([%!%+%#%?%-])(%S+)%s*(.*)") Could be changed to %p

Commands in a table wouldn't be better too?Less mem usage   ::)

I saw too that the changes that a user make in his settings are only saved to the file on PX exit...Maybe you could use a serialize func. (i HATE file handling)

And to finish NICE IDEAS!!! BTW this are only requests, opinions and doubts  ;) :D


Thor

Ehh, you've right... Before i ended the script there was an other value in the table: on with value true or false bool. I removed it, because that was unnecessary, but on the code other parts i was careless, and i didn't remove all. I will correct it a.s.a.p., thanks the report. The serialize function is really unknown for me, and this version works well enough to me. So, you want to change the prefix while script running? That's possible, easy to do. And why i have to put the commands into a table? Why this not good? :o

Markitos

Quote from: Hungarista on 24 June, 2006, 18:27:57
Ehh, you've right... Before i ended the script there was an other value in the table: on with value true or false bool. I removed it, because that was unnecessary, but on the code other parts i was careless, and i didn't remove all. I will correct it a.s.a.p., thanks the report. The serialize function is really unknown for me, and this version works well enough to me. So, you want to change the prefix while script running? That's possible, easy to do. And why i have to put the commands into a table? Why this not good? :o
Commands in a table wouldn't be better too?Less mem usage Roll Eyes


Ill keep wating 4 your progress...

Thor

Less memory ??? I made all command to local vars, and not global... If i make a global table, it will use more memory ;D

Thor

By the way could you say me what this serialize function is doing? I looked for that, and it handle files also... Please say me more about this, and i will build in it to my script. Thanks

Markitos

Quote from: Hungarista on 25 June, 2006, 09:41:31
Less memory ??? I made all command to local vars, and not global... If i make a global table, it will use more memory ;D
You can make a local table inside the chatarrival func check this http://forum.ptokax.org/index.php?topic=5206#new
Quote from: Hungarista on 25 June, 2006, 10:37:03
By the way could you say me what this serialize function is doing? I looked for that, and it handle files also... Please say me more about this, and i will build in it to my script. Thanks
You could format format the user settings file in a more formal way like
tOffline = {
	[Nick Name] = {
		[email] = user.sEmail
		[description] = user.sDescription
		[awaymsg] = message
	}
}

instead of Estranho_para_ti?y@blabla.com?0?15?Ba Bye

Madman

Quote from: Markitos on 24 June, 2006, 18:18:22
Commands in a table wouldn't be better too?Less mem usage ? ::)

What he means is that he thinks you should do like this,

function ChatArrival(curUser, data)
	local data = string.sub(data, 1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)") -- Find commands
	if cmd then -- Found command
		cmd = string.lower(cmd)
		local tCmds = { -- Here is all commands
		["help"] = function(curUser, data)
			local Profile = GetProfileName(curUser.iProfile)
			if curUser.iProfile == -1 then Profile = "User" end
			local f = io.input("MadSecurity/Txt/Help" ..Profile.. ".txt")
			local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close()
			curUser:SendPM(tConfig.Bot.Name, line) return 1
		end,
		["rules"] = function(curUser, data)
			local f = io.input("MadSecurity/Txt/Rules.txt")
			local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close()
			curUser:SendPM(tConfig.Bot.Name, line) return 1
		end,
		}
		if tCmds[cmd] then -- If the command was in table
			return tCmds[cmd](curUser, data) -- Then execute it...
		end
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Markitos

Quote from: Madman on 25 June, 2006, 11:54:13
Quote from: Markitos on 24 June, 2006, 18:18:22
Commands in a table wouldn't be better too?Less mem usage   ::)

What he means is that he thinks you should do like this,

function ChatArrival(curUser, data)
	local data = string.sub(data, 1, -2)
	local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)") -- Find commands
	if cmd then -- Found command
		cmd = string.lower(cmd)
		local tCmds = { -- Here is all commands 
		["help"] = function(curUser, data)
			local Profile = GetProfileName(curUser.iProfile)
			if curUser.iProfile == -1 then Profile = "User" end
			local f = io.input("MadSecurity/Txt/Help" ..Profile.. ".txt")
			local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close()
			curUser:SendPM(tConfig.Bot.Name, line) return 1
		end,
		["rules"] = function(curUser, data)
			local f = io.input("MadSecurity/Txt/Rules.txt")
			local line = string.gsub(f:read("*all"), "\n", "\r\n")f:close()
			curUser:SendPM(tConfig.Bot.Name, line) return 1
		end,
		}
		if tCmds[cmd] then -- If the command was in table
			return tCmds[cmd](curUser, data) -- Then execute it...
		end

Indeed, but this local s,e,cmd = string.find(data, "%b<>%s+[%!%+](%S+)") could be changed to
local s,e,cmd = string.find(data, "%b<>%s*%p(%w+)") (Whatever there are many ways aight?)
return tCmds[cmd](curUser, data),1 returning 1 here would avoid many inside the table

jiten

Quote from: Markitos on 25 June, 2006, 11:50:02
You could format format the user settings file in a more formal way like
tOffline = {
	[Nick Name] = {
		[email] = user.sEmail
		[description] = user.sDescription
		[awaymsg] = message
	}
}

instead of Estranho_para_ti?y@blabla.com?0?15?Ba Bye

Hint:

If you expect a huge database, it's better to leave as it is (Hungarista's structure), so that it won't grow [file size] massively.
If not, you could use the Serialize or other custom function.

Thor

The working version is avaible now. I tried to modifiy as Markitos asked, but in ToArrival is impossible to find out, what was the users originally prefix... So now the bot will use the same nickname as the op has, and if you want to say to the users, that this is a bot, write it to the away message. This serialize function also strange for me yet, and this way works also, so i don't know why that way better.. I dont except big databases, maybe on ophubs, but this works as it has to. You can brave to call me lazy, but i dont want to complicate it. (the code is opened, feel free to modify, just don't forget my name ;D)

speedX

When a user enable's this script for himself and goes offline, he get's the messages. But when he comes online and the script is still enabled, and if some one PM's him thn he doesn't get those PM's.

Is it possible tht when tht user come's online, the script is auto-disabled only while he is online and again auto-enabed when he goes offline ??

(if possible plzz convert this to Lua 5.1)
Thanking You,

speedX

dougvcd

please please need some help with this prog
the prob i have is i enable the offline prog thengo off line
when i try to log back on it wont let me says nick is being used
please what do i have to do
very urgent
cheers
Doug uk
an old man trying to keep up with the youngsters

Thor

Yes, old versions never works more on newer PtokaX (0.3.5.2. and after), because:
Fixed: Few bugs related to reserved nicks (thx -RICK- for report).
New version is avaible, not tested, but it has to work :)
-> CLICK <-

dougvcd

a big thank you worked fine
cheers
Doug uk
an old man trying to keep up with the youngsters

Thor

Nice to hear, if you have problem with it, please post there.

SMF spam blocked by CleanTalk