gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
76794 Posts in 13503 Topics by 1651 Members - Latest Member: Arnold99 December 08, 2024, 03:22:10 pm
*
gfx*gfx
gfx
WinMX World :: Forum  |  Third Party Stuff  |  Bots  |  metis script
gfx
gfxgfx
 

Author Topic: metis script  (Read 14699 times)

0 Members and 1 Guest are viewing this topic.

Offline mike777

  • Forum Member
  • I love WinMX!
metis script
« on: January 26, 2013, 04:39:00 pm »
hi  any chance of getting some help with a script for Metis 2.6\RoboMX. i would like to be able to add movies to a movie list , saved in .xml which currently follows this address :- D:\777\Metis 2.6\Add-Ons\New.xml

Offline reef

  • WMW Volunteer
  • *****
  • ***
Re: metis script
« Reply #1 on: January 27, 2013, 07:12:44 am »
Is there any particular reason why you want the file to save as xml? Saving it as .txt or .ini would be much easier and would accomplish what your looking to do (unless you have an idea for which xml is absolutely required).

You could check out this thread, the script sounds like what your looking for..

https://forum.winmxworld.com/index.php?topic=7290.0.html

I'm not sure if it will work with metis 2.6 which is actually quite an old version of metis. But you could give it a go and mess around with it or maybe change it up to accomplish what you need. :)

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #2 on: January 27, 2013, 11:25:53 am »
ty reef.   very close to what i'm after   but not quite  :(   i'll keep looking and trying    thx again

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #3 on: January 27, 2013, 11:30:19 am »
and   lol   i said .xml as all other files used are currently .xml. No idea if .txt works

Offline Pri

  • MX Hosts
  • *****
  • *****
Re: metis script
« Reply #4 on: January 31, 2013, 06:40:49 pm »
What you want is the ability to type !movie <moviename> then have it added to a list which other users inside the room can then type !movies to view the list. Is that correct?

If so you should store the list itself as a text file and then reference that text file. This is quite a simple script to make.

So to start with you would have something like this:

Code: [Select]
<command type="script">
<in>!movie %PARAM%</in>
<out>Movie %PARAM% Accepted!</out>

This will setup the script and accept the movie you want to add. I've also added a single output that merely tells you the name of the movie you added so you know it is working.
Then directly underneath that you would have this code:

Code: [Select]
<out type="push" extdata="movie01"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="movie02"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="movie03"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="movie04"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="movie05"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="movie06"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="6"/></out>
<out type="push" extdata="movie07"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="7"/></out>
<out type="push" extdata="movie08"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="8"/></out>
<out type="push" extdata="movie09"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="9"/></out>
<out type="push" extdata="movie10"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="10"/></out>

the above piece of code tells the bot to load in our previously saved movie listings. We want to load them in before we try to save anything so that your old list doesn't get over-written on your hard drive. In the above example I'm using C:\Movie.List.txt but you can modify this to anywhere on your hard drive.

Now here is the code to actually control the movie entries as they are being added to your listings

Code: [Select]
<out type="push" extdata="movie10">$movie09$</out>
<out type="push" extdata="movie09">$movie08$</out>
<out type="push" extdata="movie08">$movie07$</out>
<out type="push" extdata="movie07">$movie06$</out>
<out type="push" extdata="movie06">$movie05$</out>
<out type="push" extdata="movie05">$movie04$</out>
<out type="push" extdata="movie04">$movie03$</out>
<out type="push" extdata="movie03">$movie02$</out>
<out type="push" extdata="movie02">$movie01$</out>
<out type="push" extdata="movie01">%PARAM%</out>

This code will move your movie entries up by one in the list and add your new entry to the variable called movie01. When we read this list back the newest entry will be at the top.
Directly after this you want a way to save these entries to your hard drive so when your bot shuts off the list isn't lost. So after that piece of code add this piece of code

Code: [Select]

<out type="file" extdata="C:\Movie.List.txt" mode="t">$movie01$\n$movie02$\n$movie03$\n$movie04$\n$movie05$\n$movie06$\n$movie07$\n$movie08$\n$movie09$\n$movie10$</out>
</command>


This piece of code will save all the entries to the text file C:\Movie.List.txt - You can change this to a file anywhere on your computer. The \n between each entry is what is called a newline and on windows and other operating systems this is interperated as a line break. Basically each entry will be on its own line inside the text file. This means we can easily read it back.

You'll also notice at the bottom I added </command> that is simply because that part of the script (adding files) is done now. So this tells Metis that script is finished.

Now the command for users to actually view your list of movies:

Code: [Select]
<command type="script">
<in>!movies</in>
<out>List of our Movies!</out>

We use the same command structure but this time we don't need the %PARAM% because the user isn't supplying any parameters, they are just giving a command. I've also changed the output to merely say "List of our Movies!" again so that you know the bot is doing something even if your list of movies is blank.

Code: [Select]
<out type="push" extdata="movie01"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="movie02"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="movie03"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="movie04"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="movie05"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="movie06"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="6"/></out>
<out type="push" extdata="movie07"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="7"/></out>
<out type="push" extdata="movie08"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="8"/></out>
<out type="push" extdata="movie09"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="9"/></out>
<out type="push" extdata="movie10"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="10"/></out>

Same as last time we want to load in the movies to make sure the user actually sees something.

Code: [Select]
<out>$movie01$</out>
<out>$movie02$</out>
<out>$movie03$</out>
<out>$movie04$</out>
<out>$movie05$</out>
<out>$movie06$</out>
<out>$movie07$</out>
<out>$movie08$</out>
<out>$movie09$</out>
<out>$movie10$</out>
</command>

