Author Topic: Mass message unregged users  (Read 4646 times)

0 Members and 1 Guest are viewing this topic.

Offline Optimus

  • Emperor
  • **
  • Posts: 1 474
  • Karma: +13/-1
Mass message unregged users
« on: 30 March, 2005, 19:12:56 »
Code: [Select]
-- Message Unregged Users
-- Made by Optimus
-- 03/30/05

sBot = "BotName"

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

ChatArrival = function(user, data)
data=string.sub(data,1,string.len(data)-1)
s,e,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd == "!messunreg") then
if user.bOperator then
local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
if message then
local border = ""
if (string.len ( message)*2/3+2) < 76 then
border = string.rep ("-", string.len (message)*2/3+2)
else
border = string.rep ("-", 75)
end message = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
for id,who in frmHub:GetOnlineUsers() do
if who.iProfile == -1 then
who:SendPM(sBot, message)
end
end
else
user:SendData(sBot, "*** Usage: !messunreg ")
end
end
return 1
end
end


Mass message unregged users updated version.

- Optimus

PtokaX forum

Mass message unregged users
« on: 30 March, 2005, 19:12:56 »

Herodes

  • Guest
(No subject)
« Reply #1 on: 30 March, 2005, 21:41:46 »
nice trick for the border,.. its about 2/3rds ;)
I couldn't resist touching this one,... no offense..

Code: [Select]
-- Message Unregged Users
-- Made by Optimus
-- 03/30/05
---
-- I couldn't resist touching .. Herodes..

sBot = "BotName"

ChatArrival = function(user, data)
if user.bOperator then
data=string.sub(data,1,-2)
s,e,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd == "!messunreg") then
local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
if message then
local border = string.rep ("-", 75)
if (string.len (message)*2/3+2) < 76 then
border = string.rep ("-", string.len (message)*2/3+2)
end
message = "\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
for id,who in frmHub:GetOnlineUsers() do
if who.iProfile == -1 then
who:SendData( "$To: "..who.sName.." From: "..who.sName.." $<"..sBot.."> "..message )
end
end
else
user:SendData(sBot, "*** Usage: !messunreg ")
end
end
return 1
end
end

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 725
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #2 on: 30 March, 2005, 22:08:07 »
If i use this:

Code: [Select]
SendPmToAll(user.sName,"message came")
will the away messages be rebounded to me?

Or better use this:

Code: [Select]
for h=1,table.getn(userstbl) do; userstbl[h]:SendData("$To: "..userstbl[h].sName.." From: "..Bot.." $<"..user.sName.."> "..message ); end
, where user is me.

So?
Everything could have been anything else and it would have just as much meaning.

Offline Optimus

  • Emperor
  • **
  • Posts: 1 474
  • Karma: +13/-1
(No subject)
« Reply #3 on: 30 March, 2005, 23:28:48 »
Code: [Select]
-- Message Unregged Users
-- Made by Optimus
-- 03/30/05
--
-- I couldn't resist touching .. Herodes..
-- Touched it some more by Optimus cause it feels so good hehe

sBot = "BotName"

ChatArrival = function(user, data)
if user.bOperator then
data=string.sub(data,1,-2)
local s,e,cmd=string.find(data, "%b<>%s+(%S+)")
if (cmd == "!massunreg") then
local s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.*)")
if message then
local border = string.rep ("-", 75)
if (string.len (message)*2/3+2) < 76 then
border = string.rep ("-", string.len (message)*2/3+2)
end message = "*** Hub: "..(frmHub:GetHubName() or frmHub:GetHubAddress()).." - From: "..user.sName.."\r\n\r\n"..border.."\r\n"..message.."\r\n"..border.."\r\n"
for id,who in frmHub:GetOnlineUsers() do
if who.iProfile == -1 then
who:SendData( "$To: "..who.sName.." From: "..who.sName.." $<"..sBot.."> "..message)
end
end SendToOps(sBot, user.sName.." sended a mass message to all none regged users!")
else
user:SendData(sBot, "*** Usage: !massunreg ")
end
return 1
end
end
end
Yummy yummy

Offline Requiem

  • Forum Ace
  • *****
  • Posts: 95
  • Karma: +0/-0
(No subject)
« Reply #4 on: 30 March, 2005, 23:36:19 »
The script above eats too much resources (memory compared to the one I'll give below) I think.. Maybe you can try this one:
Code: [Select]
-- Made by Optimus
-- 08/12/03
-- converted to LUA 5 by jiten

sBot = "BotName"

unRegUsers = {}
unRegUserFile = "unRegUsers.txt"

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 ChatArrival(user, data)
data=string.sub(data,1,string.len(data)-1)
_,_,cmd=string.find(data, "%b<>%s+(%S+)")
if user.bOperator then
if (cmd == "!unregpm") then
s,e,cmd,message = string.find(data,"%b<>%s+(%S+)%s+(.+)")
if message then
tosend = ""
if (string.len ( message)*2/3+2) < 76 then
border = string.rep ("-", string.len (message)*2/3+2)
else
border = string.rep ("-", 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
return 1
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)
local handle = io.open(unRegUserFile,"r")
if (handle ~= nil) then
                dofile(unRegUserFile)
handle:flush()
handle:close()
        end
end

function dosaveTable(user,data)
local f = io.open(unRegUserFile, "w+")
assert(unRegUserFile)
f:write("unRegUsers = {")
         for a,b in unRegUsers do
                  if b == 1 then
         f:write(string.format("[%q]=",a)..b..",")
         end
        end
        f:write("}")
        f:flush()
        f:close()
end


Am I wrong ?

Offline [UK]Madman

  • Forum Ace
  • *****
  • Posts: 79
  • Karma: +1/-0
(No subject)
« Reply #5 on: 31 March, 2005, 00:41:31 »
If using lua new releases of ptokax (e.g. lua 5) wouldnt something like this be easier ?

Code: [Select]
local tUsers = {}
tUsers = frmHub:GetOnlineUsers()
for key,value in tUsers do
if not value.bRegistered then
tUnreg[value.sName] = 1
  end
end

Would save the need to save to a text file, tho use more resources when called in a hub with a lot of users.....

Herodes

  • Guest
(No subject)
« Reply #6 on: 31 March, 2005, 00:46:48 »
Requiem,.. I dont think that it eats up resources.. check it out ... the script done by Opti is taking advantage of what [UK]Madman pointed out .. ;)

Offline philoum

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Mass message unregged users
« Reply #7 on: 29 May, 2006, 05:25:22 »
Hello, i'm french
I put this last unreg mess but on connected unreg there no mess auto in pm for the unreg user ?
can you help me?

thank
respectfull

Offline Rincewind

  • Scripter
  • Lord
  • ******
  • Posts: 403
  • Karma: +60/-7
    • Rincewind's Scripts
Re: Mass message unregged users
« Reply #8 on: 29 May, 2006, 09:11:02 »
This script only sends a message when an operator types !massunreg in main followed by the message to send.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Mass message unregged users
« Reply #9 on: 29 May, 2006, 20:51:08 »
I noticed.. All codes posted in this is thread is lua 5... so maybe this topic fits better in the lua 5 section?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

Re: Mass message unregged users
« Reply #9 on: 29 May, 2006, 20:51:08 »