Simple Topic Bot
 

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

Simple Topic Bot

Started by kepp, 21 December, 2003, 09:08:34

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

kepp

I was bored so i made myself a little Topic bot for my bot :)

And now i took it out of there..
This one will show up in Public list aswell.
Enjoy...

--// Topic Bot
--// Made by Kepp

BotName = "T0pic"  --// What ever you want
HubOName = "Your_Hub_Name_Here"

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
--// Bye bye
    data=strsub(data,1,strlen(data)-1)
    local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
       if user.iProfile == 0 then
    
             if (cmd=="+topic") then
                local s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(.+)")
                local HubName = frmHub:GetHubName()
                local Topic = HubName.." - [Topic: "..arg.." ]"
                      frmHub:SetHubName(Topic)
                      SendToAll("$HubName "..Topic)
                      SendToAll(BotName, user.sName.." Changed the topic to: "..arg)


             elseif (cmd=="+removetopic") then
                      frmHub:SetHubName(HubOName)
                      SendToAll("$HubName "..HubOName)
                   end
             end
      end
end
Guarding    

kepp

Oups.... Don't take untill i can locate some copy 'n' paste missatkes :)
Guarding    

kepp

Nevermind, Anyway, before you set a new topic after another, don't forget to delete the first one.
else you will end up with multiple topics!!  :rolleyes:
Guarding    

IceCoder


BlazeXxX

Good one kepp :) there is another version of topicbot done by Skrolster i think ? which even updates the current topic to the public hub list and changes the hub description with the topic that is set?

So feel free to try both :) still a good script kepp  :D

kepp

Well, there's one by Bonki! Actually got the idea from this one

-- [TopicBot] - v0.1
-- Written by bonki
--
-- ABOUT:
--   Allows you to add a topic to your hub(name) (not shown in hublists!)
--
-- AVAILABLE COMMANDS:
--   !tb.help:             Guess.
--   !tb.settopic : Sets a new topic (OP).
--   !tb.rmtopic:          Removes the current topic (OP).
--
-- 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  = "TopicBot";
sVer   = "0.1";
sAbout = "Allows you to add a topic to your hub."

sHubnamePattern = "[hubname] [topic: [topic]]"

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

sCrLf      = "\r\n";

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

function Main()
  bot = { sBotName  = sName,
          sBotVer   = sVer,
          sBotTag   = "<++ V:"..sVer..",P:bonki>",
          sBotDescr = "Current topic: [topic]",
          sBotEmail = "bonki@no-spam.net",
          sBotSpeed = "Sol",
          iBotShare = 0 };

  LoadTopic();

  UpdateBotInfo();
  SendBotInfo();


  sHelpHeader   = sCrLf..sCrLf.."TopicBot v"..bot.sBotVer.." written by bonki 2003"..sCrLf..sAbout..sCrLf;
  sOpHelpOutput = sCrLf.."OP Commands:"..sCrLf..sCrLf;
  sHelpOutput   = sCrLf.."Commands:"..sCrLf..sCrLf;

  tCommands = {
                [ "!tb.help" ]     = { CmdShowHelp,    0, nil,       "\tDisplays this help message." },
                [ "!tb.settopic" ] = { CmdSetTopic,    1, "", "Sets the topic to ."  },
                [ "!tb.rmtopic" ]  = { CmdRemoveTopic, 1, 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);
  else
    curUser:SendData(bot.sBotName, "Syntax error, see help.");
  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);
    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

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

Only diference between this one and mine is that Bonki's will update The bot's description aswell, And yea, there's some help too!
But this one won't show up in public,
And therefore i took abit of another approach!

So, credits goes to Bonki as i got the idea from his script :)
Guarding    

pHaTTy

QuoteOriginally posted by kepp
I was bored so i made myself a little Topic bot for my bot :)

And now i took it out of there..
This one will show up in Public list aswell.
Enjoy...

--// Topic Bot
--// Made by Kepp

BotName = "T0pic"  --// What ever you want
HubOName = "Your_Hub_Name_Here"

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
--// Bye bye
    data=strsub(data,1,strlen(data)-1)
    local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
       if user.iProfile == 0 then
    
             if (cmd=="+topic") then
                local s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(.+)")
                local HubName = frmHub:GetHubName()
                local Topic = HubName.." - [Topic: "..arg.." ]"
                      frmHub:SetHubName(Topic)
                      SendToAll("$HubName "..Topic)
                      SendToAll(BotName, user.sName.." Changed the topic to: "..arg)


             elseif (cmd=="+removetopic") then
                      frmHub:SetHubName(HubOName)
                      SendToAll("$HubName "..HubOName)
                   end
             end
      end
end

actually this will update on pubby list ;)
Resistance is futile!

pHaTTy

but here you go ;)

--// Topic Bot
--// Made by Kepp
--// Update by Phatty

SetCommand = "+topic" --// anything u want
KillCommand = "+removetopic" --// anything u want

Bot = "Kepp" --// he he he ;)
HubName = "YouHubName"
Topic = ""

function DataArrival(user, data)
	if (strsub(data,1,1) == "<") then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")   

      		if user.iProfile == 0 then 
			if cmd == SetCommand then
				s,e,cmd,arg = strfind(data,"%b<>%s+(%S+)%s+(.+)")
				Topic = arg
				frmHub:SetHubName(HubName.." - "..Topic)
				SendToAll("$HubName "..HubName.." - "..Topic)
				SendToAll(Bot, user.sName.." Changed the topic to: "..arg)
			elseif cmd == KillCommand then
				frmHub:SetHubName(HubName)
				SendToAll("$HubName "..HubName)
			end
		end
	end
end

l8rr
Resistance is futile!

kepp

Guarding    

Pieltre

Hi,

I've tried the first bot posted by Keep and it works fine, except for a few details.   I wanted to get the OPs to change the topics too, so I change the
line        if user.iProfile == 0 then to        if user.iProfile == 1 then   The problem now is that I can't, as a master, change the topic... I tried a few ways to include to status, but failed.  Another thing I wanted to do was remove the "Topic: " in the topic line... removing that from the line local Topic = HubName.." - [Topic: "..arg.." ]"  just got the script not to work anymore...  
How can I get this to work


cheers,
pieltre

plop

by using this.
if user.iProfile <= 1 then
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk