Jump to content
Yoshi_E

[DiscordBot] BEC RCon Discord bot (Python)

Recommended Posts

Discord Bot
Github: https://github.com/Yoshi-E/ArmaRconDiscordBot

 

The Discord module currently support these commands:

Current features:

  • addBan Ban offline player
  • admins lists current admins on the server
  • banPlayer Ban online player
  • changePassword Changes the RCon password
  • command Sends a custom command to the server
  • getBEServerVersion Gets the current version of the BE server
  • getBans Lists most recent bans
  • getChat Sends a custom command to the server
  • getMissions Gets a list of all Missions
  • goVote Users can vote for the mission selection.
  • kickPlayer Kicks a player who is currently on the server
  • loadBans (Re)load the BE ban list from bans.txt
  • loadMission Loads a mission
  • loadScripts Loads the 'scripts.txt' file without the need to restart...
  • loadEvents Loads Events 
  • lock Locks the server. No one will be able to join
  • maxPing Changes the MaxPing value. 
  • monitords Shows performance information in the dedicated server console. Interval 0 means to stop monitoring.
  • players lists current players on the server
  • reassign Shuts down the server after mission ends
  • removeBan Removes a ban 
  • restart Restart mission with current player slot selection
  • restartM Shuts down and restarts the server after mission ends
  • restartServer Shuts down and restarts the server immediately
  • say Sends a global message
  • sayPlayer Sends a message to a specific player
  • shutdown Shutdowns the Server
  • shutdownM Shuts down the server after mission ends
  • unlock Unlocks the Server

Special commands:

  • status Current connection status
  • debug Toggles RCon debug mode
  • getChat Returns most recent chat messages
  • checkAFK Checks if a player is AFK by testing if he responds in chat.
  • players+ Lists all players with their Flag and BEID
  • addKeyWord Add a keyword to triggers a DM to you. (Use „\_“ as space)
  • removeKeyWord Removes a keyword
  • listKeyWords Lists all your keywords
  • setNotification Mute the bot, or tell him to send those messages only when you are online.
  • streamChat streams all messages from the arma 3 server into the channel where you used the command. (Is persistent)
  • stopStream Stops the stream
  • start Starts the arma Server Binary
  • stop Stops the arma Server (only works on Windows for now)

 

Additional features are:

  • Easy setup using a web-based settings menu
  • Discord: Notification on configurable keywords
  • User database for username, BEID, IP and last-seen
    • The EPM Rcon database can be imported
  • Automatic warning if users with possible multiple accounts are attempting to connect
  • Display the current player count in the status of the bot.
  • Announce when a joins or leaves the server
  • Announce new bans

 

Works on all platforms! (Windows, Linux, MacOSX)

License: https://creativecommons.org/licenses/by-nc-sa/4.0/

 

How it looks in Discord:

P0JvSqf.png

 

 

 

API Used:

Spoiler

 

Python API BEC_RCon v0.1.1
Github: https://github.com/Yoshi-E/Python-BEC-RCon

 

This might be late by about 5 years or so, but here is an API for Battleyes Extended Control - Rcon.

Our Server uses Discord a lot. You are on the go and receive a ping that a user needs to get banned? Or maybe the server crashed? 
With this API or Discord module you can directly connect to your server and resolve the issue.
You want to automate server restart, resets, or shutdowns? Yep, can be done with this API.

You want to get a notification when somebody asks ingame for help? All possible with this API.

Loading missions at specific times can also be done now!

 

Works on all platforms! (Windows, Linux, MacOSX)

 

API and Discord:

The API is just a straight forward standalone implementation of accessing BEC RCon without having to worry about anything else. Discord is not needed for it!

Install:


pip install git+https://github.com/Yoshi-E/Python-BEC-RCon.git

To upgrade to the lastest version:


pip install git+https://github.com/Yoshi-E/Python-BEC-RCon.git -U

Version:

  • 0.1.0: Initial release (20.06.2019)
  • 0.1.1: Fixed loadMission, +tweaks (24.06.2019)

 

More details about the API can be found on Github

 

 

  • Like 6
  • Thanks 1

Share this post


Link to post
Share on other sites

The API now comes as a package! Version 0.1.0 has been released!
You can directly install it with:

pip install git+https://github.com/Yoshi-E/Python-BEC-RCon.git

Then simply import it with

Quote

 

import bec_rcon

rcon_client = bec_rcon.ARC("192.168.0.1", "MyPassword", 2302)

 

 

Many new commands have been added, together with some additional tweaks.
Added detailed documentation on the API.

  • Thanks 1

Share this post


Link to post
Share on other sites

This would be great to have at least the same functionality like in a Zupa Bot https://bot.devzupa.be/ (this current link just an example. Web version of a bot not working now. Just a standalone version.) For me - my favorite feature is to see the country flag of a player.

This is a commands list https://bot.devzupa.be/commands

Share this post


Link to post
Share on other sites
23 hours ago, varrkan_ua said:

This would be great to have at least the same functionality like in a Zupa Bot

Other than the player+ (wich is now added) all commands and many more are supported.

 

 

---------------------------------------------------------------------------

 

bec_rcon API has been updated to 0.1.1 (fixed loadMission)

Update with:

pip install git+https://github.com/Yoshi-E/Python-BEC-RCon.git -U

Discord module has been updated:

  • getChat Returns most recent chat messages
  • checkAFK Checks if a player is AFK by testing if he responds in chat, does he not, he gets kicked
  • players+ Lists all players with their Flag and BEID
  • loadEvents Loads Events 

  • Like 3

Share this post


Link to post
Share on other sites

is it possible to start a server with this bot?

Share this post


Link to post
Share on other sites
On 7/22/2019 at 9:37 PM, SantoJ said:

is it possible to start a server with this bot?

no. But could be added if you run the python script on your server.

Share this post


Link to post
Share on other sites
56 minutes ago, Dedmen said:

no. But could be added if you run the python script on your server.

I already figured out a simple solution for his problem on Discord with him.

https://pastebin.com/i4nhrnLB

the same commands are also in the main bot too.

 

 

 


The discord bot is now a proper standalone Discord bot, rather than just a Cogs module.

Improved code structure.

 

Added new commands:

Get a notification when a player types specific keywords on the server:

addKeyWord Add a keyword to triggers a DM to you. (Use „\_“ as space)

removeKeyWord Removes a keyword

listKeyWords Lists all your keywords

setNotification Mute the bot, or tell him to send those messages only when you are online.

 

streamChat streams all messages from the arma 3 server into the channel where you used the command. (Is persistent)

stopStream Stops the stream

 

The following commands are disabled until configured:

start Starts the arma Server Binary

stop Stops the arma Server (only works on Windows for now)

 

In the Core Module you can also configure the channels the bots listens to now. Useful if you have multiple instances of the same bot.

  • Like 2

Share this post


Link to post
Share on other sites

please update packages !!!!!!!

