PtokaX forum

Development Section => Your Developing Problems => Topic started by: Reefa on 01 July, 2004, 14:07:39

Title: PM shows in main, any help?
Post by: Reefa on 01 July, 2004, 14:07:39
Hi guys,

I'm still in the process of learning lua, but I hacked together a small script to open a text file, read the contents and post it in a pm.

The problem is it pm's you in main, I'm guessing it's due to the fact that it sends the request too quickly and doesn't have time to open a new pm window.

Anything I can do?

QuoteBot = "-=Info-Bot=-"

v1 = "Information"

file = "info.txt"

function Main()
--frmHub:RegBot(sBot)
end

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

if (cmd=="!goactive") then
ReadGoActive(user, data, cmd)
return 1
end
end
end

function ReadGoActive(user, data, cmd)
local release = ""
readfrom(file)
while 1 do
local line = read()
if (line == nil) then
break
else
release = release.."   "..line.."\r\n"
end
end
user:SendPM(Bot, "\r\n\r\n".." "..v1.." posted by Info-Bot ".."\r\n\r\n"..release)
readfrom()
end

Thanks :)

Reef
Title:
Post by: pHaTTy on 01 July, 2004, 14:11:07
general dc++ settings causes a problem soooo

function Main()
  frmHub:RegBot(Bot)
end

/pha
Title:
Post by: NightLitch on 01 July, 2004, 14:11:27
you must reg your bot or name it to another bot you have regged... otherwise it will send the PM in main... due to not be in userlist...

change:

function Main()
--frmHub:RegBot(sBot)
end

to

function Main()
frmHub:RegBot(Bot)
end

/NL
Title:
Post by: NightLitch on 01 July, 2004, 14:12:09
Damit Phatty I was first... lmao... hehe
Title:
Post by: Reefa on 01 July, 2004, 14:15:59
LOL!!! Thanks for the quick reply guys!

I didn't realise the bot *has* to be regged in order for the message to pop up from it, thought it would just pop up and display the bot name anyway :D

Ta ;)