Author Topic: Notification Bot for various things... help..  (Read 4614 times)

0 Members and 1 Guest are viewing this topic.

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
Notification Bot for various things... help..
« on: 07 December, 2003, 14:11:18 »
Hey Guy's I need some help... :-)

I have tried doing my own notification in my bot but
can get it to work so I hopped you guys could help me...

This is the way I have tried:

TABLE = {}   to store op's names and when logging in "no"

opname = "no"  notification is off by default...

then I have the command !noti on/off with change above opname = "no" to "yes"...

Think that is a good start... but...

How do I do it so the ops that have yes only get OR get
the message... have tried many way but no luck or success...

have tried:



function ShowOnLineOps(data)
   for OP,NOT in OPLOG do
   local _,_,ToOP = strfind(OP, "(%S+)")
   if NOT == "on" then
      SendNotiTo = function(this,from,text)
      SendPmToNick(this,from,text)
            end
      SendToAll(BOTNAME,"Online: "..OP.."\t Notification: "..NOT)
   else
      SendToAll(BOTNAME,"Notification is OFF")
   end
   return data
end
end
 

in a function and returning OPS but don't work...

so help me out...

/NL
//NL

PtokaX forum

Notification Bot for various things... help..
« on: 07 December, 2003, 14:11:18 »

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #1 on: 08 December, 2003, 02:16:01 »
why don't you only store the op names in the table from the ops who have it enabled.
2 enable  OPLOG[user.sName]=1
2 disable  OPLOG[user.sName]=nil

for a,b in OPLOG do
   SendPmToNick(a, BOTNAME, what)
end

or am i missing what your trying 2 do???

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #2 on: 08 December, 2003, 02:19:42 »
why use all the crap, do what i do its simple, quick.

if notification is on for a op then it writes there name to a text file and then for notification reads the text file and gets each name by item and sends the notification for if the user is nil then it skips the line.....

l8rr,,

-phatty
Resistance is futile!

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
quick
« Reply #3 on: 08 December, 2003, 03:29:12 »
because all the table crap is way faster than reading from a textfile over and over crap
and SendToNick is also a lot faster than if getitembyname then crap

later

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #4 on: 08 December, 2003, 06:13:02 »
not depending on what you are using, tables and crap = memory/ reading = cpu, now if you consider it to be slow, ur comp must be a 486

we have processors approaching the speed of light and u say slow wow, must be a 486 :P

l8rr ;)
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #5 on: 08 December, 2003, 10:42:36 »
Quote
Originally posted by (uk-kingdom)pH?tt?
not depending on what you are using, tables and crap = memory/ reading = cpu, now if you consider it to be slow, ur comp must be a 486

we have processors approaching the speed of light and u say slow wow, must be a 486 :P

l8rr ;)
reading from hdd is measured in MB/s, while reading from memory is measured in GB/s.
now who's faster???
check my changelog when a.i. is released 2 see how much difference it makes 2 change a if/elseif/elseif/etc for a table.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #6 on: 08 December, 2003, 14:23:29 »
yes i know you are right, but a few k of data r3ading in mb is not much differ, its not important, if hdd;s read in kb or bytes then it wud be a differ sotry :P

for example,

1 meg a sec

1 gig a sec

which will be done first, neither both same for about 3k
Resistance is futile!

Offline tezlo

  • Triple Ace
  • **
  • Posts: 225
  • Karma: +1/-0
(No subject)
« Reply #7 on: 08 December, 2003, 14:26:13 »
btw.. i never said slow
but you said quick.. which it isnt
its HD torture

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #8 on: 08 December, 2003, 14:28:08 »
lol, he he he, ok i agree memory is better to use, but, still for if you newbie then it is easier to learn from doing that, Gekko does read from a file but only on script start, and then puts names into table, so yep reading is better from memory, but still a few k is nothink.....
Resistance is futile!

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #9 on: 08 December, 2003, 17:29:18 »
Okey guy get the point and man.. can you guys talk about everything... :-p like helping my life... hehe...

So how do I do this function then...

this is how a check is now:



   elseif (tonumber(tFlags["S"]) > MAXSLOTS) then
      curUser:sendmessage(BOTNAME, "You have  too many slots open, max number is: "..MAXSLOTS)
      SendPmToOps(LOGNAME,curUser.sName.." had to many slots, "..tFlags["S"].."/"..MAXSLOTS.." Slots")
      curUser:Disconnect()



I now I change the SendPmToOps to SendPmToNick but
how do I trigger the function ??

best way would be starting the function right in Data Arrival or...

and then type "a" or what ever for Ops name...

ex:



function DataArrival (curUser, data)
for OPS,NUM in OPLOG do
if(strsub(data, 1, 7) == "$MyINFO" and curUser.bOperator == nil) then
      if DCCHECK == "enable" then
         DoClientCheck(curUser,data,OPS) --// Can I do it like this then..??
      end
end
end


and then in DoClientCheck



function DoClientCheck(curUser,data,OPS)
SendPmToNick(OPS, BOTNAME, Message)
if (tonumber(tFlags["S"]) > MAXSLOTS) then
      curUser:sendmessage(BOTNAME, "You have  too many slots open, max number is: "..MAXSLOTS)
      SendPmToNick(OPS,BOTNAME,curUser.sName.." had to many slots, "..tFlags["S"].."/"..MAXSLOTS.." Slots")
      curUser:Disconnect()
end
end




will this work ???

/NL
//NL

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #10 on: 08 December, 2003, 19:17:06 »
hmm i dont understand what you man tirgger it, why?

either way it will need to be triggered to send the ops that have it enabled, else all wont get it,

so for example it cud be if Setting == 1 then send pm to ops sort of thing but thAt is if setting is on, but you want to send to the users in the table so a hint use for
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #11 on: 08 December, 2003, 19:33:25 »
your explaining is a bit fuzzy here, but this is what i understand from it.
Code: [Select]
function DoClientCheck(curUser,data,OPS)
   NotifOPs(Message) --- gues this line is debug or something, because Message looks nil 2 me.
   if (tonumber(tFlags["S"]) > MAXSLOTS) then
      curUser:sendmessage(BOTNAME, "You have too many slots open, max number is: "..MAXSLOTS)
      NotifOPs((curUser.sName.." had to many slots, "..tFlags["S"].."/"..MAXSLOTS.." Slots"))
      curUser:Disconnect()
   end
end


function NotifOPs(msg)
   for a,b in OPLOG do
      SendPmToNick(a, BOTNAME, msg)
   end
end  
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline NightLitch

  • Emperor
  • **
  • Posts: 1 455
  • Karma: +16/-0
(No subject)
« Reply #12 on: 08 December, 2003, 19:46:26 »
ThX alot plop... Works great...

Thank you all... :-)

/NL
//NL

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #13 on: 08 December, 2003, 22:58:13 »
Quote
Originally posted by NightLitch
ThX alot plop... Works great...

Thank you all... :-)

/NL
yw   enjoy

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #14 on: 10 December, 2003, 18:12:30 »
hmmm

Quote

function NotifOPs(msg)
   for a,b in OPLOG do
      SendPmToNick(a, BOTNAME, msg)
   end
end


Code: [Select]
function NotifOPs(msg)
   for a,b in OPLOG do
      SendPmToNick(b, BOTNAME, msg)
   end
end

?

?
Resistance is futile!

Offline plop

  • Forum God
  • ****
  • Posts: 2 464
  • Karma: +37/-0
(No subject)
« Reply #15 on: 10 December, 2003, 19:14:09 »
a is the key, b is the value.
in this case a holds the operator nick, while b is just a dummy vallue (anything beside nil can be used).
if you look up i'm using a vallue of 1.
for example   OPLOG = {"plop"=1, "phatty"=1}
in your case it would try 2 send the pm 2 user named 1.
the reason 2 use this kind of array's is that it's way easyer 2 add/remove things from them.
OPLOG[NightLitch]=1   adds NightLitch 2 the table and OPLOG[phatty]=nil removes you from it.
as you can see there is no need 2 go thru all the key's 2 see if a name is in the array.
Code: [Select]
if OPLOG[user.sName] then
   SendToAll(Bot, user.sName.." is in the array")
else
    SendToAll(Bot, user.sName.." is not in the array")
end
it uses a tiny bit more memory but as a result it works faster.
only 1 bad side effect, sorting those tables is a pain in the ass.
for a example about a way 2 sort them and how 2 handle those tables, take a look @ my usercleaner.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Offline pHaTTy

  • Forum Legend
  • ***
  • Posts: 1 916
  • Karma: +5/-1
(No subject)
« Reply #16 on: 10 December, 2003, 19:18:52 »
hmmm, well not how i do it, but suppose if it works then great :))
Resistance is futile!

PtokaX forum

(No subject)
« Reply #16 on: 10 December, 2003, 19:18:52 »