ptokax 330 notificationon Topic change
 

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

ptokax 330 notificationon Topic change

Started by Madman, 05 May, 2004, 20:39:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

Yup, just as the Topic say.... i made a script that send a messeage in the Main Chat the Topic has been changed by

Why? Well beacuse i wanted the user to know that we changed the Topic :p

--//Made by Madman

Bot = "-=Destruction=-"

--// This function is fired at the serving start
function Main()
	frmHub:RegBot(Bot)
end

--// This function is fired when a new data arrives
function DataArrival(curUser,data)
	if strsub(data, 1, 1) == "<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if GetProfileName(curUser.iProfile) == "Operator" then
		if cmd == "!topic" then
		SendToAll(Bot, "The Topic has been changed by "..curUser.sName.." ")
		end
else if GetProfileName(curUser.iProfile) == "Master" then
		if cmd == "!topic" then
		SendToAll(Bot, "The Topic has been changed by "..curUser.sName.." ")
		end
	end
end
end
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

imby

hi, how about upon !topic off , the topic has been cleared by

Typhoon

why not use  

if cmd == "!topic" and curUser.bOperator then

that saves you a command  :o)

keep it up ;o)



imby

#3
impressive, thanks.

Madman

--//Topic Change Notification Bot Made By Madman
--//Rewriten And Updated
--//Based On A Script From Phatty
--//Also Thanks To enema For The The Help
--//Thanks To bastya_elvtars For The Save Function
--//Skipped dofile, It Gives Error On Script Restart

Bot = "TopicBot"

function DataArrival(curUser, data)
	if (strsub(data,1,1) == "<") then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if cmd == "!showtopic" then ReadTopic(curUser) end
		if curUser.bOperator then
		local s,e,cmd,Topic = strfind(data,"%b<>%s+(%S+)%s+(.+)")
			if cmd == "!topic" then
				if Topic == "off" then
					SendToAll(Bot, curUser.sName.." deleted the topic")
				else
					SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
					Topic2Save = Topic
					SaveTopic()
				end
			end
		end
	end
end

function SaveTopic()
	writeto("Topic.ini")
	if Topic2Save then
		write("The Topic is: "..Topic2Save)
	else
		write("Could not find the Topic")
	end
	writeto()
end

function ReadTopic(curUser)
	readfrom("Topic.ini")
	local line = read("*a")
		curUser:SendData(Bot, line)
	readfrom()
end

It was a while since i made that script... but anyway..
I got some time over and i finnaly made an update...
Rember this is only for 330....
TD X dont have a !topic command
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

bastya_elvtars

function SaveTopic()
	writeto("Topic.ini")
	if Topic2Save then
		write("topic= "..Topic2Save)
	else
		write("topic=nil")
	end
	writeto()
end

this will save a lua file and can be safely dofiled. :)
Everything could have been anything else and it would have just as much meaning.

Madman

--//Topic Change Notification Bot Made By Madman
--//Rewriten And Updated
--//Based On A Script From Phatty
--//Also Thanks To enema For The The Help
--//Thanks To bastya_elvtars For The Save Function
--//Skipped dofile, It Gives Error On Script Restart
--//Added Custom File..

Bot = "TopicBot"
File = "Topic.ini"

function DataArrival(curUser, data)
	if (strsub(data,1,1) == "<") then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if cmd == "!showtopic" then ReadTopic(curUser) end
		if curUser.bOperator then
		local s,e,cmd,Topic = strfind(data,"%b<>%s+(%S+)%s+(.+)")
			if cmd == "!topic" then --//The Command PtokaX Uses
				if Topic == "off" then --//So It Wont Send Changed Teext When Turning It Of
					SendToAll(Bot, curUser.sName.." deleted the topic") --//Send If Cmd == !topic off
				else
					SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
					Topic2Save = Topic --//"Convert" For SaveTopic()
					SaveTopic()
				end
			end
		end
	end
end

function SaveTopic()
	writeto(File) --//Save The File
	if Topic2Save then
		write("The Topic is: "..Topic2Save) --//How To Save It 
	else
		write("Could not find the Topic") --//Couldnt Find Topic2Save
	end
	writeto()
end

function ReadTopic(curUser)
	readfrom(File) --//Read The file
	local line = read("*a") --//Read Whats In File
		curUser:SendData(Bot, line) --//Send It To User
	readfrom()
end

Update..

To Bastya
I know if i write "topic= "..Topic2Save it can be dofiled...
but when i use the !showtopic command
it will say something like
Topic="-=Topic=-"
witch i dont want it to say... it sholdnt say Topic=
Thats why i skipped the dofile...
beacuse if i saved it like i do now it gave me an error on script restart...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

bastya_elvtars

if you cal a dofile on it, no need 4 readtopic

basically my routine saves it as a lua file, which is executed by dofile().
Everything could have been anything else and it would have just as much meaning.

Madman

No need 4 ReadTopic?
But how then are the users suppose to view the topic?
They type !showtopic and they will see the Topic in main...
I dont really see how a dofile can do that?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

bastya_elvtars

my save saves topic as a lua-syntaxed file... dofile just executes it, its only needed when ya shut down the hub.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk