Hola guys!
Here the script i would really like to see working properly, one thing is dosn't work is a timer.
_____________________________________________
--- Periodical PMs to unregs ? requested by witch
--- by Herodes ? 13-8-2004
--- optimized a bit. by plop
botsName = "...::TripBot::..."--- Change this to whatever u want
TxtFile = "unregfile.txt"--- be sure to have a file corresponding to this one in the 'scripts'
thecmd = "!pmunregs"--- change this to whatever u want ...
secs = 1000
mins = 60*secs
timerinterval = 20*mins--- I hope this is clear enough ...
function Main()
tUnregUsers = {}--- don't touch this one ...
--frmHub:UnregBot(botsName)--- Unreg the Bot from the NickList, ( using the string defined by the ' botsName ' value )
frmHub:RegBot(botsName)--- and Register it again ... ( using the string defined by the ' botsName ' value, again )
SetTimer(timerinterval)
StartTimer()
end
function OnTimer()
local sText = ReadTextFile(TxtFile)
local iC = 0
for index, nick in tUnregUsers do
SendPmToNick(nick, botsName, sText.."|")
iC = iC +1
end
return iC
end
function NewUserConnected(user)
if user.iProfile == -1 then
tUnregUsers[user.sName] = 1
end
end
function UserDisconnected(user)
if user.iProfile == -1 then
tUnregUsers[user.sName] = nil
end
end
function DataArrival(user, data)
if ( ( strsub(data, 1, 1) == "<" ) and user.bOperator )then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
if ( cmd == thecmd ) then
local iC = OnTimer()
if iC >= 25 then
user:SendPM(botsName, iC.." users have been notified.|")
else
user:SendPM(botsName, "The following users have been notified : |")
for a,b in tUnregUsers do
user:SendPM(botsName, "\t"..a.."|")
end
end
end
end
end
function ReadTextFile(file)
local message = "\r\n"
readfrom(file, "r")
while 1 do
local line = read()
if ( line == nil ) then break
else message = message.."\t"..line.."\r\n"
end
end
readfrom()
return message
end
_____________________________________________
If any1 would fix that i will be very happy.....thx in advince :)
Try using this script by Optimus. Really working (Tested and using it). You can use or change the command ( !unregpm ) from the line 35.
-- Made by Optimus
-- 08/12/03
sBot = "PM2unREGs" --BOT NAME
unRegUsers = {}
unRegUserFile = "unRegUsers.txt" -- A file to record unREGs in the hub dynamically
function Main()
frmHub:RegBot(sBot)
doloadTable(unRegUserFile)
if frmHub:GetUsersCount() == 0 then unRegUsers = {}
dosaveTable(user,data)
end
end
function NewUserConnected(user)
if user.iProfile == -1 then
doLog_unRegUsers(user, data)
end
end
function UserDisconnected(user)
if unRegUsers[user.sName] then
unRegUsers[user.sName] = nil
dosaveTable(user,data)
end
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 user.bOperator then
if (cmd == "!unregpm") then
s,e,cmd,message = strfind(data,"%b<>%s+(%S+)%s+(.+)")
if message then
tosend = ""
if (strlen ( message)*2/3+2) < 76 then
border = strrep ("-", strlen (message)*2/3+2)
else
border = strrep ("-", 75)
end
tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
if unRegUsers then
for name,_ in unRegUsers do
SendPmToNick(name,sBot, tosend)
end
end
else
user:SendData(sBot, "*** Please Enter a Message!")
end
end
end
end
end
function doLog_unRegUsers(user, data)
if unRegUsers[user.sName] == nil then
unRegUsers[user.sName] = 1
dosaveTable(user,data)
end
end
function doloadTable(unRegUserFile)
assert(readfrom(unRegUserFile))
dostring(read("*all"))
readfrom()
end
function dosaveTable(user,data)
writeto(unRegUserFile)
write("unRegUsers = {")
for a,b in unRegUsers do
if b then
write(format("[%q]=",a)..b..",")
end
end
write("}" )
writeto()
end
Edit: Sorry dude, didn't see that yours was periodical. But if you can't find a working one as you've requested, use this..
QuoteOriginally posted by Requiem
Try using this script by Optimus. Really working (Tested and using it). You can use or change the command ( !unregpm ) from the line 35.
-- Made by Optimus
-- 08/12/03
sBot = "PM2unREGs" --BOT NAME
unRegUsers = {}
unRegUserFile = "unRegUsers.txt" -- A file to record unREGs in the hub dynamically
function Main()
frmHub:RegBot(sBot)
doloadTable(unRegUserFile)
if frmHub:GetUsersCount() == 0 then unRegUsers = {}
dosaveTable(user,data)
end
end
function NewUserConnected(user)
if user.iProfile == -1 then
doLog_unRegUsers(user, data)
end
end
function UserDisconnected(user)
if unRegUsers[user.sName] then
unRegUsers[user.sName] = nil
dosaveTable(user,data)
end
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 user.bOperator then
if (cmd == "!unregpm") then
s,e,cmd,message = strfind(data,"%b<>%s+(%S+)%s+(.+)")
if message then
tosend = ""
if (strlen ( message)*2/3+2) < 76 then
border = strrep ("-", strlen (message)*2/3+2)
else
border = strrep ("-", 75)
end
tosend = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
if unRegUsers then
for name,_ in unRegUsers do
SendPmToNick(name,sBot, tosend)
end
end
else
user:SendData(sBot, "*** Please Enter a Message!")
end
end
end
end
end
function doLog_unRegUsers(user, data)
if unRegUsers[user.sName] == nil then
unRegUsers[user.sName] = 1
dosaveTable(user,data)
end
end
function doloadTable(unRegUserFile)
assert(readfrom(unRegUserFile))
dostring(read("*all"))
readfrom()
end
function dosaveTable(user,data)
writeto(unRegUserFile)
write("unRegUsers = {")
for a,b in unRegUsers do
if b then
write(format("[%q]=",a)..b..",")
end
end
write("}" )
writeto()
end
thx dude 4 script, but it dosn't have TIMER wichest main reason of my post...
here you go pm to unreg whit timer
--Script by Optimus
--Converted to LUA 5 by jiten
--massage on time in Main Chat, as well as PM
--
--
--User Settings-------------------------------------------------------------------------------------
--
--Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'.
sBot = "?Unreg?"
--Interval [in minutes] to PM unregistered users
sec=1000
min=60*sec
hour=60*min
--Message to send to unregistered Users
UnRegMsg = "You can't download if your not Registered type !regme ..... on the dots your password(make up your own password) (then close the hub and logon again ) or else you keep getting this annoying message till you registered!"
--
--End User Settings----------------------------------------------------------------------------------
UnRegTab = {}
UnReg = "UnReg.dat"
function Main()
SetTimer(1*min) -- Set timer here
StartTimer()
frmHub:RegBot(sBot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
LoadFromFile(UnReg)
end
function OnExit()
SaveToFile(UnReg , UnRegTab , "UnRegTab")
end
function NewUserConnected(user, data)
if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then
UnRegTab[user.sName] = 1
end
end
function UserDisconnected(user, data)
if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then
UnRegTab[user.sName] = nil
end
end
function OnTimer()
local usr,aux
for usr, aux in UnRegTab do
if (GetItemByName(usr) ~= nil) then
sNick = GetItemByName(usr)
sNick:SendPM(sBot, UnRegMsg)
sNick:SendData(sBot, UnRegMsg)
end
end
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
try this 1...
--- Periodical PMs to unregs ? requested by witch
--- by Herodes ? 13-8-2004
--- optimized a bit. by plop
--- rewriten by Herodes.. 4-4-2005
botsName = "...::TripBot::..."--- Change this to whatever u want
TxtFile = "unregfile.txt" --- be sure to have a file corresponding to this one in the 'scripts'
thecmd = "!pmunregs "--- change this to whatever u want ...
secs = 1000
mins = 60*secs
timerinterval = 20*mins--- I hope this is clear enough ...
function Main()
frmHub:RegBot(botsName)--- and Register it again ... ( using the string defined by the ' botsName ' value, again )
SetTimer(timerinterval)
StartTimer()
end
function OnTimer()
SendEm()
end
function ChatArrival( user, data)
if user.bOperator then
data = string.sub(data,1,-2)
local s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
if ( cmd == thecmd ) then
SendEm()
end
end
end
function SendEm()
local sText = ReadTextFile(TxtFile)
for i, user in frmHub:GetOnlineUsers() do
if user.iProfile == -1 then
user:SendPM(botsName, sText)
end
end
end
function ReadTextFile(file)
local f=io.open(file, "r");
if f then local m=f:read("*all");f:close;return m;end;
return "file isn't there";
end
You may wanna try this, which I am using in my own hub too..
--RegHound 1.0
--Requested by Sin
--Script by Mutor The Ugly 7/10/14
-- converted to LUA 5 by jiten
--
--Prompts unregistered users to register on repaeating interval
--Hounds in Main Chat, as well as PM
--
--
--User Settings-------------------------------------------------------------------------------------
--
--Name for bot[You can use your main bot, if so no need to register this bot. See 'function main'.
sBot = "BotName"
--Interval [in minutes] to PM unregistered users
Mins = "30"
--Message to send to unregistered Users
UnRegMsg = "Your message to unregged users goes here"
--
--End User Settings----------------------------------------------------------------------------------
UnRegTab = {}
UnReg = "UnReg.dat"
function Main()
SetTimer(Mins*60000)
StartTimer()
--frmHub:RegBot(sBot) --If using main bot, remark this line, add -- ie.. --frmHub:RegBot(sBot)
LoadFromFile(UnReg)
end
function OnExit()
SaveToFile(UnReg , UnRegTab , "UnRegTab")
end
function NewUserConnected(user, data)
if (user.iProfile == -1 and UnRegTab[user.sName] == nil) then
UnRegTab[user.sName] = 1
end
end
function UserDisconnected(user, data)
if (user.iProfile == -1 and UnRegTab[user.sName] ~= nil) then
UnRegTab[user.sName] = nil
end
end
function OnTimer()
local usr,aux
for usr, aux in UnRegTab do
if (GetItemByName(usr) ~= nil) then
sNick = GetItemByName(usr)
sNick:SendPM(sBot, UnRegMsg)
sNick:SendData(sBot, UnRegMsg)
end
end
end
function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");
sTab = sTab or "";
sTmp = ""
sTmp = sTmp..sTab..sTableName.." = {\n"
for key, value in tTable do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end
sTmp = sTmp..",\n"
end
sTmp = sTmp..sTab.."}"
return sTmp
end
function SaveToFile(file , table , tablename)
local handle = io.open(file,"w+")
handle:write(Serialize(table, tablename))
handle:flush()
handle:close()
end
function LoadFromFile(file)
local handle = io.open(file,"r")
if (handle ~= nil) then
dofile(file)
handle:flush()
handle:close()
end
end
The RegHound script by Mutor was a really good way of doing this. BUT this conversion made by jiten that Requiem has posted, is the bad way to do it, since the newest PtokaX versions have changes in hte API that make half of what that script tries to do, with a simple PtokaX function... so don't use it,.. it is a waste of cpu,mem&storage ... thats my personal opinion.
QuoteOriginally posted by Herodes
The RegHound script by Mutor was a really good way of doing this. BUT this conversion made by jiten that Requiem has posted, is the bad way to do it, since the newest PtokaX versions have changes in hte API that make half of what that script tries to do, with a simple PtokaX function... so don't use it,.. it is a waste of cpu,mem&storage ... thats my personal opinion.
Yups, Herodes is right. When I did this conversion, I did not look for the changes in the API. If I had done it, it would be a shorter script requiring almost nothing of our computers.
Cheers
Thanks for that script Requiem. Ive been typing messages myself! This should really bug them to register:) Mind you cant understand why they don't and what they are doing in the hub if they are not registered as I block search, download and PM:)