Jump to content

Realm System Messages Automated


Guest Garbaek

Recommended Posts

I do not take credit for this, It was on the old mangos forums waaaaay back, and I just stumpled upon the files on my server. Thought I wanted to share.

Note, this only works for linux, cause its using bash scripts.

First make sure you have the correct settings in mangos.conf (all the way in the bottom)

Ra.Enable = 1
Ra.IP = 127.0.0.1
Ra.Port = 3443
Ra.MinLevel = 3 (what gm levels that are allowed to connect to the telnet realm server
Ra.Secure = 1

Then you need to make 3 files

messages.sh

starttelnet.sh

telnet.sh

And they should look something like this

messages.sh

#!/bin/sh

/home/user/adscript/telnet.sh | /home/user/adscript/starttelnet.sh
echo Done

starttelnet.sh

#!/bin/sh

telnet -e X

telnet.sh

#!/bin/sh

host=127.0.0.1   #server hostname or IP address
port=3443
login="USER account"            #RA console commands for login user
passwd="PASS password"  #and the password

message1="This is the first message"
message2="This is the second message"
message3="This is the third message"

mess=$[ ( $RANDOM % 3 ) + 1 ]   # replace "3" with real number of your messages

echo open $host $port
sleep 1
echo $login
sleep 1
echo $passwd
sleep 1

case $mess in
   1)
       echo "announce $message1";
    ;;
   2)
       echo "announce $message2";
    ;;
   3)
       echo "announce $message3";
    ;;

  # and so on..
esac
sleep 1
echo X
sleep 1
echo quit

Then all you need to do, is add the script to crontab, if you want it to run automaticly every xx minutes

type crontab -e to get your crontab, and insert this line in the bottom.

*/15 * * * * /home/user/adscript/messages.sh > /dev/null 2>&1

and your done..

you can naturally test the script by typing

./home/user/adscript/messages.sh in shell

have fun with it..

Link to comment
Share on other sites

Instead of sleep()ing I suggest using `expect' during login.

It comes from tcl, but has support in bash as well:

reply="blah"

expect -c "
   spawn what_to_launch
   expect {
       string_to_expect: { send \\"${reply}\\n\\"; exp_continue }
   }
exit"

you can use wildcards in string_to_expect, such as string_to_* to match string_to_expect , string_to_something, string_to_somethingelse, etc.

starttelnet.sh could be replaced with a simple alias or possibly even deleted.

btw .. I never used MaNGOS RA, if it just prints nothing during login, sleep()ing is a pretty good way, but a one echo for both name and pass should be enough.

Link to comment
Share on other sites

You can also add color codes to the messages

|cff7777cd = Bluish-purple

|cff32cd32 = Green

|cff7777aa = Light Blue

|cffcd32cd = Pink

|cffffcc00 = Yellow

|cffff0000 = Red

|cff995500 = Orange

|cff00ffff = Lightblue

|cffffcc00 = Gold

|c000000ff = Green

|c0000ad00 = Blue

|cff000000 = Black

|cffffffff = White

Ie

message1="|cffffcc00 Hello world!"

Link to comment
Share on other sites

Bash has been ported to most operating systems out there, even to DOS believe it or not.

Furthermore, /bin/sh is a generic shell, available on _all_ *nix-like systems. It's rarely a symlink to some other shell.

So yes, this script will probably work on *BSD, Solaris, etc., since I can't find any bash specifics.

Link to comment
Share on other sites

  • 7 months later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use