Author Topic: Need help with rightclick build in  (Read 2850 times)

0 Members and 1 Guest are viewing this topic.

Offline Syphrone-NL

  • Double Ace
  • *
  • Posts: 130
  • Karma: +2/-0
Need help with rightclick build in
« on: 23 April, 2006, 21:19:30 »
Got this script and i want a right click in it just trying everything but cant do it

Code: [Select]
-------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------
-- Command bot
-- Just sends the text in the text files in pm to the user who asked for it
-- Made by Donald_Duck
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------


sConf = {
sBot = frmHub:GetHubBotName(),
sFile1 = "active.txt",
sFile2 = "active-router.txt",
sFile3 = "hublist.txt",
sFile4 = "news.txt",
sFile5 = "reghelp.txt",
sFile6 = "windows2.txt",
sFile7 = "vip3.txt",
sFile8 = "private.txt",
sFile9 = "special.txt",
sFolder = "helping" -- folder where the file is stored
}

function Main()
frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
if cmd then
local tCmds = {
["active"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
end,

["active-router"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
end,

["hublist"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
end,

["news"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
end,

["reghelp"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
end,

["windows"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
end,

["vip"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
end,

["private"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile8))
end,

["special"] = function(user,data)
user:SendPM(sConf.sBot,ReadFile(sConf.sFile9))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user,data), 1
end
end
end


function ReadFile(file)
local fFile = io.open(sConf.sFolder.."/"..file)
if fFile then
local message = fFile:read("*all");
fFile:close();
return message;
else
return file.." not found!"
end
end

Can somebody build me in a rightclick
Its for all profiles they got all the same commands
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

PtokaX forum

Need help with rightclick build in
« on: 23 April, 2006, 21:19:30 »

Offline Thor

  • Scripter
  • Lord
  • ******
  • Posts: 290
  • Karma: +45/-5
    • Hungarian Direct Connect Site
Re: Need help with rightclick build in
« Reply #1 on: 23 April, 2006, 21:59:59 »
Code: [Select]
sMenu = "..::TEXT FILES::.."

function NewUserConnected(curUser)
curUser:SendData("$UserCommand 0 3 |")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to be active?$<%[mynick]> +active&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to be active wirh router?$<%[mynick]> +active-router&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\Hublists$<%[mynick]> +hublist&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\News$<%[mynick]> +news&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to register?$<%[mynick]> +reghelp&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\windows2$<%[mynick]> +windows2&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\vip3$<%[mynick]> +vip3&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\private$<%[mynick]> +private&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\special$<%[mynick]> +special&#124;|")
end

OpConnected=NewUserConnected
And copy text files to PtokaX\texts folder. It's easier.

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: Need help with rightclick build in
« Reply #2 on: 23 April, 2006, 22:57:28 »
Code: [Select]
sMenu = "..::TEXT FILES::.."

function NewUserConnected(curUser)
curUser:SendData("$UserCommand 0 3 |")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to be active?$<%[mynick]> +active&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to be active wirh router?$<%[mynick]> +active-router&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\Hublists$<%[mynick]> +hublist&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\News$<%[mynick]> +news&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\How to register?$<%[mynick]> +reghelp&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\windows2$<%[mynick]> +windows2&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\vip3$<%[mynick]> +vip3&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\private$<%[mynick]> +private&#124;|")
curUser:SendData("$UserCommand 1 3 "..sMenu.."\\special$<%[mynick]> +special&#124;|")
end

OpConnected=NewUserConnected
And copy text files to PtokaX\texts folder. It's easier.

Argh! The table method was more elegant! Please make another with that! :P
Everything could have been anything else and it would have just as much meaning.

Offline Syphrone-NL

  • Double Ace
  • *
  • Posts: 130
  • Karma: +2/-0
Re: Need help with rightclick build in
« Reply #3 on: 24 April, 2006, 08:20:58 »
Thx Hungarista

Almost had it myself only forgot a few little things like:

Code: [Select]
function NewUserConnected(curUser)
I had:
Code: [Select]
function NewUserConnected(user)

And forgot this one:
Code: [Select]
OpConnected=NewUserConnected
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

Offline BrotherBear

  • Triple Ace
  • **
  • Posts: 165
  • Karma: +20/-1
Re: Need help with rightclick build in
« Reply #4 on: 26 October, 2006, 00:34:38 »
This script is redundant to the inbuilt PtokaX Text reader, although the right click is not.

As bastya says the table is the way to go.
suggest you use bluebears pxutilities extension lib to populate that table,
with using os.execute and shell popups.

Example:

Code: [Select]
--[[

TextCommands 1.0 LUA 5.0/5.1

By American Idiot        04/23/06

Generates a list of text files in the specified folder
Sends context menus (right click) to all users.

**IMPORTANT NOTE: This script requires bluebear's Px extension
library, PxUtilities. It's available for both Lua 5.0.2 & Lua 5.1
This script will not work without it, and it's free.

Visit http://thewildplace.dk/ for this and many other great
extensions to the PtokaX hub software.

]]

TextCfg = {
--Command Menu Name
Menu = frmHub:GetHubName() or "User Commands",
--Command Submenu Name
SubMenu = "Text Reader",
--Botname
Bot = frmHub:GetHubBotName() or "Command_Bot",
--Register the bot? [show in user list]
RegBot = "yes",
--If registering, does bot have a key?
BotIsOp = 1,
--Bot description
BotDesc = "I send user commands",
--Bot Email address
BotMail = "user@domain.com",
--Path To Files
Dir = "C:\\PtokaX+\\texts",
--//-- Op's nick for status/error message
OpNick = "American Idiot",
--//-- Display status messages to OpNick?
Verbose = "on",
}

Main = function()
Texts = {}
if _VERSION == "Lua 5.1" then --Both paths reflect the root of Px per LUA version
libinit = package.loadlib("PxUtilities_l51.dll", "_libinit")
gc = "collect"
else
libinit = loadlib("../PxUtilities.dll", "_libinit")
gc = nil
end
libinit()
SetTimer(5 * 60000)
StartTimer()
DoList()
if TextCfg.RegBot == "yes" then
if TextCfg.Bot ~= frmHub:GetHubBotName() or
TextCfg.Bot == frmHub:GetHubBotName() and not frmHub:GetHubBot() then
frmHub:RegBot(TextCfg.Bot, TextCfg.BotIsOp, TextCfg.BotDesc, TextCfg.BotMail)
end
end
end

OnTimer = function()
DoList()
end

NewUserConnected = function(user)
local Prof = GetProfileName(user.iProfile) or "Unregistered User"
user:SendData(TextCfg.Bot, "Welcome "..user.sName..", "..Prof.."'s text commands "..
"enabled. Right click hub tab or user list for menu.")
DoCmds(user)
end
OpConnected = NewUserConnected

OnError = function(msg)
if TextCfg.Verbose == "on" then
SendToNick(TextCfg.OpNick,msg)
end
end

DoCmds = function(user)
local Menu,SubMenu = TextCfg.Menu,TextCfg.SubMenu
for i,v in ipairs(Texts) do
user:SendData("$UserCommand 1 3 "..Menu.."\\"..
SubMenu.."\\"..v.."$<%[mynick]> +"..v.."|")
end
  collectgarbage(gc)
end

DoList = function()
Texts = {}
local FileSize,FileCount = 0,0
local result = PXU.FindFirstFile(TextCfg.Dir.."\\*.*")
if result == 0 then
OnError(TextCfg.Dir.." = "..PXU.GetErrorString(PXU.GetLastError()))
return 1
else
while result ~= 0 do
result = PXU.FindNextFile()
if result ~= 0 then
local FileName = ""
FileName = FileInfo.cFileName() or FileInfo.cAltFileName()
if not FileInfo.IsDirectory() then
if string.find(FileName,"(%.txt)$") then
FileName = string.gsub(FileName,"(%.txt)$","")
table.insert(Texts,FileName)
end
end
end
end
PXU.CloseFind()
collectgarbage(gc)
end
end

[ Get the PxUtilities extension library ]

Hi American Idiot!

How could I change that instead of sending the text to main send it to the bot's PM?

I want to avoid spamming in main and if they want to show it in main they have
to copy from the bots PM and paste it in the main.

Hope you understand what I'm asking for :)

Thanks in advance!
Regards,

BrotherBear

Offline BrotherBear

  • Triple Ace
  • **
  • Posts: 165
  • Karma: +20/-1
Re: Need help with rightclick build in
« Reply #5 on: 26 October, 2006, 20:06:26 »
Ok, I changed the text that is Red.

ChatArrival = function(user, data)
   if TextCfg.Profiles[user.iProfile] and TextCfg.Profiles[user.iProfile] == 1 then
      local s,e,to = string.find(data,"^$To:%s(%S+)%s+From:")
      local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
      local s,e,usr = string.find( data, "%b<>%s%p%w+%s(%S+)|$")
      if cmd then
         for i,v in ipairs(Texts) do
            if cmd == v then
               local lines="\r\n\r\n"
               for line in io.lines(TextCfg.Dir.."\\"..v..".txt") do
                  lines = lines..line.."\r\n"
               end
               if usr then
                  local nick = GetItemByName(usr)
                  if nick  then
                     SendPmToNick(nick.sName, user.sName, lines)
                  else
                     local reply = "The user "..usr.." is not "..
                     "online, check your spelling."
                     if to and to == TextCfg.Bot then
                        user:SendPM(TextCfg.Bot,reply)
                     else
                        user:SendData(TextCfg.Bot,reply)
                     end
                  end
                  return 1
               else
                  user:SendPM(TextCfg.Bot, lines)
                  return 1
               end
            end
         end
      end
   end
end


First the Ascii to a User Responds with My nick instead of the Bots nick.
Second ALL Ascii goes to PM :)

Thanks for this Great script American Idiot.
« Last Edit: 26 October, 2006, 20:45:33 by BrotherBear »
Regards,

BrotherBear

PtokaX forum

Re: Need help with rightclick build in
« Reply #5 on: 26 October, 2006, 20:06:26 »