Get Topic?
 

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

Get Topic?

Started by Madman, 03 January, 2005, 13:44:16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

I'm using 0.3.3.0 build 15.25 [debug]
I want when i change topic it sends the topic to main also..
And if the topic is so long that the user can see the whole line, he can use some command to show the complete topic...

Note that i dont want a script to change topic.. i just want a script that tell and show the topic...

And is there somekind of frmhub:GetTheTopic?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

enema

got to do something with this
SendToAll("$HubName "..HubName.." - "..Topic)

Madman

Thanks =)
That Helpe.. Kind of slow now in the morning ;p
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

Everything could have been anything else and it would have just as much meaning.

TTB

#4
Hi,

I have modified a script what was here somewhere... I made an extra option: -topic will show the whole topic. It has one disadvantage... the text is only smallsized (how do you name that in English... :P) Ow, this is the script above... :)  and now modified... It should be the script u need...

-- [TopicBot] - v0.1
-- Written by bonki
-- Added -topic (VIEW) feat. by TTB
--
-- ABOUT:
--   Allows you to add a topic to your hub(name) (not shown in hublists!)
--
-- AVAILABLE COMMANDS:
--   -topichelp:        Guess.
--   -topic : 	Sets a new topic.
--   -topic: 		Shows current topic.
--   -rmtopic  :        Removes the current topic.
--
-- OTHER FEATURES:
--   You may want to edit 'sHubnamePattern' to suits your needs.
--   This will be the final string for hubname + topic.
--     [hubname] will be replaced with your hub's name.
--     [topic]   will be replaced with your hub's topic.
--
-- BUGS/LIMITATIONS:
--   If you change your hubname when a topic is set, you have to reset the topic
--   in order to change the displayed hubname to the new one.
--
-- CHANGELOG:
--   v0.1: General: Initial release
--

sName  = "[BOT]PLAY";
sVer   = "0.1";
sAbout = "Allows you to add a topic to your hub."

sHubnamePattern = "[hubname] [topic]]"

sTopicFile = "TopicBot.topic";
sTopic     = nil;
sHubname   = "";

sCrLf      = "\r\n";

-------------------------------------------------------------------------------

function Main()
  bot = { sBotName  = sName,
          sBotVer   = sVer,
          sBotTag   = "<++ V:"..sVer..",P:DVDhub>",
          sBotDescr = "",
          sBotEmail = "",
          sBotSpeed = "",
          iBotShare = 0 };

  LoadTopic();

  UpdateBotInfo();
  SendBotInfo();


  sHelpHeader   = "";
  sOpHelpOutput = sCrLf.."OP Commands:"..sCrLf..sCrLf;
  sHelpOutput   = sCrLf.."Commands:"..sCrLf..sCrLf;

  tCommands = {
                [ "-topichelp" ]      = { CmdShowHelp,    0, nil,       "Displays this help message." },
                [ "-topic" ] 	      = { CmdSetTopic,    0, "", "Sets the topic to ."  },
                [ "-rmtopic" ]        = { CmdRemoveTopic, 0, nil,       "Removes the current topic."  },
              };

  for sCmd, tCmd in tCommands do
    if(tCmd[2] == 1) then
      if (tCmd[3]) then
        sOpHelpOutput = sOpHelpOutput..sCmd.." "..tCmd[3].."\t\t"..tCmd[4]..sCrLf;
      else
        sOpHelpOutput = sOpHelpOutput..sCmd.."\t\t"..tCmd[4]..sCrLf;
      end
      hasOpCommands = 1;
    else
      if (tCmd[3]) then
        sHelpOutput   = sHelpOutput..sCmd.." "..tCmd[3].."\t"..tCmd[4]..sCrLf;
      else
        sHelpOutput   = sHelpOutput..sCmd.."\t\t"..tCmd[4]..sCrLf;
      end
    end
  end

  frmHub:RegBot(bot.sBotName);
end

-------------------------------------------------------------------------------

function CmdShowHelp(curUser)
  local sMsg = sHelpHeader;
  if (curUser.bOperator and hasOpCommands) then
    sMsg = sMsg..sOpHelpOutput;
  end
  sMsg = sMsg..sHelpOutput;
  curUser:SendData(bot.sBotName, sMsg);
