request - Page 2
 

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

request

Started by kbeh273300, 23 February, 2004, 01:48:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

nErBoS

Hummmm..

Show me your text file with the goodusers please.

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

kbeh273300

[dsl]-tony-   [DM]kbeh273300

[adsl]q8   [DM]kbeh273300

Pako   [DM]kbeh273300

Bladerunner   [DM]kbeh273300

bosboot   [DM]kbeh273300

[DM]?harlene   [DM]?rg??

[DM]bob1082   [DM]?harlene

BigFish   [DM]?harlene

[DM]Joostkeijzer   [DM]?harlene

[DM]Lazarus   [DM]?harlene

[DM]TheOtherOne   [DM]?harlene

testing   [DM]kbeh273300

[DM]S^yfa   [DM]?harlene

[DM]Lazarus   [DM]?harlene

[DM]tankman57   [DM]?harlene

[DM]IanJ    [DM]?harlene

[DM]IanJ                     [DM]?harlene
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

kbeh273300

i think i just found my mistake.i was trying to get it too look better when i use the show commnd si i went into the text file and made it like my last post but i see now that that wont work.is there a way of makeing it look neater like the way it is in my last post?the way it is now it looks like this

[18:43] <[DM]kbeh273300> !show
[18:43] [dsl]-tony-   [DM]kbeh273300[adsl]q8   [DM]kbeh273300Pako   [DM]kbeh273300Bladerunner   [DM]kbeh273300bosboot   [DM]kbeh273300[DM]?harlene   [DM]?rg??[DM]bob1082   [DM]?harleneBigFish   [DM]?harlene[DM]Joostkeijzer   [DM]?harlene[DM]Lazarus   [DM]?harlene[DM]TheOtherOne   [DM]?harlenetesting   [DM]kbeh273300[DM]S^yfa   [DM]?harlene[DM]Lazarus   [DM]?harlene[DM]tankman57   [DM]?harlene[DM]IanJ    [DM]?harlene[DM]IanJ                     [DM]?harlene

kinda messy can we make it wright neater like this?

<[DM]kbeh273300> !show
[dsl]-tony- [DM]kbeh273300

[adsl]q8 [DM]kbeh273300

Pako [DM]kbeh273300

Bladerunner [DM]kbeh273300

bosboot [DM]kbeh273300

[DM]?harlene [DM]?rg??

[DM]bob1082 [DM]?harlene

BigFish [DM]?harlene

[DM]Joostkeijzer [DM]?harlene

[DM]Lazarus [DM]?harlene

[DM]TheOtherOne [DM]?harlene

testing [DM]kbeh273300

[DM]S^yfa [DM]?harlene

[DM]Lazarus [DM]?harlene

[DM]tankman57 [DM]?harlene

[DM]IanJ [DM]?harlene

[DM]IanJ [DM]?harlene
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

kbeh273300

but also it still didnt remove the user (testing) witch is what is still not working i hope its not me did i mess something up?
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

kbeh273300

i just found out something the users with - infront of the nicks delete just fine but the users without the - wont delete

[18:56] <[DM]kbeh273300> !show
[18:56] [dsl]-tony-   [DM]kbeh273300
- [adsl]q8   [DM]kbeh273300
Pako   [DM]kbeh273300
Bladerunner   [DM]kbeh273300
bosboot   [DM]kbeh273300
- [DM]?harlene   [DM]?rg??
- [DM]bob1082   [DM]?harlene
BigFish   [DM]?harlene
- [DM]Joostkeijzer   [DM]?harlene
- [DM]Lazarus   [DM]?harlene
- [DM]TheOtherOne   [DM]?harlene
testing   [DM]kbeh273300
- [DM]S^yfa   [DM]?harlene
- [DM]Lazarus   [DM]?harlene
- [DM]tankman57   [DM]?harlene

im sorry for all these postes
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

nErBoS

#30
Hi,

I have tested and is working...

--Requested by kbeh273300
--Made by nErBoS

Bot = "FavUsers-Bot"

goodtext = "gooduser.txt" --It will be created in the script folder

function Main() 
frmHub:RegBot(Bot) 
end 

