PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: fireball on 29 January, 2004, 20:41:35

Title: Perl Script to LUA Script
Post by: fireball on 29 January, 2004, 20:41:35
Hi, I run Open DC Hub for linux, and the other person in my network uses that ptokta hub which uses the lua scripting, well, i was searching everywhere for a lua programming guide, something that tells me all the commands, but with no luck... i kept getting here....

Well, this is the perl script... if anyone can help me out that would be great...

#!/usr/bin/perl -w
# For more information http://aatraders.port5.com/
# Purpose to display a unique login message for each person, administered by a
# forum modification!
# Change log Version - Name - YYYY MM DD
# 0.0.0.3a - A4 - 2003 09 21
#  - Now supports admin_op, ops as well as regs
# 0.0.0.2a - A4 - 2003 09 19
#  - Creating a local cache to increase speed, and decrease internet usage!
#  - Added possibility of On/Off switches
# 0.0.0.1a - A4 - 2003 09 17
#  - Actually connected it to the forums!
# 0.0.0.1 - A4 - 2003 09 ??
#  - Though about it, soved together a simple file!

use LWP::Simple;

$version = "0.0.0.3a";
$botname = "LoginBot";
$commandlinemode = "0";
%localcache = ();
$onoffswitch = 1; # 1 = on everything or else is off!
$localcacheonly = 0; # 1 = only use local cache copies
$noresetcache = 0; # 1 = disallows resetting of cache, should only be used when
      # you are low on bandwidth or you have the $localcacheonly on!
$forumaddy = "http://members.lycos.co.uk/aatraders/phpBB2/";
$forummod = "loginmsg.php?user=";


# Values:
# - 0 = Disabled
# - 1 = testing array and perl regular expressions
# - 2 = testing perl LWP::Simple

if ($commandlinemode eq "1")
{
  $_ = " hi, he, ho";
  @hhh = split(/\ /,$_);
  print $hhh[0];
}

if ($commandlinemode eq "2")
{
}

sub main()
{
  publicsay("$botname $version loaded!");
}

sub op_admin_connected
{
  my($user) = @_;
  if ($onoffswitch == 1)
  {
    say_login_message($user);
  }
}

sub op_connected
{
  my($user) = @_;
  if ($onoffswitch == 1)
  {
    say_login_message($user);
  }
}

sub reg_user_connected
{
  my($user) = @_;
  if ($onoffswitch == 1)
  {
    say_login_message($user);
  }
}

sub get_login_message
{
  my ($user) = @_;
  if (($localcache{$user} eq "") && ($localcacheonly == 0))
  {
    $_ = get($forumaddy.$forummod.$user);
    /\|/s;
    $localcache{$user} = $_;
  }
  return $localcache{$user};
}

sub say_login_message
{
  my ($user) = @_;
  publicsay(get_login_message($user));
}

sub data_arrival
{
  my ($user, $data) = @_;
  my (@command) = split(/\ /,$data);
  if ($#command < 0) {exit;};
  if ($command[0] =~ /^\  {
    if ($command[1] =~ /^-nani|-help|-nani\ loginbot$/i)
    {
      privatesay($user,"Please visit our forums (private message the nanibot".
   " with the word -forums for more details) to change your name!");
      privatesay($user,"-clearmycache ----- removes your cache from the ".
        "$botname you would use this if you changed your hub login message!");
    } elsif ($command[1] =~ /^\-clearmycache$/i)
    {
      if ($noresetcache == 0)
      {
        privatesay($user, "Clearing your cache!");
        $localcache{$user} = "";
      } else
      {
        privatesay($user, "Reseting of Local Cache is currently off!");
      }
    }
  } else { # we have command!
  }
}

sub publicsay
{
  my ($data) = @_;
  odch::data_to_all("<$botname> $data|");
}

sub privatesay
{
  my ($user, $data) = @_;
  odch::data_to_user($user, "<$botname> $data|");
}

well, like i said, any help with this would be great... thanks

you can also reach me on AIM (tylersreed) and MSN (tylersreed@msn.com)
Title:
Post by: VidFamne on 29 January, 2004, 21:23:22
>>HERE<< (http://www.lua.org/manual/4.0/) is the lua manual. Have fun. ;))
Title:
Post by: plop on 29 January, 2004, 22:34:06
and here (http://board.univ-angers.fr/thread.php?threadid=1064&boardid=6) you can follow a thread about how 2 make a bot like this.
just not by using a forum for changing but the bot itself.

plop