Small API for bots

By Spoofing on Dec 03, 2010

About idea read here: http://www.hawkee.com/phpBB2/viewtopic.php?t=22139

Uncompleted, just for test. Now works only channels ID.

$hfind($+(conference,$cid),#).data - returns personal ID for every channel.

For what? You can use this for your scripts. For store any information and get him by ID.

on *:START: {
  if ($hget(server)) hfree $v1 | hmake server | hinc server id 0
  if ($hget(network)) hfree $v1 | hmake network | hinc network id 0
  if ($hget(channel)) hfree $v1 | hmake channel | hinc channel id 0
}
on *:EXIT: {  }
on *:CONNECT: {
  var %server = 0, %network = 0
  if ($hfind(server,$server).data) var %server = $v1
  else {
    var %server = $hget(server,id) + 1
    hinc -m server id
    hadd -m server %server $server
  }
  if ($network) {
    if ($hfind(network,$network).data) var %network = $v1
    else {
      var %network = $hget(network,id) + 1
      hinc -m network id
      hadd -m network %network $network
    }
  }
  else {
    if ($hfind(network,$server).data) var %network = $v1
    else {
      var %network = $hget(network,id) + 1
      hinc -m network id
      hadd -m network %network $server
    }
  }
}
on *:DISCONNECT: {
  if ($hget($+(conference,$cid))) hfree $v1
}
on *:JOIN:*: {
  var %# = 0
  if (# ischan) {
    if ($hfind($+(conference,$cid),#).data) var %# = $v1
    else {
      var %server = 0, %network = 0
      if ($hfind(server,$server).data) {
        var %server = $v1
        if ($hfind($+(server,%server),$+(network,*),0,w)) var %network = $hfind($+(server,%server),$+(network,*),$v1,w)
      }
      if ($hfind(network,$network).data) var %network = $v1
      elseif ($hfind(network,$server).data) var %network = $v1
      if (%network) {
        var %i = $hfind($+(network,%network),$+(channel,*),0,w)
        while (%i) {
          var %id = $mid($hfind($+(network,%network),$+(channel,*),%i,w),8), %i = %i - 1
          if ($hget(channel,%id) == #) var %# = %id
        }
        if (%# = 0) {
          var %# = $hget(channel,id) + 1
          hinc -m channel id
          hadd -m channel %# #
        }
        hadd -m $+(conference,$cid) %# #
      }
    }
  }
}

Comments

Sign in to comment.
Spoofing   -  Dec 03, 2010

and.. okay. I'm sorry, - my english is very bad because it not my native language, but I very good know mSL :) so, I will not write any more comments, description etc.
I'll just upload scripts/snippets.

 Respond  
Spoofing   -  Dec 03, 2010

Jethro_: I said about MOAR /while loop for load/save ALL hash tables from/to files in START/EXIT for every: network, server, channel, user. Also RAM usage if you load data, but network/server/channel/user no more using :)

Dark|: Uncompleted = this snippet under developing, in my todo list: make networks, servers and users personal IDs. Current working only channels.

 Respond  
Dark|   -  Dec 03, 2010

can i ask a stupid qustion

Uncompleted, just for test. Now works only channels ID.

$hfind($+(conference,$cid),#).data - returns personal ID for every channel.
what does that mean in english

 Respond  
Jethro   -  Dec 03, 2010

The -m switch from what I've learned will create a default 100 slots, which in turn, is already very sufficient. If you use /hmake

 Respond  
Spoofing   -  Dec 03, 2010

I dont like using START/EXIT events for load/save all data, because it (theoretically, if the data is very much) will be a high load.

load/hsave hash tables data must of necessity. For channels, example, after hadd -m $+(conference,$cid) %# # need check the saved data:

if ($lof($+(channels,/,channel,%#,/,data,.,txt))) {
  hload $+(channel,%#) $+(channels,/,channel,%#,/,data,.,txt)
}

and load if exists.. also saving.

but no need using common events for load/save ALL data. IMHO :)

 Respond  
Jethro   -  Dec 03, 2010

That exit event is probably for the /hsave routine...which looks like it's been missing.

 Respond  
_Teen_   -  Dec 03, 2010

another event for nothing, i know about ur perfectionism

on *:EXIT: {  }
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.