function DataArrival(user, data) 
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!add") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			AddGoodUser(user.sName, goodtext, gooduser)
			user:SendPM(Bot, "The user "..gooduser.." was been added to the list GoodUser.")
			return 1
			else
			user:SendPM(Bot, "Syntax error, !add . ")
			return 1
			end
			end
		elseif (cmd=="!show") then
			if (user.bOperator) then
			Readtextfile(user, goodtext)
			return 1
			end
		elseif (cmd=="!findgu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			if (GetItemByName(gooduser) == nil) then
			user:SendPM(Bot, "The user "..gooduser.." isn't online.")
			return 1
			else
			user:SendPM(Bot, "The user "..gooduser.." is online.")
			return 1
			end
			else
			user:SendPM(Bot, "Syntax error, !findgu . ")
			return 1
			end
			end
		elseif (cmd=="!regu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			RemoveGoodUser(gooduser, goodtext)
			user:SendPM(Bot, "Done..")
			return 1
			else
			user:SendPM(Bot, "Syntax error, !regu . ")
			return 1
			end
			end
		end
	end
end


function Readtextfile(user, file)
   	local filecontents = ""
	local handle = openfile(file, "r")
	if (handle ~= nil) then
		local line = read(handle)
		while line do
        	filecontents = filecontents..line.."\r\n"
		line = read(handle)
		end
		closefile(handle)
      	user:SendPM(Bot, filecontents)
	end
end

function Writetextfile(file, array)
	writeto(file)
	for x=1,getn(array) do write(array[x].."\r\n") end
	writeto()
end

function RemoveGoodUser(user, file)
local time = 0
local tmp = ""
local temp = {}
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil) then 
	break
      else
         local s, e, nick = strfind(line, "(%S+)%s+%S+")
         if (nick == user) then
         else
            tmp = tmp..line.."\r\n"
         end
      end
end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
end

function AddGoodUser(user, file, whoto)
local temp = {}
local tmp = ""
local time = 0
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil or line == "") then 
	tmp = tmp..whoto.."\t"..user
	break
      else
	tmp = tmp..line.."\r\n"
      end
   end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
end

Delete your old goodtext and let this one start all over.

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

Snooze

#31
Damn im learning tons from this - thanks nErBoS

One more question :D

What would the command line look like if you wanted to delete all lines in the file ? As in clear the txt file..


elseif (cmd=="!regu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			
			user:SendPM(Bot, "Done..")
			return 1
			else
			user:SendPM(Bot, "Syntax error, !regu . ")
			return 1
			end
			end

**snooze

nErBoS

#32
Hi,

Well just do this...

appendto(file) -- goes to the file wanted
write("") --- will write nothing in the file and everthing that was on him will disappeare
writeto() -- to write on the file

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

pHaTTy

well clearing the file, if u append it will leave the other text

Write: write as clean file
Append : Write leaving the other text

so as nerbox says but change appendto to writeto

or

openfile ( file, "w")

write("")

closefile(file)
Resistance is futile!

nErBoS

Sorry you are right :)

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

Snooze

Thanks goes to both :)

Your are doing a superb job at helping us newbies getting the hang at this :D

Please keep up the good work !


**Snooze

Snooze

I've used your read/write/delete functions to make a easily edited welcome msg.  But im missing one feature.

I need the script to check if there is anything in the file before adding a new entry.

Ex:

If (file) 'not empty' then
SendC(Bot, "Another entry exists. Delete this before adding a new")
return 1
end

I hope this explains what im looking for ;)


**Snooze

nErBoS

#37
Hi,

If you are checking if the file existes use this..

check = readfrom(file)

if (check == nil) then -- this checks if the file exists =nil the file doesn't exists

If you are trying to see if something is written in the file do this..

readfrom(file)
   while 1 do
      local line = read()
      if (line == nil) then --if a line is nil then he checks but coud be mistaken because you could have a text with a first line empty

                user:SendPM(Bot, "File is empty")
   break

      else
          user:SendPM(Bot, "File has text")
          break
         end
      end

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

kbeh273300

