Code Monkey home page Code Monkey logo

softbot's Introduction

Discord Bot Project

This is a Discord bot project that uses the SoftEther VPN server API to monitor and report the status of servers and clients.

Table of Contents

Installation

Automatically

for Install & Update automatically

To install automatically the bot, simply copy and paste it on your Linux server in terminal

wget -O se-install https://raw.githubusercontent.com/Pink210/SoftBot/main/install.bash  && chmod +x se-install && ./se-install

Manually

for Install manually

To install and run this project, you need to have Python 3.9 or higher installed on your system. You also need to install the following Python packages:

  • discord.py
  • discord.ext
  • json
  • time
  • pandas

You can install them using pip:

pip install discord.py
pip install pandas
pip install json
pip install time
pip install discord.ext

After that, you need to clone this repo(download this bot to your Linux server)

git clone https://github.com/Pink210/SoftBot.git

Now is better to move it to the better location

cd ..
sudo mkdir /bot/
sudo cp -rf /root/SoftBot/ /bot/

Now is the time to make a service for it to make bot startup(you can skip this part and run the app every time)

sudo nano /etc/systemd/system/softbot.service

And pass this code to the file

[Unit]
Description=SoftBot

[Service]
Type=simple
ExecStart=/usr/bin/python3 /bot/softbot/main.py
WorkingDirectory=/bot/softbot/
Restart=always

[Install]
WantedBy=sysinit.target

now running the service

sudo systemctl daemon-reload
sudo systemctl enable SoftBot.service
sudo systemctl start SoftBot.service

If you don't want to have service You can run the bot with this code in the bot directory:

python main.py

THE END ;) NOW You need to edit the setup file for config the bot

Configration

for Setup and Configration

You need a Discord account and create a bot token for your project. You can follow the instructions from here to create a bot token.

You need to edit the setup.py file and enter the following information:

  • Your bot token
  • The username and password of your SoftEther VPN server
  • The list of hubs and cascades that you want to monitor
  • The Discord channel name that you want the bot to respond to
  • The input commands for checking all servers or clients
  • The hour that the bot sends status updates
  • The cooldown time for responses
sudo nano /bot/SoftBot/setup.py

after that

sudo systemctl restart SoftBot.service

Infomation

The bot will connect to your Discord server and start listening for messages in the specified channel. You can use the following commands to interact with the bot:

  • Type the name of a server (e.g. hubnumber1) to get the status of that server (online or offline).
  • Type the name of a client (e.g. *hubnumber1) to get information about clients on that server (name, expiry date, traffic).
  • Type servers to get the status of all servers.
  • Type client to get information about clients on all servers.

The bot will respond with a formatted message containing the requested information. For example:

User list of all servers:
Name: user1 Expiry: 2023/12/31 Traffic: 1 GB
Name: user2 Expiry: No expiry Traffic: 2 GB

or

Server is Online
['hubnumber1', 'hubnumber2', 'hubnumber5', 'hubnumber6']
or
Server is Offline
['hubnumber3', 'hubnumber4']

or

hubnumber1 is online

or

User list of hubnumber1:
Name: user1 Expiry: 2023/12/31 Traffic: 1 GB
Name: user2 Expiry: No expiry Traffic: 2 GB

The bot will also send status updates every 8 hours (or as specified in the setup.py file) in the channel.

Translate

Click here for details
sudo nano /bot/SoftBot/msg.py

You may translate the message into any language or format you like.

Uninstall

Click here for details
wget -O se-install https://raw.githubusercontent.com/Pink210/SoftBot/main/uninstall.bash  && chmod +x se-install && ./se-install

Acknowledgements

This project was inspired by this tutorial on how to create a Discord bot using Python. I also used this documentation for the SoftEther VPN server API. I would like to thank the authors of these resources for their helpful guidance.

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.