show chat history to new user who logs in
 

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

show chat history to new user who logs in

Started by jsjen, 16 January, 2004, 22:23:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jsjen

Hi I was looking for a script that shows some of the chat history when a person logs back into the hub, ive been looking through this site and cant seem to find anything . does it exist?

Intel

just enable webserver ..-.....-... inbuildt function
Punnakku

jsjen

will I have to open a port for this???

thanks

tezlo

#3
..
maxhistory = 40

function Main()
	chathistory = dofile("chathistory.dat") or {}
end

function NewUserConnected(user)
	local n = getn(chathistory)
	local str = ">> last "..n.." chat messages.."
	for i = 1, n do str = str.."\n"..chathistory[i] end
	user:SendData(str)
end

OpConnected = NewUserConnected

function DataArrival(user, data)
	if strsub(data, 1, 1) ~= "<" then return end
	tinsert(chathistory, date("[%H:%M] ")..strsub(data, 1, -2))
	if getn(chathistory) > maxhistory then tremove(chathistory, 1) end
	savehistory()
end

function savehistory()
	local f = openfile("chathistory.dat", "w+")
	assert(f, "chathistory.dat")
	write(f, "return {\n")
	for i = 1, getn(chathistory) do
		write(f, "\t"..format("%q", chathistory[i])..",\n")
	end write(f, "}") closefile(f)
end

jsjen

I guess, I want it so when someone logs in they know what has been hapening so i think the last 40 messages would be all they would need.

Im not sure of the script you just put up.

the second post says its already on there but it doesnt seem to work

tezlo

ok now it gets saved.. and loaded whenever you restart scripts

tezlo

yeah commands.. good point :)
but yours will ignore mesages with +!? anywhere in it, you only need to check the first character.. try replace DataArrival() with this one
function DataArrival(user, data)
	if strsub(data, 1, 1) ~= "<" then return end
	local s, e, pre = strfind(data, "^%b<> (.)")
	if pre == "!" or pre == "+" or pre == "?" then return end
	tinsert(chathistory, date("[%H:%M] ")..strsub(data, 1, -2))
	if getn(chathistory) > maxhistory then tremove(chathistory, 1) end
	savehistory()
end

also, if you want the PMs to popup you'll need to frmHub:RegBot(botname) in Main() or use an already registered botname

nErBoS

Hi,

If you want to the private popup come up you have to register the Bot.

Best regards, nErBoS
--## nErBoS Spot ##--

pHaTTy

standard settings on dc++ wont allow the pm to pop up in pm, because standard dont allow pop up pm's from offline users, if the bot is in the userlist, then it will work fine, it will also work with nmdc, but for dc++ uwill usually need the bot registered.....

function Main() 
        chathistory = dofile("chathistory.dat") or {}
        frmHub:RegBot(botname)
end
Resistance is futile!

jiten

i've tried the chat history, but the PM's don't pop up in a new window. they come like this in main:
[09:13] Private message from ?bot?: You have not reached the minimum share ammount of 1 GB.
what do i need to change in this code i got so that they come in pm?:

--code:---------------------------------------------------------------

--Chat History On Entry 1.01
--By Mutor The Ugly 4/14/04
--
--Based entirely on a script by Tezlo 1/17/04

-----------------------------------------------------------
--Changes
--
--Send chat history to PM on entry
--Omits chat with command prefixes.
-----------------------------------------------------------

maxhistory = 20 -- maximum lines of chat to cache
botname = "?bot?"

function Main()
frmHub:RegBot(botname)
chathistory = dofile("chathistory.dat") or {}
end

function NewUserConnected(user)
local n = getn(chathistory)
local str = "<----------------------------------------------------------------------[ Last ( "..n.." ) chat messages ]----------->\r\n"
for i = 1, n do str = str.."\r\n"..chathistory end
user:SendPM(botname,str.."\r\n")
user:SendPM(botname,"<--------------------------------------------------------------------------[ End of chat history ]--------------->")
end

OpConnected = NewUserConnected

function DataArrival(user, data)
   if strsub(data, 1, 1) ~= "<" then return end
   local s, e, pre = strfind(data, "^%b<> (.)")
   if pre == "!" or pre == "+" or pre == "?" then return end
   tinsert(chathistory, date("[%H:%M] ")..strsub(data, 1, -2))
   if getn(chathistory) > maxhistory then tremove(chathistory, 1) end
   savehistory()
end

function savehistory()
local f = openfile("chathistory.dat", "w+")
assert(f, "chathistory.dat")
write(f, "return {\n")
for i = 1, getn(chathistory) do
write(f, "\t"..format("%q", chathistory)..",\n")
end write(f, "}") closefile(f)
end
--end code:---------------------------------------------------------

nErBoS

Hi,

This bot already come up with pm, probably you forgot to restart script, try that.

Best regards, nErBoS
--## nErBoS Spot ##--

jiten

it doesn't work with me. well, i've updated the script with the one u posted. but, i still get the chat history in main, and not in a new window (PM):

[11:08:29] Private message from ?bot?: <----------------------------------------------------------------------[ Last ( 6 ) chat messages ]----------->

- [21:50] hum...
- [21:50] com o carlos abre
- [21:50] xii
- [21:50] afinal
- [21:50] mng
- [21:51] aki nao

[11:08:29] Private message from ?bot?: <--------------------------------------------------------------------------[ End of chat history ]--------------->
[11:08:29] // Type !help in main for your available commands!

pHaTTy

probby got pop up pms from bots in client disabled
Resistance is futile!

jsjen

just here to say this script works perfectly for me.

Is there a way to add like rules and stuff to the popup?
a txt fil ewould be good so I dont screw another script up

great work guys

jiten

isn't there any other way for the PM to popup in a new window, without enabling the pop up pms from bots in client, just by editing the script?

SMF spam blocked by CleanTalk