python3.6 ((((((

many mistakes

Spoiler

requirements.txt

git+git://github.com/Yoshi-E/Python-BEC-RCon@master#bec_rcon
discord==1.0.1 !!!!! outdated
  - discord.py [required: >=1.2.2, installed: 1.2.2] !!!!! not
    - aiohttp [required: >=3.3.0,<3.6.0, installed: 3.5.4]
      - async-timeout [required: >=3.0,<4.0, installed: 3.0.1]
      - attrs [required: >=17.3.0, installed: 19.1.0]
      - chardet [required: >=2.0,<4.0, installed: 3.0.4]
      - idna-ssl [required: >=1.0, installed: 1.1.0]
        - idna [required: >=2.0, installed: 2.6]
      - multidict [required: >=4.0,<5.0, installed: 4.5.2]
      - typing-extensions [required: >=3.6.5, installed: 3.7.2]
      - yarl [required: >=1.0,<2.0, installed: 1.3.0]
        - idna [required: >=2.0, installed: 2.6]
        - multidict [required: >=4.0, installed: 4.5.2]
    - websockets [required: >=6.0,<7.0, installed: 6.0]
geoip2==2.9.0
  - maxminddb [required: >=1.4.0, installed: 1.4.1]
  - requests [required: >=2.9, installed: 2.18.4]
    - certifi [required: >=2017.4.17, installed: 2017.11.5]
    - chardet [required: >=3.0.2,<3.1.0, installed: 3.0.4]
    - idna [required: >=2.5,<2.7, installed: 2.6]
    - urllib3 [required: >=1.21.1,<1.23, installed: 1.22]
packaging==19.0
  - pyparsing [required: >=2.0.2, installed: 2.3.0]
  - six [required: Any, installed: 1.11.0]
prettytable==0.7.2
pygeoip==0.3.2
psutil==5.3.3   !!!! not

Share this post


Link to post
Share on other sites

@VitalyTurboVaz packages updated

 

Rcon Module (0.1.6):

  • Bugs fixes
  • Added UTF-8 Support

Discord Module:

  • Updated requirements
  • Bug fixes
  • Added UTF-8 Support
  • Added "rcon_custom" module (inactive by default): Posts a message whenever a user was banned / unbanned.
  • Like 1

Share this post


Link to post
Share on other sites

OS Windows Server Standart 2019

 

Install Python3.6+ --->>>>Install python-3.6.8-amd64.exe

Clone the git https://github.com/Yoshi-E/ArmaRconDiscordBot.git

Run pip install -r requirements.txt to install required modules

Run the bot.py once, it will quickly terminate itself, as you still have to configure some settings:

Configure the bot: The files are created upon the first launch

In /modules/core/config.json you have to enter a Discord Bot Token

In /modules/core/permissions.json you can setup the permissions for the bot. (WIP)

In /modules/rcon/rcon_cfg.json you have to enter your Battleye RCon details. Read more about it here: Battleye Rcon.

Now you should be good to go! Just start the bot.py!

 

Spoiler

C:\ArmaRconDiscordBot>bot.py
Traceback (most recent call last):
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 608, in _load_from_module_spec
    setup(self)
  File "C:\ArmaRconDiscordBot\modules\rcon\module.py", line 1018, in setup
    bot.add_cog(CommandRcon(bot))
  File "C:\ArmaRconDiscordBot\modules\rcon\module.py", line 221, in __init__
    self.rcon_settings = CoreConfig.cfg.new(self.path+"/rcon_cfg.json", self.path+"/rcon_cfg.default_json")
  File "C:\ArmaRconDiscordBot\modules\core\config.py", line 112, in new
    return Config(cfg_path, default_cfg_path)
  File "C:\ArmaRconDiscordBot\modules\core\config.py", line 20, in __init__
    self.load()
  File "C:\ArmaRconDiscordBot\modules\core\config.py", line 23, in load
    self.cfg = self.json_load()
  File "C:\ArmaRconDiscordBot\modules\core\config.py", line 28, in json_load
    cfg_t = json.load(open(self.cfg_path,"r"))
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 7 column 25 (char 153)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\ArmaRconDiscordBot\bot.py", line 47, in <module>
    main()
  File "C:\ArmaRconDiscordBot\bot.py", line 35, in main
    load_modules()
  File "C:\ArmaRconDiscordBot\bot.py", line 16, in load_modules
    bot.load_extension("modules."+extension+".module")
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 653, in load_extension
    self._load_from_module_spec(spec, name)
  File "C:\Users\Администратор\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 613, in _load_from_module_spec
    raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'modules.rcon.module' raised an error: JSONDecodeError: Invalid \escape: line 7 column 25 (char 153)

C:\ArmaRconDiscordBot>

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

C:\ArmaRconDiscordBot>py -m pydoc modules

Please wait a moment while I gather a list of all available modules...

__future__          antigravity         http                secrets
_ast                argparse            idlelib             select
_asyncio            array               idna                selectors
_bisect             ast                 idna_ssl            setuptools
_blake2             async_timeout       imaplib             shelve
_bootlocale         asynchat            imghdr              shlex
_bz2                asyncio             imp                 shutil
_codecs             asyncore            importlib           signal
_codecs_cn          atexit              inspect             site
_codecs_hk          attr                io                  six
_codecs_iso2022     audioop             ipaddress           smtpd
_codecs_jp          base64              itertools           smtplib
_codecs_kr          bdb                 json                sndhdr
_codecs_tw          bec_rcon            keyword             socket
_collections        binascii            lib2to3             socketserver
_collections_abc    binhex              linecache           sqlite3
_compat_pickle      bisect              locale              sre_compile
_compression        bot                 logging             sre_constants
_csv                builtins            lzma                sre_parse
_ctypes             bz2                 macpath             ssl
_ctypes_test        cProfile            macurl2path         stat
_datetime           calendar            mailbox             statistics
_decimal            certifi             mailcap             string
_distutils_findvs   cgi                 marshal             stringprep
_dummy_thread       cgitb               math                struct
_elementtree        chardet             maxminddb           subprocess
_functools          chunk               mimetypes           sunau
_hashlib            cmath               mmap                symbol
_heapq              cmd                 modulefinder        symtable
_imp                code                msilib              sys
_io                 codecs              msvcrt              sysconfig
_json               codeop              multidict           tabnanny
_locale             collections         multiprocessing     tarfile
_lsprof             colorsys            netrc               telnetlib
_lzma               compileall          nntplib             tempfile
_markupbase         concurrent          nt                  test
_md5                configparser        ntpath              textwrap
_msi                contextlib          nturl2path          this
_multibytecodec     copy                numbers             threading
_multiprocessing    copyreg             opcode              time
_opcode             crypt               operator            timeit
_operator           csv                 optparse            tkinter
_osx_support        ctypes              os                  token
_overlapped         curses              packaging           tokenize
_pickle             datetime            parser              trace
_pydecimal          dbm                 pathlib             traceback
_pyio               decimal             pdb                 tracemalloc
_random             difflib             pickle              tty
_sha1               dis                 pickletools         turtle
_sha256             discord             pip                 turtledemo
_sha3               distutils           pipes               types
_sha512             doctest             pkg_resources       typing
_signal             dummy_threading     pkgutil             typing_extensions
_sitebuiltins       easy_install        platform            unicodedata
_socket             email               plistlib            unittest
_sqlite3            encodings           poplib              urllib
_sre                ensurepip           posixpath           urllib3
_ssl                enum                pprint              uu
_stat               errno               prettytable         uuid
_string             faulthandler        profile             venv
_strptime           filecmp             pstats              warnings
_struct             fileinput           psutil              wave
_symtable           fnmatch             pty                 weakref
_testbuffer         formatter           py_compile          webbrowser
_testcapi           fractions           pyclbr              websockets
_testconsole        ftplib              pydoc               winreg
_testimportmultiple functools           pydoc_data          winsound
_testmultiphase     gc                  pyexpat             wsgiref
_thread             genericpath         pygeoip             xdrlib
_threading_local    geoip2              pyparsing           xml
_tkinter            getopt              queue               xmlrpc
_tracemalloc        getpass             quopri              xxsubtype
_warnings           gettext             random              yarl
_weakref            glob                re                  zipapp
_weakrefset         gzip                reprlib             zipfile
_winapi             hashlib             requests            zipimport
abc                 heapq               rlcompleter         zlib
aifc                hmac                runpy
aiohttp             html                sched

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".


C:\ArmaRconDiscordBot>

 

Share this post


Link to post
Share on other sites
6 hours ago, VitalyTurboVaz said:

  obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid \escape: line 7 column 25 (char 153)

 

You cant use "\" in the config file, python / json doesnt like it. Replace all of them with "/".

So e.g. instead of "D:\Server\arma\Arma3server_x64" write  "D:/Server/arma/Arma3server_x64" 

 

If you need further troubleshoot, we can write on discord (https://discordapp.com/invite/YhBUUSr) or here in Forum DM.

  • Like 1

Share this post


Link to post
Share on other sites

this also works!!!!

rcon_cfg.json ---->>>>>

"start_server": "'C:\\Games\\ArmA3\\A3Master\\arma3server_x64.exe'

Question.

give commands !monitords 15

the bot answers ----->>>> Restart the mission with new player slot selection

I do not see server performance

in the log (A3Master.log ---->>>

 

 

// GLOBAL SETTINGS
hostname            = "name server";
password             = "";
passwordAdmin          = "****************";
serverCommandPassword = "***********";
logFile                = "A3Master.log";
verifySignatures       = 2;
BattlEye            = 1;                  )

 

of the recording server there is---->>>

16:29:30 Player y**** disconnected.
16:29:30 BattlEye Server: Player #12 y**** disconnected
16:32:12 Server load: FPS 30, memory used: 1683 MB, out: 1608 Kbps, in: 156 Kbps, NG:0, G:512, BE-NG:0, BE-G:0, Players: 9 (L:0, R:0, B:0, G:9, D:0)
16:32:27 Server load: FPS 32, memory used: 1683 MB, out: 1070 Kbps, in: 72 Kbps, NG:0, G:0, BE-NG:0, BE-G:0, Players: 9 (L:0, R:0, B:0, G:9, D:0)
16:32:42 Server load: FPS 37, memory used: 1685 MB, out: 1008 Kbps, in: 89 Kbps, NG:0, G:520, BE-NG:0, BE-G:0, Players: 9 (L:0, R:0, B:0, G:9, D:0)
16:32:57 Server load: FPS 39, memory used: 1689 MB, out: 936 Kbps, in: 81 Kbps, NG:0, G:0, BE-NG:0, BE-G:0, Players: 9 (L:0, R:0, B:0, G:9, D:0)

 

how to make output data to a discord channel from the log?

Share this post


Link to post
Share on other sites
On 4/30/2020 at 10:58 PM, VitalyTurboVaz said:

how to make output data to a discord channel from the log?

 

The command "monitords" does this now by default (displays the performance for the next 5 seconds)

Share this post


Link to post
Share on other sites

Two problems that I did not solve.

1. The output of the server performance to the text channel discord.

I give the command to the bot:

!monitords 15

Bot is responsible:

Restart the mission with new player slot selection

 

2. Ban players.


On the first question, I wanted to ask what log the bot parses.

On the second question - >>>

I give the command to the bot
!help banplayer
Bot is responsible
![banPlayer|banplayer] <player_id> [time=0] [message...]
I give the command to the bot
!addBan 76561198***7183** time=60
Bot is responsible
banPlayer has caused the following error:
Converting to "int" failed for parameter "time".

 

PS There was a problem with the certificate. Unexpectedly, after several weeks of work.

https://gist.github.com/marschhuynh/31c9375fc34a3e20c2d3b9eb8131d8f3

 

 

Share this post


Link to post
Share on other sites
4 hours ago, VitalyTurboVaz said:

1. The output of the server performance to the text channel discord

Make sure you are using the latest version (from today).

with "!monitords" (no number) you should get the performance displayed in discord (only 5 times). The erroneous message was also corrected.

 

 

Quote

On the first question, I wanted to ask what log the bot parses.

The bot takes a list of all log files (*.log and *.rpt) files in the given directory and sorts them by name.
Then it takes the most recent one as the current log to read from. The current log file should be displayed in the console.

 

 

Quote

![banPlayer|banplayer] <player_id> [time=0] [message...]
!addBan 76561198***7183** time=60

The commands do not support value assignments, simply leave the "time=".
time = 0 simply means the default value is 0 --> which is a permanent ban.
 

!addBan 0123456789 60 You are a bad boy

 

Quote

There was a problem with the certificate. Unexpectedly, after several weeks of work.

I am not sure what you mean

Share this post


Link to post
Share on other sites

Launched, but does not work, although it connects to the discord!
 

Spoiler

 

C:\>cd Test_Bot

C:\Test_Bot>bot.py
Failed to load extension: rcon
Traceback (most recent call last):
  File "C:\Test_Bot\bot.py", line 16, in load_modules
    bot.load_extension("modules."+extension+".module")
  File "C:\PY\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 649, in load_extension
    spec = importlib.util.find_spec(name)
  File "C:\PY\Python\Python38\lib\importlib\util.py", line 94, in find_spec
    parent = __import__(parent_name, fromlist=['__path__'])
  File "C:\Test_Bot\modules\rcon\__init__.py", line 1, in <module>
    from .readLog import *
  File "C:\Test_Bot\modules\rcon\readLog.py", line 3, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
Logged in as
Test_Bot
868683939201254365

 

Repeated:

 

Setup:

Install Python3.6+

Clone the git https://github.com/Yoshi-E/ArmaRconDiscordBot.git

Run pip install -r requirements.txt to install required modules

Run the bot.py once, it will quickly terminate itself, as you still have to configure some settings:

Configure the bot: The files are created upon the first launch

In /modules/core/config.json you have to enter a Discord Bot Token

In /modules/core/permissions.json you can setup the permissions for the bot. (WIP)

In /modules/rcon/rcon_cfg.json you have to enter your Battleye RCon details. Read more about it here: Battleye Rcon.

Now you should be good to go! Just start the bot.py!

 

but does not work!!!!!!


 

 

Share this post


Link to post
Share on other sites
1 hour ago, VitalyTurboVaz said:

Launched, but does not work, although it connects to the discord!

A yes, my bad, there were some not used packages in there. Should be good now.

Share this post


Link to post
Share on other sites

Hi!

 

I setup the https://github.com/Yoshi-E/ArmaRconDiscordBot and it works really nice when typing commands! Thanks!

I would like to know however, can i use the https://github.com/Yoshi-E/ArmaRconDiscordBot to send Discord notifications when a player connects and disconnects to the server?
I would like to output that to a specific Discord channel for players to see.

 

Do I need https://github.com/Yoshi-E/Python-BEC-RCon to do this?

Share this post


Link to post
Share on other sites
11 hours ago, Raymond John Clarke said:

I would like to know however, can i use the https://github.com/Yoshi-E/ArmaRconDiscordBot to send Discord notifications when a player connects and disconnects to the server?
I would like to output that to a specific Discord channel for players to see.

 

Do I need https://github.com/Yoshi-E/Python-BEC-RCon to do this?

 

The rcon module is already included in the bot.
https://github.com/Yoshi-E/ArmaRconDiscordBot/blob/master/modules/rcon/module.py#L311-L329

The variable "message" contains the message produced by rcon.

 

For example message = "16:53:53 | (Side) Max: opfor here at kali" 

or message =

"16:27:52 | Player #6 Max disconnected"

"16:59:23 | Player #8 Max (77.21.253.123:17228) connected"

 

you would need a simple regex or if statements to filter them out.

 

Edit: The out comment else block in that code is not quite correct. Connect messages contain a „:“ therefore the split condition there is wrong for what your are planing to do

 

 

to send the message to a specific channel simply do this:

0123456789 here is the channel id.
You can copy the channel id by right clicking a channel directly from discord, if you have the developer mode enabled in the discord settings (Appearance --> Advanced --> Developer mode). 

channel = self.bot.get_channel(0123456789)
await channel.send("Player {} connected".format("Max"))

 

 

Currently I'm refactoring the entire structure, soonish custom stuff can be easily added in extra modules.

Edited by Yoshi_E
  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, Yoshi_E said:

 

The rcon module is already included in the bot.
https://github.com/Yoshi-E/ArmaRconDiscordBot/blob/master/modules/rcon/module.py#L311-L329

The variable "message" contains the message produced by rcon.

 

For example message = "16:53:53 | (Side) Max: opfor here at kali" 

or message =

"16:27:52 | Player #6 Max disconnected"

"16:59:23 | Player #8 Max (77.21.253.123:17228) connected"

 

you would need a simple regex or if statements to filter them out.

 

Edit: The out comment else block in that code is not quite correct. Connect messages contain a „:“ therefore the split condition there is wrong for what your are planing to do

 

 

to send the message to a specific channel simply do this:

0123456789 here is the channel id.
You can copy the channel id by right clicking a channel directly from discord, if you have the developer mode enabled in the discord settings (Appearance --> Advanced --> Developer mode). 


channel = self.bot.get_channel(0123456789)
await channel.send("Player {} connected".format("Max"))

 

 

Currently I'm refactoring the entire structure, soonish custom stuff can be easily added in extra modules.

 

Thanks!

 

So if i understand this correctly ( keeping in mind i am not a coder / developer at all )

channel = self.bot.get_channel(0123456789)

await channel.send("Player {} connected".format("Max"))

 

This means that only if a player named "Max" connects to the server it will output this to the given channel?

I actually want it to output any connect and disconnects from any players to the given channel.

 

Also, could you please guide me on exactly where i need to add this part in the module.py?

Share this post


Link to post
Share on other sites

@Raymond John Clarke I added it as a module, simply update to the latest version, and you should be able to enable the module "modules/rcon_join_msg" it in the settings. 
Some settings require the bot to be restart after change. Setting menu is still WIP.

Share this post


Link to post
Share on other sites

Wow wow wow!! I am super impressed!!
It works perfectly and dummy proof as well now hehe. 🙂

 

Thank you so very very much! I wish i was clever enough to do this myself, but hey, I'm glad there are people like you!

Share this post


Link to post
Share on other sites

@Yoshi_E
I have 2 things that you can maybe assist me with 🙂

One problem I have is that when the server restarts, cmd says:

 

"Reconnecting to BEC Rcon"

 

It never connects BEC automatically so the Bot no longer works until i restart the Bot again.

Any way to set it to try connecting every few seconds perhaps?

2nd thing, the player join and leave msg works great, but some players asked that I rather remove it as it shows the players public IP address. They are worried about ddos attacks and hacks.

Can I set it to only show the name and not the IP as well?

 

Thanks for all the replies!

Share this post


Link to post
Share on other sites
5 hours ago, Raymond John Clarke said:

@Yoshi_E
I have 2 things that you can maybe assist me with 🙂

One problem I have is that when the server restarts, cmd says:

 

"Reconnecting to BEC Rcon"

 

It never connects BEC automatically so the Bot no longer works until i restart the Bot again.

Any way to set it to try connecting every few seconds perhaps?

2nd thing, the player join and leave msg works great, but some players asked that I rather remove it as it shows the players public IP address. They are worried about ddos attacks and hacks.

Can I set it to only show the name and not the IP as well?

 

Thanks for all the replies!

Just as side note here.. I actually use this for Dayz.
So my BEC will output this when a player connects for example:

 

(2020-06-15 | 14:02:40) : Player #3 PlayerName (79.512.1.151:2000) connected

 

I only want it to show: Player #3 PlayerName connected

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×