Difference between revisions of "Installation"

From Bebot Wiki 2
Jump to navigationJump to search
 
(9 intermediate revisions by the same user not shown)
Line 8: Line 8:
  
 
* an account of Anarchy Online (paid only if to be connected into RK2019 server) or Age of Conan
 
* an account of Anarchy Online (paid only if to be connected into RK2019 server) or Age of Conan
* PHP version from 5.4 (minimal requirement) upto 8.2 (max tested so far)
+
* PHP version from 5.4 (minimally but 7+ advised) upto 8.3 ("Max Tested So Far" aka MTSF)
* database server of either Mysql (from 4.1 upto 8.0) or MariaDB (10.0 upto 10.4)
+
* database server of either Mysql (from 4.1 upto 8.0 MTSF) or MariaDB (10.0 upto 11.2 MTSF)
 
* either "Official" files at https://github.com/J-Soft/BeBot/archive/master.zip (stable) or "Beta" files from https://github.com/bitnykk/BeBot/archive/master.zip (sandbox) NB : if you know how to use git, you also can clone/pull from any of these urls.
 
* either "Official" files at https://github.com/J-Soft/BeBot/archive/master.zip (stable) or "Beta" files from https://github.com/bitnykk/BeBot/archive/master.zip (sandbox) NB : if you know how to use git, you also can clone/pull from any of these urls.
  
Line 29: Line 29:
  
 
Download the latest release version from the BeBot homepage and unzip/git the files to a directory maintaining the directory structure.
 
Download the latest release version from the BeBot homepage and unzip/git the files to a directory maintaining the directory structure.
 +
 +
OR
 +
 +
Follow our Docker guide (if you juste want to test Bebot or run 1 bot and you have no SQL) http://wiki.bebot.link/index.php/Docker
  
 
'''Database'''
 
'''Database'''
Line 55: Line 59:
  
 
On linux, you may have to perform various installs depending on which OS you run (and its version). Usually apt (or yum) based :
 
On linux, you may have to perform various installs depending on which OS you run (and its version). Usually apt (or yum) based :
 
+
* install phpX.Y phpX.Y-mysqli phpX.Y-bcmath phpX.Y-curl phpX.Y-mbstring (X.Y being the PHP version you aim for, eg 7.0 or 8.1, etc).
install phpX.Y phpX.Y-mysqli phpX.Y-bcmath phpX.Y-curl phpX.Y-mbstring (X.Y being the PHP version you aim for, eg 7.0 or 8.1, etc).
 
  
 
On windows, according to the PHP version you'd want Bebot to run into, you may need to copy a php.exe file right into bot's root folder (where StartBot.bat is). Unless windows PATH and/or php.ini are well set so the exe can locate required libraries alone, you may have to copy correct .dll files for this specific PHP.
 
On windows, according to the PHP version you'd want Bebot to run into, you may need to copy a php.exe file right into bot's root folder (where StartBot.bat is). Unless windows PATH and/or php.ini are well set so the exe can locate required libraries alone, you may have to copy correct .dll files for this specific PHP.
 
+
* For 5.4/5.6 : libeay32, libmysql, php5ts and ssleay32, php_mysqli & php_sockets.
For 5.4/5.6 : libeay32, libmysql, php5ts and ssleay32, php_mysqli & php_sockets.
+
* For 7+.x : libcrypt, libssl, libssh2, sockets, nghttp2, curl & phpX(ts).
For 7.x : libcrypt, libssl, libssh2, sockets, nghttp2, curl & php7(ts).
 
  
 
Bot will tell you what misses to run during startup, so check all lines !
 
Bot will tell you what misses to run during startup, so check all lines !
Line 84: Line 86:
 
  extension=pdo_mysql
 
  extension=pdo_mysql
 
  extension=sockets
 
  extension=sockets
 +
 +
You also should look after the value of the parameter "memory_limit" in php.ini. It could be set at -1 (unlimited) which is fine if you got lot of RAM.
 +
Otherwise you'd want to control how much RAM each bot uses (if you run many). Anything around 10M (linux) or 50M (windows) should work safe enough :
 +
 +
memory_limit = 50M
 +
 +
If you see errors about exhausted allowed memory size, raise that number up of, e.g., 10M more (50M becomes 60M for example) until it works fine.
  
 
In Startbot.php you may want to set $main_php to location of the "Main.php". Leave it at "Main.php" if you're starting the bot from the directory its in. But if StartBot.php is in another directory than the bot itself (not recommended) you must specify its complete path to "Main.php".  
 