end

-------------------------------------------------------------------------------

function CmdSetTopic(curUser, args)
  if (strlen(args) > 0) then
    SetTopic(args, 1);
   elseif (sTopic == nil) then
   curUser:SendData(bot.sBotName, "There is no topic atm!"); 
   else
    curUser:SendData(bot.sBotName, "Current topic: "..sTopic);
    --"Om de topic te veranderen moet je wel iets achter '-topic' zetten!");
  end
end

-------------------------------------------------------------------------------

function CmdRemoveTopic(curUser)
  if (sTopic) then
    sHubname = frmHub:GetHubName();
    sTopic   = nil;
    remove(sTopicFile);

    SendHubname();
    UpdateBotInfo();
    SendBotInfo();

    SendToAll(bot.sBotName, "Hub topic removed!");
  else
    curUser:SendData(bot.sBotName, "There's currently no topic set anyway!");
  end
end

-------------------------------------------------------------------------------

function DataArrival(curUser, sData)
  local _, _, cmd, args = strfind(sData, "%b<>%s+(%S+)%s*([^%|]*)%|$");

  if(cmd == nil) then
    return 0; end

  if (tCommands[cmd]) then
    curUser:SendData(sData);
    tCommands[cmd][1](curUser, strlower(args));
--    if (tCommands[cmd][2] == 0 or curUser.bOperator) then
--      tCommands[cmd][1](curUser, strlower(args));
--    else
--      curUser:SendData(bot.sBotName, "You do not have sufficient rights to run that command!");
--    end
    return 1;
  end

  return 0;
end

-------------------------------------------------------------------------------

function NewUserConnected(curUser)
  SendHubname();
  SendBotInfo(curUser);
end

-------------------------------------------------------------------------------

OpConnected = NewUserConnected;

-------------------------------------------------------------------------------

function SaveTopic(curTopic)
  flTopicFile = openfile(sTopicFile, "w");

  if (flTopicFile) then
    write(flTopicFile, curTopic);
    closefile(flTopicFile);
  end
end

-------------------------------------------------------------------------------

function LoadTopic()
  flTopicFile = openfile(sTopicFile, "r");

  if (flTopicFile) then
    sTopic = read(flTopicFile);
    closefile(flTopicFile);

    SetTopic(sTopic, 1);
  end
end

-------------------------------------------------------------------------------

function SetTopic(curTopic, bSave)
  curTopic         = gsub(curTopic,        "%s+",         " ");
  curTopic         = gsub(curTopic,        "%c+",         " ");

  sTopic = curTopic;

  local sHubString = gsub(sHubnamePattern, "%[topic%]",   sTopic);
  sHubString       = gsub(sHubString,      "%[hubname%]", frmHub:GetHubName());

  sHubname = sHubString;

  if (bSave) then
    SaveTopic(curTopic);
  end

  UpdateBotInfo();
  SendBotInfo();

  SendHubname();
  SendToAll(bot.sBotName, "Topic set to: "..curTopic);
end

-------------------------------------------------------------------------------

function SendHubname(curUser)
  if (curUser) then
    curUser:SendData("$HubName "..sHubname);
  else
    SendToAll("$HubName "..sHubname);
  end
end

-------------------------------------------------------------------------------

function SendBotInfo(curUser)
  if (curUser) then
    curUser:SendData(sBotInfo);
  else
    SendToAll(sBotInfo);
  end
end

-------------------------------------------------------------------------------

function UpdateBotInfo()
  local sBotDescr = "";
  if (sTopic) then
    sBotDescr = gsub(bot.sBotDescr, "%[topic%]", sTopic);
  else
    sBotDescr = gsub(bot.sBotDescr, "%[topic%]", "No topic set.");    
  end

  sBotInfo = "$MyINFO $ALL "..bot.sBotName.." "..sBotDescr..bot.sBotTag.."$ $"..bot.sBotSpeed..strchar(1).."$"..bot.sBotEmail.."$"..bot.iBotShare.."$";
end

-------------------------------------------------------------------------------


BYE

*EDIT* >> some text was Dutch, changed it to English
*EDIT2* >> I ment with smallsized text -> text without capitals
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