The above piece of code simply outputs the list of movies in to the room. If you wanted to make this private and you were using WCS or RSWCS you would add /hidecmd /privnotice %NAME% to the front of each line like this:

Code: [Select]
<out>/hidecmd /privnotice %RAWNAME% $movie01$</out>

And then only the user who used the !movies command would see the list of movies. You will also note I included another </command> as that is the final part of that code. Now some notes about this code, it is quite inefficient as each time one of the commands is being used it is loading in 10 lines of text from your hard disk instead of serving the entries from memory. To make it work more efficiently would have made the script more complicated and I wanted this to be as simple as possible so you could understand how it works and hopefully make stuff for yourself and others in the future and also to help anyone else that stumbles across this code example.

I will now supply the complete script in a code tag for easy copying and pasting:

Code: [Select]
<command type="script">
<in>!movie %PARAM%</in>
<out>Movie %PARAM% Accepted!</out>
<out type="push" extdata="movie01"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="movie02"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="movie03"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="movie04"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="movie05"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="movie06"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="6"/></out>
<out type="push" extdata="movie07"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="7"/></out>
<out type="push" extdata="movie08"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="8"/></out>
<out type="push" extdata="movie09"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="9"/></out>
<out type="push" extdata="movie10"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="10"/></out>
<out type="push" extdata="movie10">$movie09$</out>
<out type="push" extdata="movie09">$movie08$</out>
<out type="push" extdata="movie08">$movie07$</out>
<out type="push" extdata="movie07">$movie06$</out>
<out type="push" extdata="movie06">$movie05$</out>
<out type="push" extdata="movie05">$movie04$</out>
<out type="push" extdata="movie04">$movie03$</out>
<out type="push" extdata="movie03">$movie02$</out>
<out type="push" extdata="movie02">$movie01$</out>
<out type="push" extdata="movie01">%PARAM%</out>
<out type="file" extdata="C:\Movie.List.txt" mode="t">$movie01$\n$movie02$\n$movie03$\n$movie04$\n$movie05$\n$movie06$\n$movie07$\n$movie08$\n$movie09$\n$movie10$</out>
</command>

<command type="script">
<in>!movies</in>
<out>List of our Movies!</out>
<out type="push" extdata="movie01"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="1"/></out>
<out type="push" extdata="movie02"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="2"/></out>
<out type="push" extdata="movie03"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="3"/></out>
<out type="push" extdata="movie04"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="4"/></out>
<out type="push" extdata="movie05"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="5"/></out>
<out type="push" extdata="movie06"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="6"/></out>
<out type="push" extdata="movie07"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="7"/></out>
<out type="push" extdata="movie08"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="8"/></out>
<out type="push" extdata="movie09"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="9"/></out>
<out type="push" extdata="movie10"><operator type="readfile" nvalue="C:\Movie.List.txt" lvalue="l" rvalue="10"/></out>
<out>$movie01$</out>
<out>$movie02$</out>
<out>$movie03$</out>
<out>$movie04$</out>
<out>$movie05$</out>
<out>$movie06$</out>
<out>$movie07$</out>
<out>$movie08$</out>
<out>$movie09$</out>
<out>$movie10$</out>
</command>

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #5 on: February 01, 2013, 09:50:22 am »
Ori    your a star m8
just going to give it a try   :D

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #6 on: February 01, 2013, 09:51:18 am »
Pri   oops   soz m8

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #7 on: February 01, 2013, 12:41:11 pm »
worked like a dream m8   i do appreciate your time and effort on this, i even sussed how to change where files are stored at increased total from 10 to 40, quite pleased with myself. :).
one last thing   what can i do so that only @ can add?   seems to me at mo anyone can access it. thx in advance  :)

Offline Pri

  • MX Hosts
  • *****
  • *****
Re: metis script
« Reply #8 on: February 01, 2013, 09:08:20 pm »
The easiest way to do that is to add this line of code just after the <in>!movie %PARAM%</in>

Code: [Select]
<out type="break" condition="!=" lvalue="%USERMODE%" rvalue="@"></out>

Basically what this code is doing is checking the users mode in the room, it can either be blank, a + or an @ just like you see in the chat rooms. The condition value here is != which means if the usermode does not match @ then the script will "break" meaning stop. So by placing this piece of code at the top of the script where you add files you're making the script check that the user performing the command has an @ in the userlist and if they don't it won't allow the script to run.

Something to note about this is, if you're using Metis 2.80, 2.81 or 2.82 this won't work. You need to use Metis 2.83 or better. If you need such a Metis you can use my distribution of Metis that you can get here: http://www.mxpulse.com/board/viewtopic.php?f=9&t=405 You will only need to download the metis.r2x and replace the one found in your plugins folder then restart your bot. I recommend you backup your old metis.r2x (don't leave it in the same folder or rename it, physically move it to another folder) just in-case you need it :)

Offline mike777

  • Forum Member
  • I love WinMX!
Re: metis script
« Reply #9 on: February 02, 2013, 10:18:27 pm »
thx again Pri   much appreciated  :)

Offline Pri

  • MX Hosts
  • *****
  • *****
Re: metis script
« Reply #10 on: February 04, 2013, 02:23:16 am »
You're welcome mike :)

WinMX World :: Forum  |  Third Party Stuff  |  Bots  |  metis script
 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What program is this site about?:
What year is it next year?:
What's the name of the site this forum belongs to?:

gfxgfx
gfx
©2005-2024 WinMXWorld.com. All Rights Reserved.
SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies
Page created in 0.021 seconds with 25 queries.
Helios Multi © Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!