In Startbot.php you may want to set $main_php to location of the "Main.php". Leave it at "Main.php" if you're starting the bot from the directory its in. But if StartBot.php is in another directory than the bot itself (not recommended) you must specify its complete path to "Main.php".  
 +
 +
'''Config files'''
 +
 +
You can either fill up infos at bot's 1st run (if no conf file exists, they will be created once interactive setup is done), or edit them manually :
  
 
Open the file Bot.conf, which is in the conf directory where you installed the bot, in a text editor. Here you will have to enter the Anarchy-Online username, password and the name of the bot along with the dimension number you would like to run it on.
 
Open the file Bot.conf, which is in the conf directory where you installed the bot, in a text editor. Here you will have to enter the Anarchy-Online username, password and the name of the bot along with the dimension number you would like to run it on.
Line 100: Line 113:
  
 
The last 4 values are probably best left at default.
 
The last 4 values are probably best left at default.
 +
 +
'''1K Limit'''
 +
 +
Each bot has a limit of friendlist ingame, but that can be overcome by specific tricks and config.
 +
 +
For AO specifically, you may use AOCP over a certain version of Bebot. For AoC you have the slaves module.
 +
 +
Both are detailed in README and/or at this page http://wiki.bebot.link/index.php/Friendlist
  
 
'''Guild bot ONLY'''
 
'''Guild bot ONLY'''

Latest revision as of 21:24, 17 December 2023

Installing bebot

Prerequisites (What do you need?)

To install and run BeBot you need the following:

  • an account of Anarchy Online (paid only if to be connected into RK2019 server) or Age of Conan
  • PHP version from 5.4 (minimally but 7+ advised) upto 8.3 ("Max Tested So Far" aka MTSF)
  • database server of either Mysql (from 4.1 upto 8.0 MTSF) or MariaDB (10.0 upto 11.2 MTSF)
  • either "Official" files at https://github.com/J-Soft/BeBot/archive/master.zip (stable) or "Beta" files from https://github.com/bitnykk/BeBot/archive/master.zip (sandbox) NB : if you know how to use git, you also can clone/pull from any of these urls.

Create a player

A bot is basically a regular player character so you'll need to create a character on the appropriate dimension or server. The breed, gender and profession is irrelevant for the function of the bot. The name of the toon will be the name of the bot. You can use an already existing character, but be advised that this character should not be played while the bot is running. If you try to login as this character the bot will be disconnected.

Notes for guild-style bot

A guild bot needs to be a member of the guild it is to be a bot for.

For Anarchy Online, this means that it needs to have the same faction as the guild. For tower wars to work as intended the bot needs to be in the top three ranks of an org. This is because the [ALL TOWERS] channel is restricted to these ranks.

For Age of Conan there are no extra requirements. If you want the bot to do be able to perform guild member add/remove functions you will need to promote it to a suitable rank. We suggest you don't do this until you are comfortable with bebot and how it operates.

Download and install BeBot

You will need to do one of the following to get BeBot:

Download the latest release version from the BeBot homepage and unzip/git the files to a directory maintaining the directory structure.

OR

Follow our Docker guide (if you juste want to test Bebot or run 1 bot and you have no SQL) http://wiki.bebot.link/index.php/Docker

Database

0. Prompt into your database, e.g. by doing : mysql -u user -p

   (Enter/Return then type password and Enter/Return again)

1. Type CREATE DATABASE databasename CHARACTER SET latin1; (or utf8 for recent PHP/SQL)

   (replace databasename with the name of the database you wish to create)

2. Press Enter/Return. 3. CREATE USER username@localhost;

   (Change username to the username you want, keep @localhost)

4. Press Enter/Return. 5. SET PASSWORD FOR username@localhost = PASSWORD("newpassword");

   (Change username and newpassword to your selected username and password, again keep @localhost)

6. Press Enter/Return. 7. Type GRANT ALL on databasename.* TO username@localhost;

   (Again, change username, keep @localhost)

8. Press Enter/Return. 9. Type quit then Enter/Return to exit the MySQL Monitor.

StartBot.php

If you start the bot from the same directory as the binary php file (for windows "php.exe") you can just enter the name. Otherwise you'll have to enter the name and path of the binary executable (ie C:/Program files/PHP/php.exe or C:\\ProgramFiles\\PHP\\php.exe or /usr/local/bin/php5).

Note that you can use forward slashes (recommended) or double backslashes (not recommended) on windows systems. Using single backslashes WILL NOT WORK as php interprets \ as a special escape character.

On linux, you may have to perform various installs depending on which OS you run (and its version). Usually apt (or yum) based :

  • install phpX.Y phpX.Y-mysqli phpX.Y-bcmath phpX.Y-curl phpX.Y-mbstring (X.Y being the PHP version you aim for, eg 7.0 or 8.1, etc).

On windows, according to the PHP version you'd want Bebot to run into, you may need to copy a php.exe file right into bot's root folder (where StartBot.bat is). Unless windows PATH and/or php.ini are well set so the exe can locate required libraries alone, you may have to copy correct .dll files for this specific PHP.

  • For 5.4/5.6 : libeay32, libmysql, php5ts and ssleay32, php_mysqli & php_sockets.
  • For 7+.x : libcrypt, libssl, libssh2, sockets, nghttp2, curl & phpX(ts).

Bot will tell you what misses to run during startup, so check all lines ! E.g. you may need to install some modules (e.g. curl) and/or activate them in php.ini your install uses. So first be sure of what php.ini file is loaded by the PHP client Bebot uses. Then edit this php.ini file to enable required modules by adding or uncommenting (aka remove ";" first letter) at least the following :

PHP5*:

extension=php_curl.dll
extension=php_mbstring.dll
extension=php_mysqli.dll
extension=php_openssl.dll
extension=php_pdo_mysql.dll
extension=php_sockets.dll
  • on linux, the upper extensions would be .so instead of .dll

PHP7/8

extension=curl
extension=mbstring
extension=mysqli
extension=openssl
extension=pdo_mysql
extension=sockets

You also should look after the value of the parameter "memory_limit" in php.ini. It could be set at -1 (unlimited) which is fine if you got lot of RAM. Otherwise you'd want to control how much RAM each bot uses (if you run many). Anything around 10M (linux) or 50M (windows) should work safe enough :

memory_limit = 50M

If you see errors about exhausted allowed memory size, raise that number up of, e.g., 10M more (50M becomes 60M for example) until it works fine.

In Startbot.php you may want to set $main_php to location of the "Main.php". Leave it at "Main.php" if you're starting the bot from the directory its in. But if StartBot.php is in another directory than the bot itself (not recommended) you must specify its complete path to "Main.php".

Config files

You can either fill up infos at bot's 1st run (if no conf file exists, they will be created once interactive setup is done), or edit them manually :

Open the file Bot.conf, which is in the conf directory where you installed the bot, in a text editor. Here you will have to enter the Anarchy-Online username, password and the name of the bot along with the dimension number you would like to run it on.

$owner is the super-duper admin of the bot. This user has got all rights. This should be the name of the character which you intend to configure the bot with as some settings require you to be owner in order to change.

Below that is the configuration lines for your super admins. You can add as many superadmins as you like. Just copy and past that line and exchange the name. These names cannot be downgraded in-game so it is recomended that you hard-code as few super admins here as possible. Instead of putting the names in here we recomend using the !admin add SUPERADMIN <username> in-game to add superadmins.

The next section works just like the superadmins. You can tell the bot what other bots it may encounter in the guild. This is so that the bot just ignores tells and messages from the other bot and doesn't end up in a spam war with it.

To switch logging off set “$log” to “off”. You can also set it to “chat” which will only log incoming and outgoing messages. If set to “all” everything displayed on the console will be put into the log. The default is “chat”. Set “$log_path” to the place where you want logs to be saved.

With “$command_prefix” you can determin what symbol commands start with. The default here is “!”. Note that you need to use the regex string here. This means that to use “.” as your command prefix you need to enter “\.” because “.” has got a special meaning in regular expressions so it must be escaped by antislah \. This goes for a lot of other characters needing to be antislash-escaped as well, namely . ^ $ * + - ? ( ) [ ] { } \ | — /

The last 4 values are probably best left at default.

1K Limit

Each bot has a limit of friendlist ingame, but that can be overcome by specific tricks and config.

For AO specifically, you may use AOCP over a certain version of Bebot. For AoC you have the slaves module.

Both are detailed in README and/or at this page http://wiki.bebot.link/index.php/Friendlist

Guild bot ONLY

To make a guild bot set “$guildbot” to true. Change “$guild_name” to the exact name of your guild. Set “$guild_id” to the id of your guild. The easiest way to find out the guild ID is going to http://www.anarchy-online.com/content/community/people/ and finding your guild. The URL will now read something like this: “http://www.anarchy-online.com/org/stats/d/1/name/xxxxxx” where the “xxxxxx” would be your guild ID. To relay chat to another guild bot you want to set $guild_relay_target = “Name_of_other_guildbot”; If you do not want this feature set $guild_relay_target = False; (note: False, not “False”. If you use quotes your bot will attempt to relay to the player named 'False')

Raid bot ONLY

To make a raid bot set “$guildbot” to false. leave “$guild_name” blank. Set “$guild_id” to 0. For a raid bot you most likely want to set $guild_relay_target = False; (note: False, not “False”) conf/MySQL.conf

Set the MySQL username, password, server IP adress or server host name and database name for the bot.

Starting the bot

Open a console (In windows press “Start” ⇒ “Run” ⇒ enter “cmd” and press enter). Now run StartBot (.php under linux or .bat under windows) : Windows: Navigate to the directory of your bot assuming you have the php.exe in the same directory and write “StartBot.bat”. You also can make it a startup shortcut as long as your database service runs too. Linux: Assuming you can run php from anywhere navigate to your bot directory and write “php StartBot.php” (assuming your php binary is named “php”). You also can cron it at startup with screen, as long as your database service runs too.

The console should now state that the bot is loading the modules, authenticating and connecting. Once this is done (it should only take a few seconds) You can log onto an character ingame which you have configured as “superadmin”. You should now be able to talk to the bot.

Automated bot(s) start

On windows, it should be quite easy to add a shortcut to your bot's StartBot.bat file into the startup folder. On recent versions it is e.g. located at C:Users/Username/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup

On linux, there are several ways of automating bot(s) start, both should use some processor like screen (or nohup if you prefer).

Simplest way, you add such a line into your crontab :

@reboot /path/script.sh

This executable (chmod +x) bash script contains e.g. :

for bebot in toon1 toon2 toon3 etc
do
 cd /path/to/$bebot
 screen -d -m -S $bebot php -f StartBot.php
done

More complex way, you create service(s) into systemd :

nano /lib/systemd/system/botname.service

This file contains all details about it :

[Unit]
Description=Freely describe your bot service
After=network.target

[Service]
Type=simple
User=root
RemainAfterExit=yes
WorkingDirectory=/path/to/botname
ExecStart=/usr/bin/screen  -d -m -S botname /usr/bin/php -f /path/to/StartBot.php
ExecReload=/bin/kill $(ps -aux | grep -v grep | grep -w botname | awk '{print $2}')
StandardOutput=file:/var/log/botservice.log

[Install]
WantedBy=multi-user.target

(Be sure to use an unique bot name or that may kill more than the wanted/targetted process)

Just update your system with as for any further service change :

systemctl daemon-reload

Then you can type (or crontab) :

service botname start|reload

Or :

systemctl start botname.service

In this case your reboot bash script upper should rather be like :

/bin/systemctl start botname.service

Would your bot into an AOCP proxy with slaves, you could also service it on same model :

[Unit]
Description=Freely describe your proxy service
After=network.target

[Service]
Type=simple
User=root
RemainAfterExit=yes
WorkingDirectory=/path/to/aocproxy
ExecStart=/usr/bin/screen  -d -m -S aocproxy /path/to/aocproxy/run.sh
ExecReload=/bin/kill $(ps -aux | grep -v grep | grep -w aocproxy | awk '{print $2}')
StandardOutput=file:/var/log/aocproxyservice.log

[Install]
WantedBy=multi-user.target

(here also, be careful to use an unique proxy name to avoid killing unwanted processes)


In-game setup

Starting at version 0.3 there is a new settings module to handle configuration of most aspects and many modules for BeBot. Most notable is the Security module. To start configuring it send a tell to your bot with “!settings security”. For a list of modules whose settings are configurable by the new interface send a tell to your bot with “!settings”.

Adding and Removing Modules

If you do not wish for certain modules to be used by a bot just put an underscore (“_”) at the front of the name in the “modules” directory. There are several files already in the distribution that have been commented out in this way: Most notable is _ExampleModule.php which is a template to make your own modules. Installing 3rd party modules

We recommend you put any 3rd party modules into the directory named custom instead of putting it directly into the modules or core directories. This is because if a 3rd party module has got the same name as a standard module or a module with that name is added later it will be over-written if you upgrade the bot. Modules in the 'custom' directory are never touched by installing upgrades to BeBot.