well iv never goten the !regu cmd to work iv started over with it 4 times and its always the same thing it say its deleteing the user but it never does.i use PtokaX DC Hub 0.3.3.0 build 15.25 [debug]
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

nErBoS

Hi,

My bad on always saying done, fixed that..

--Requested by kbeh273300
--Made by nErBoS

Bot = "FavUsers-Bot"

goodtext = "gooduser.txt" --It will be created in the script folder

function Main() 
frmHub:RegBot(Bot) 
end 

function DataArrival(user, data) 
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!add") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			AddGoodUser(user.sName, goodtext, gooduser)
			user:SendPM(Bot, "The user "..gooduser.." was been added to the list GoodUser.")
			return 1
			else
			user:SendPM(Bot, "Syntax error, !add . ")
			return 1
			end
			end
		elseif (cmd=="!show") then
			if (user.bOperator) then
			Readtextfile(user, goodtext)
			return 1
			end
		elseif (cmd=="!findgu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			if (GetItemByName(gooduser) == nil) then
			user:SendPM(Bot, "The user "..gooduser.." isn't online.")
			return 1
			else
			user:SendPM(Bot, "The user "..gooduser.." is online.")
			return 1
			end
			else
			user:SendPM(Bot, "Syntax error, !findgu . ")
			return 1
			end
			end
		elseif (cmd=="!regu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			if (RemoveGoodUser(gooduser, goodtext) == 0) then
			user:SendPM(Bot, "User not founded in the GoodUser list.")
			else
			user:SendPM(Bot, "Done..")
			end
			return 1
			else
			user:SendPM(Bot, "Syntax error, !regu . ")
			return 1
			end
			end
		end
	end
end


function Readtextfile(user, file)
   	local filecontents = ""
	local handle = openfile(file, "r")
	if (handle ~= nil) then
		local line = read(handle)
		while line do
        	filecontents = filecontents..line.."\r\n"
		line = read(handle)
		end
		closefile(handle)
      	user:SendPM(Bot, filecontents)
	end
end

function Writetextfile(file, array)
	writeto(file)
	for x=1,getn(array) do write(array[x].."\r\n") end
	writeto()
end

function RemoveGoodUser(user, file)
local time = 0
local tmp = ""
local temp = {}
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil) then 
	break
      else
         local s, e, nick = strfind(line, "(%S+)%s+%S+")
         if (nick == user) then
	 time = 1
         else
            tmp = tmp..line.."\r\n"
         end
      end
end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
return time
end

function AddGoodUser(user, file, whoto)
local temp = {}
local tmp = ""
local time = 0
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil or line == "") then 
	tmp = tmp..whoto.."\t"..user
	break
      else
	tmp = tmp..line.."\r\n"
      end
   end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
end

I have tried on the ptokax 0.3.3.0 and is working ok !!

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

Snooze

so if i change it to

while 2 do


it would check the 2nd line, right ?

**Snooze

nErBoS

Hi,

No..

While 1 do --- this number doen?t have nothing to do with the lines, is a condition to while work indefenely, on the code of while you should have a break condition with the break in your case is "if line ==nil then break", if not your while will not stop :)

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

kbeh273300

that did the trick nErBoS and i thank you very much for sticking with it.this forum and its scripters just keeps getting better :) your the man i cant thank you enough
-=United Kings network=-
Network Webpage?
Hub address: houseofkings.no-ip.org:420
hub webpage
hub forum

Snooze

I dound a new feature i would love to add.

When a new msg has meen added, could we have it send a PM to 3 "special" users ?

nErBoS

Hi,

Sorry didn?t understood your request :)
Can you be more clear.

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

Snooze

#45
Sorry...


When a new txt has been added to the txt file, is it possible to have the script send a PM to ex.: 3 special users ?

This is what i tried - it might explain what im after.

I add this:

sHubOwner = { "Snooze", "Owner2", "Owner3", "Owner4" }

Then added this in the script part that sends you a reply that the msg has been written to the txt file:

writeto()
user:SendPM(Bot, "Your Owner Message has been added: Topic: '"..topic.."' Message: '"..msg..".'")
sHubOwner:SendPM(Bot, "A new Owner msg has been added: Topic: '"..topic.."' Message: '"..msg..".'")
return 1