Madman

thanks for the help but...
i think you missed the line in my first post
QuoteNote that i dont want a script to change topic.. i just want a script that tell and show the topic...
=)
Anyway this is what i wanted....
--//Topic Change Notification Bot Made By Madman
--//Rewriten And Updated
--//Based On A Script From Phatty
--//Also Thanks To enema For The The Help


Bot = "TopicBot"
Topiced = {}

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
			curUser:SendData(Bot, "The topic is: " ..Topiced)
		end
		if curUser.iProfile == 0 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)
					Topiced = Topic
				end
			end
		end
	end
end
But i got a problem with it..
After Script/Hub restart the table is emptyed....
So when i try to read the topic i get this error msg

Syntax error: attempt to concat global `Topiced' (a table value)
stack traceback:
   1:  function `DataArrival' at line 15 [file `...ram\Hub\PtokaX-0.330 madhouse\scripts\Topic.lua']

So eiter i need to save the topic somewhere/somehow
or i need it to display a error that the topic couldnt be found... In dc that is...
but i dont manage to to either of them...
So if anyone could do it for me i would be happy =)
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

Modify to your needs:

function savetopic()
	writeto("lawmaker/inifiles/topic.ini")
	if topic then
		write("topic=\""..topic.."\"")
	else
		write("topic=nil")
	end
	writeto()
end

the topic.ini has to be dofiled in start of script.
Everything could have been anything else and it would have just as much meaning.

TTB

Just asking...

the script I posted, is only without capitals... Is it simple to change that (I like CAPITALS!) :)  I don't know how to fix that...  ?(
TTB

(? ?.??.-> Admin @ Surfnet hubs <-.??.???)

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


Bot = "TopicBot"

dofile("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() end --Add When fixed save
		if curUser.iProfile == 0 then --Make bOperator?
		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)
					SaveTopic()
				end
			end
		end
	end
end

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

It dont work :/
I type this
!topic 123'
and see this
[01:11:22] *** Topic has been set to '123'.
[01:11:22] Madman changed the topic to: 123
But in the ini file i see
Topic=nil
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

Again, some code piece, grab what you need. I had this bug too.

function changetopic(user,data,env)
	if levtopic~=0 then
		if CheckUserLevel(user) >= levtopic then
			local _,_,tp = strfind(data,"%b<>%s+%S+%s+(.+)")
			if tp then
				if topic then
					topic=tp
					SendToAll(Bot, "Topic has been changed by "..user.sName.." to: "..topic)
					SendToAll("$HubName "..frmHub:GetHubName().." - "..topic)
				else
					topic=tp
					SendToAll(Bot, "New topic has been created by "..user.sName..": "..topic)
					SendToAll("$HubName "..frmHub:GetHubName().." - "..topic)
				end
			else
				SendToAll(Bot, "Topic has been deleted by "..user.sName)
				SendToAll("$HubName "..frmHub:GetHubName())
				topic=nil
			end
			savetopic()
		else
			user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
		end
	else
		user:SendData(parseenv(user,env,Bot).."That command is disabled.")
	end
end
Everything could have been anything else and it would have just as much meaning.

Madman

Okey, That Was easy solved....
Thanks =)
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

QuoteOriginally posted by madman
Okey, That Was easy solved....
Thanks =)

and where is the new script? or i missed something? ;)
Everything could have been anything else and it would have just as much meaning.

Madman

#12
Not at all ;)
Here it is
http://board.univ-angers.fr/thread.php?threadid=1924&boardid=12&sid=562e31968de5e0e632ff5562707c3f53
But wait until i edited the post... i allready writing an update ;)
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

oh ok :)

i have my own topic in lawmaker ;p

just wanted 2 see how you can implement my code

and maybe that bug comes into my mind... i cant get wtf it was LoL
Everything could have been anything else and it would have just as much meaning.

Madman

Well i found the bug...
SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
					SaveTopic()
SendToAll(Bot, curUser.sName.." changed the topic to: "..Topic)
					[b]Topic2Save = Topic --//"Convert" For SaveTopic()[/b]
					SaveTopic()
You have to do like that...
For some reason it cant save with Topic so it has to be "converted" to something else then Topic =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk