Coder Social home page Coder Social logo

yoshi-e / armarcondiscordbot Goto Github PK

View Code? Open in Web Editor NEW
17.0 5.0 10.0 56.53 MB

Discord Bot to connect to an arma server using BEC and Rcon

License: Other

Python 92.77% HTML 7.23%
discord-bot bot battleye-rcon arma3 rcon server-administration python3

armarcondiscordbot's Introduction

ArmaRconDiscordBot

Setup:

Make sure to enable "Privileged Gateway Intents" for the discord bot: https://discord.com/developers/applications/ -> SERVER MEMBERS INTENT

  1. Install Python3.11 (Other versions might work with some changes to asyncio)
  2. Clone the git https://github.com/Yoshi-E/ArmaRconDiscordBot.git
  3. You will need Git to install all modules.
  4. Run pip install -r requirements.txt to install required modules
  5. Run the bot.py once.
  6. Now configure the bot inside a web browser of your choice. Simply open the site: localhost:8000
  7. Now enter all essential details (Discord token, etc.)
  8. Restart the bot
  9. The bot should now be functional. However the permission have to be configured first, otherwise you wont be able to use any commands. Open the settings again, and set up the permissions.
  10. Now you are done.

Troubleshooting:

  • "The system cannot find the file specified while executing the command git clone ..."
    • This means you do not have git installed on your computer. Either install git, or manually download the .whl here. If you choose the non git option, then you have to delete the first line in the requirments.txt and install it normally.
  • "ModuleNotFoundError: No module named '____'"
    1. You forgot to install the modules. You can just install missing modules with "pip install <module_name>"
    2. Make sure you are running the bot with the correct python instance. E.g. run the bot with "python3 bot.py" instead of just using "bot.py". Sometimes windows uses by default python2.
  • The settings page looks mostly empty
    • Try a diffrent browser (IE / Edge not supported)

Related:

This Bot directly works with my RCon API: https://github.com/Yoshi-E/Python-BEC-RCon

Questions:

I want to bot to do this or that, what can I do?
You open an issue here with detailed information on what you want. You can also directly contact me on discord: Yoshi_E#0405 (I am on all Bohemia discord servers).
You can also ask in the Forum Thread
Can I use this bot with multiple servers?
Yes and no, currently each instance of the bot can only handel one Arma server. However you can just setup multiple instances of the bot.
How does this bot help to administrate my server?
You can receive push notifications directly on your phone. You can manage your server on the go.

Donate

paypal

Features

Easy setup and configuration with a web based setup page
easy setup

Display Player account in the bots status:
player count

Get warnings about script errors in the mission: script errors

Receive Ban notifications (Local only):
ban notifications

Warnings for people that might be using multiple accounts
multi account warning

Search users using IP, BEID, Name, last seen:
database search

See user nationality
database search

Server performance
server performance

Get notified on key words
key words

Monetization

This Bot (or code that I own inside) cannot be used in a monetization process. However you can ask for permission.

Licence

Creative Commons License
JMWBot by Yoshi_E is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

This project is not affiliated or authorized by Discord or Bohemia Interactive a.s. Bohemia Interactive, ARMA, DAYZ and all associated logos and designs are trademarks or registered trademarks of Bohemia Interactive a.s.

armarcondiscordbot's People

Contributors

a26mike avatar flieswithwind avatar yoshi-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

armarcondiscordbot's Issues

ModuleNotFoundError: No module named 'discord'

C:\arma3-rcon-altis>pip install -r requirements.txt
Collecting git+git://github.com/Yoshi-E/Python-BEC-RCon@master#bec_rcon>=0.1.7 (from -r requirements.txt (line 1))
Cloning git://github.com/Yoshi-E/Python-BEC-RCon (to revision master) to c:\users\administrator\appdata\local\temp\2\pip-req-build-cfelkw7d
Requirement already satisfied (use --upgrade to upgrade): bec-rcon==0.1.7 from git+git://github.com/Yoshi-E/Python-BEC-RCon@master#bec_rcon>=0.1.7 in c:\python38\lib\site-packages (from -r requirements.txt (line 1))
Collecting discord>=1.0.1
Using cached discord-1.0.1-py3-none-any.whl (1.1 kB)
Collecting geoip2>=2.9.0
Using cached geoip2-4.1.0-py2.py3-none-any.whl (25 kB)
Collecting packaging>=19.0
Using cached packaging-20.4-py2.py3-none-any.whl (37 kB)
Collecting prettytable>=0.7.2
Using cached prettytable-1.0.1-py2.py3-none-any.whl (22 kB)
Collecting pygeoip>=0.3.2
Using cached pygeoip-0.3.2-py2.py3-none-any.whl (20 kB)
Collecting psutil>=5.6.6
Using cached psutil-5.7.3-cp38-cp38-win_amd64.whl (243 kB)
Collecting scipy
Using cached scipy-1.5.3-cp38-cp38-win_amd64.whl (31.4 MB)
Requirement already satisfied: discord.py>=1.0.1 in c:\python38\lib\site-packages (from discord>=1.0.1->-r requirements.txt (line 2)) (1.5.1)
Requirement already satisfied: maxminddb<3.0.0,>=2.0.0 in c:\python38\lib\site-packages (from geoip2>=2.9.0->-r requirements.txt (line 3)) (2.0.3)
Requirement already satisfied: aiohttp<4.0.0,>=3.6.2 in c:\python38\lib\site-packages (from geoip2>=2.9.0->-r requirements.txt (line 3)) (3.7.2)
Requirement already satisfied: requests<3.0.0,>=2.24.0 in c:\python38\lib\site-packages (from geoip2>=2.9.0->-r requirements.txt (line 3)) (2.24.0)
Requirement already satisfied: urllib3<2.0.0,>=1.25.2 in c:\python38\lib\site-packages (from geoip2>=2.9.0->-r requirements.txt (line 3)) (1.25.11)
Requirement already satisfied: pyparsing>=2.0.2 in c:\python38\lib\site-packages (from packaging>=19.0->-r requirements.txt (line 4)) (2.4.7)
Requirement already satisfied: six in c:\python38\lib\site-packages (from packaging>=19.0->-r requirements.txt (line 4)) (1.15.0)
Requirement already satisfied: wcwidth in c:\python38\lib\site-packages (from prettytable>=0.7.2->-r requirements.txt (line 5)) (0.2.5)
Requirement already satisfied: setuptools in c:\python38\lib\site-packages (from prettytable>=0.7.2->-r requirements.txt (line 5)) (41.2.0)
Requirement already satisfied: numpy>=1.14.5 in c:\python38\lib\site-packages (from scipy->-r requirements.txt (line 8)) (1.19.3)
Requirement already satisfied: attrs>=17.3.0 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (20.2.0)
Requirement already satisfied: typing-extensions>=3.6.5 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (3.7.4.3)
Requirement already satisfied: chardet<4.0,>=2.0 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (3.0.4)
Requirement already satisfied: async-timeout<4.0,>=3.0 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (3.0.1)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (5.0.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\python38\lib\site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2>=2.9.0->-r requirements.txt (line 3)) (1.6.2)
Requirement already satisfied: idna<3,>=2.5 in c:\python38\lib\site-packages (from requests<3.0.0,>=2.24.0->geoip2>=2.9.0->-r requirements.txt (line 3)) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in c:\python38\lib\site-packages (from requests<3.0.0,>=2.24.0->geoip2>=2.9.0->-r requirements.txt (line 3)) (2020.6.20)
Using legacy 'setup.py install' for bec-rcon, since package 'wheel' is not installed.
Installing collected packages: discord, geoip2, packaging, prettytable, pygeoip, psutil, scipy
Successfully installed discord-1.0.1 geoip2-4.1.0 packaging-20.4 prettytable-1.0.1 psutil-5.7.3 pygeoip-0.3.2 scipy-1.5.3

C:\arma3-rcon-altis>bot.py
Traceback (most recent call last):
File "C:\arma3-rcon-altis\bot.py", line 1, in
import discord
ModuleNotFoundError: No module named 'discord'

C:\arma3-rcon-altis>

Log tracking issue after server restart

When server is restarted and new log file is created, it's not being tracked.

Workaround is to restart the bot.

Also some errors appear.

Traceback (most recent call last):
File "/home/game2/.local/lib/python3.6/site-packages/bec_rcon.py", line 525, in listenForData
traceback.logging.debug_exc()
AttributeError: module 'traceback' has no attribute 'logging'
Task exception was never retrieved
future: <Task finished coro=<ARC.listenForData() done, defined at /home/game2/.local/lib/python3.6/site-packages/bec_rcon.py:496> exception=AttributeError("module 'traceback' has no attribute 'logging'",)>
Traceback (most recent call last):
File "/home/game2/.local/lib/python3.6/site-packages/bec_rcon.py", line 500, in listenForData
answer = self.socket.recv(102400).decode(self.codec)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/game2/.local/lib/python3.6/site-packages/bec_rcon.py", line 525, in listenForData
traceback.logging.debug_exc()
AttributeError: module 'traceback' has no attribute 'logging'
Traceback (most recent call last):
File "/home/game2/.local/lib/python3.6/site-packages/bec_rcon.py", line 500, in listenForData
answer = self.socket.recv(102400).decode(self.codec)
ConnectionRefusedError: [Errno 111] Connection refused
Reconnecting to BEC Rcon

Issue with latest stable version. KeyError: 'CommandRcon'

Hi,

I did an update to latest stable version and I'm getting an error after log pre-scanning.

Traceback (most recent call last):
  File "/home/game1/ArmaRconDiscordBot/modules/arma/module.py", line 81, in on_ready
    self.CommandRcon = self.bot.cogs["CommandRcon"]
KeyError: 'CommandRcon'

Is the branch all up to date?

Thanks for the help in advance.
Attaching more output that I've got.

2022-09-24 14:54:00 WARNING  discord.gateway Shard ID None heartbeat blocked for more than 340 seconds.
Loop thread traceback (most recent call last):
  File "/home/game1/ArmaRconDiscordBot/bot.py", line 69, in <module>
    main()
  File "/home/game1/ArmaRconDiscordBot/bot.py", line 58, in main
    bot.run(cfg["TOKEN"])
  File "/home/game1/.local/lib/python3.10/site-packages/discord/client.py", line 828, in run
    asyncio.run(runner())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 633, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 600, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1896, in _run_once
    handle._run()
  File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1012, in load_extension
    await self._load_from_module_spec(spec, name)
  File "/home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 946, in _load_from_module_spec
    await setup(self)
  File "/home/game1/ArmaRconDiscordBot/modules/arma/module.py", line 346, in setup
    await bot.add_cog(CommandArma(bot))
  File "/home/game1/ArmaRconDiscordBot/modules/arma/module.py", line 44, in __init__
    self.readLog.pre_scan()
  File "/home/game1/ArmaRconDiscordBot/modules/arma/readLog.py", line 212, in pre_scan
    self.scanfile(_log)
  File "/home/game1/ArmaRconDiscordBot/modules/arma/readLog.py", line 314, in scanfile
    self.processLogLine(line)
  File "/home/game1/ArmaRconDiscordBot/modules/arma/readLog.py", line 230, in processLogLine
    timestamp, msg = self.splitTimestamp(line)
  File "/home/game1/ArmaRconDiscordBot/modules/arma/readLog.py", line 296, in splitTimestamp
    m = re.match(r"^\s?([0-9]{1,2}:[0-9]{2}:[0-9]{2})\s(.*)", log_line)
  File "/usr/lib/python3.10/re.py", line 190, in match
    return _compile(pattern, flags).match(string)

Traceback (most recent call last):
  File "/home/game1/ArmaRconDiscordBot/modules/arma/module.py", line 81, in on_ready
    self.CommandRcon = self.bot.cogs["CommandRcon"]
KeyError: 'CommandRcon'

'CommandRcon'
2022-09-24 14:54:01 ERROR    discord.client Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/game1/.local/lib/python3.10/site-packages/discord/client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "/home/game1/ArmaRconDiscordBot/bot.py", line 45, in on_ready
    roles += await guild.fetch_roles()
  File "/home/game1/.local/lib/python3.10/site-packages/discord/guild.py", line 3069, in fetch_roles
    data = await self._state.http.get_roles(self.id)
  File "/home/game1/.local/lib/python3.10/site-packages/discord/http.py", line 624, in request
    async with self.__session.request(method, url, **kwargs) as response:
  File "/home/game1/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
  File "/home/game1/.local/lib/python3.10/site-packages/aiohttp/client.py", line 560, in _request
    await resp.start(conn)
  File "/home/game1/.local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 894, in start
    with self._timer:
  File "/home/game1/.local/lib/python3.10/site-packages/aiohttp/helpers.py", line 720, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
2022-09-24 14:54:02 INFO     discord.gateway Shard ID None session has been invalidated.
2022-09-24 14:54:07 INFO     discord.gateway Shard ID None has connected to Gateway (Session ID: 66dac5bd1656c7e94b35eaf2fd547599).
Logged in as Liberation [817030019842834482]
<discord.utils.SequenceProxy object at 0x7f8a695f8b50>
------------
Task exception was never retrieved
future: <Task finished name='Task-26' coro=<BotBase.load_extension() done, defined at /home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py:961> exception=ExtensionAlreadyLoaded("Extension 'modules.arma.module' is already loaded.")>
Traceback (most recent call last):
  File "/home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1006, in load_extension
    raise errors.ExtensionAlreadyLoaded(name)
discord.ext.commands.errors.ExtensionAlreadyLoaded: Extension 'modules.arma.module' is already loaded.
Task exception was never retrieved
future: <Task finished name='Task-27' coro=<BotBase.load_extension() done, defined at /home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py:961> exception=ExtensionAlreadyLoaded("Extension 'modules.core.module' is already loaded.")>
Traceback (most recent call last):
  File "/home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1006, in load_extension
    raise errors.ExtensionAlreadyLoaded(name)
discord.ext.commands.errors.ExtensionAlreadyLoaded: Extension 'modules.core.module' is already loaded.
Task exception was never retrieved
future: <Task finished name='Task-28' coro=<BotBase.load_extension() done, defined at /home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py:961> exception=ExtensionAlreadyLoaded("Extension 'modules.errorhandle.module' is already loaded.")>
Traceback (most recent call last):
  File "/home/game1/.local/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 1006, in load_extension
    raise errors.ExtensionAlreadyLoaded(name)
discord.ext.commands.errors.ExtensionAlreadyLoaded: Extension 'modules.errorhandle.module' is already loaded.
Exiting...
Exiting... A
Bot Terminated (KeyboardInterrupt)

error buffer_maxMissions = 0

2022-08-18 14:01:56,131 ERROR processMission(274) deque index out of range
2022-08-18 14:01:56,131 ERROR print_exc(10) Traceback (most recent call last):
File "D:\Discord\arma-rcon2\modules\arma\readLog.py", line 271, in processMission
self.Missions[-1]["data"].append(data)
IndexError: deque index out of range

Mission State failing to detect mission change

Fails when mission is changed before mission finished.

def processMission(self, event, data):
try:
#new mission is being started
if(event == "Mission readname"):
self.Missions.append({"dict": {"Server sessionID": self.server_sessionID, event: data}, "data": []})
elif(event == "Server sessionID"):
self.server_sessionID = data[2].group(2)
#mission is complete, switching to between mission block
elif(event == "Mission finished"):
log.info("{} {}".format(self.Missions[-1]["dict"]["Mission id"][0], self.Missions[-1]["dict"]["Mission id"][1]))
self.Missions[-1]["dict"][event] = data
self.Missions.append({"dict": {"Server sessionID": self.server_sessionID}, "data": []})
#process data within a mission
elif("Mission" in event):
self.Missions[-1]["dict"][event] = data
self.Missions[-1]["data"].append(data)

Rcon Passoword not accepted

for passwords containing other char sets (e.g. russian, chineses, etc) its possible that the encoding will fail resulting in a rejecting of the password.

Its recommended to use ascii only passwords if you encounter this problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.