I hope that clears it up ;)


nErBoS

Hi,

This script doesn't save msg, only user and the operator who saved.

Or do you want to add to, when a user his added in the goodlist to send a pm to the special usres ??

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

Snooze

QuoteOr do you want to add to, when a user his added in the goodlist to send a pm to the special usres ??

Yes - I want to send a notification to a few special users  about the latest entry.

nErBoS

#48
Hi,

Made it also when a user is removed...

--Requested by kbeh273300
--Made by nErBoS

Bot = "FavUsers-Bot"

specialusrs = { "nErBoS", "Snooze" }

goodtext = "gooduser.txt" --It will be created in the script folder

function Main() 
frmHub:RegBot(Bot) 
end 

function DataArrival(user, data) 
	if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
	data=strsub(data,1,strlen(data)-1)
	s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="!add") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			AddGoodUser(user.sName, goodtext, gooduser)
			user:SendPM(Bot, "The user "..gooduser.." was been added to the list GoodUser.")
			for i=1, getn(specialusrs) do
			if (GetItemByName(specialusrs[i]) ~= nil) then
			local usr = GetItemByName(specialusrs[i])
			usr:SendPM(Bot, "The user "..gooduser.." has been added to the goodlist by "..user.sName)
			else
			end
			end
			return 1
			else
			user:SendPM(Bot, "Syntax error, !add . ")
			return 1
			end
			end
		elseif (cmd=="!show") then
			if (user.bOperator) then
			Readtextfile(user, goodtext)
			return 1
			end
		elseif (cmd=="!findgu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			if (GetItemByName(gooduser) == nil) then
			user:SendPM(Bot, "The user "..gooduser.." isn't online.")
			return 1
			else
			user:SendPM(Bot, "The user "..gooduser.." is online.")
			return 1
			end
			else
			user:SendPM(Bot, "Syntax error, !findgu . ")
			return 1
			end
			end
		elseif (cmd=="!regu") then
			if (user.bOperator) then
			s,e,cmd,gooduser = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
			if (gooduser ~= nil) then
			if (RemoveGoodUser(gooduser, goodtext) == 0) then
			user:SendPM(Bot, "User not founded in the GoodUser list.")
			else
			user:SendPM(Bot, "Done..")
			for i=1, getn(specialusrs) do
			if (GetItemByName(specialusrs[i]) ~= nil) then
			local usr = GetItemByName(specialusrs[i])
			usr:SendPM(Bot, "The user "..gooduser.." has been removed fromm the goodlist by "..user.sName)
			else
			end
			end
			end
			return 1
			else
			user:SendPM(Bot, "Syntax error, !regu . ")
			return 1
			end
			end
		end
	end
end


function Readtextfile(user, file)
   	local filecontents = ""
	local handle = openfile(file, "r")
	if (handle ~= nil) then
		local line = read(handle)
		while line do
        	filecontents = filecontents..line.."\r\n"
		line = read(handle)
		end
		closefile(handle)
      	user:SendPM(Bot, filecontents)
	end
end

function Writetextfile(file, array)
	writeto(file)
	for x=1,getn(array) do write(array[x].."\r\n") end
	writeto()
end

function RemoveGoodUser(user, file)
local time = 0
local tmp = ""
local temp = {}
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil) then 
	break
      else
         local s, e, nick = strfind(line, "(%S+)%s+%S+")
         if (nick == user) then
	 time = 1
         else
            tmp = tmp..line.."\r\n"
         end
      end
end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
return time
end

function AddGoodUser(user, file, whoto)
local temp = {}
local tmp = ""
local time = 0
readfrom(file)
   while 1 do
      local line = read()
      if (line == nil or line == "") then 
	tmp = tmp..whoto.."\t"..user
	break
      else
	tmp = tmp..line.."\r\n"
      end
   end
readfrom()
tinsert(temp, tmp)
Writetextfile(file, temp)
end

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

Snooze

Perfect nErBoS :))


Thats exactly what i was looking for :)


**Snooze

SMF spam blocked by CleanTalk