From f36c73b30b10a01df1c0e9d44d38140742362cab Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 26 Nov 2022 20:18:42 -0500 Subject: [PATCH 1/3] Sledgehammer config approach --- BotResources.py | 28 ++++++++++++++++------------ main.py | 4 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/BotResources.py b/BotResources.py index ea8e993..027cfc6 100644 --- a/BotResources.py +++ b/BotResources.py @@ -53,20 +53,24 @@ def read_config_file(): config = configparser.ConfigParser() config.read('./config.ini') - config_return = { - 'Bot Token': config['Bot_Info']['Token'], - 'Device ID': int(config['Device']['ID']), - 'Device Name': str(config['Device']['Name']), - 'Mention Group': str(config['Bot_Info']['Mention_Group']), - 'Channel ID': int(config['Bot_Info']['Channel_ID']), - 'Handler': str(config['Config']['Handler']) - } + try: + config_return = { + 'Bot Token': config['Bot_Info']['Token'], + 'Device ID': int(config['Device']['ID']), + 'Device Name': str(config['Device']['Name']), + 'Mention Group': str(config['Bot_Info']['Mention_Group']), + 'Channel ID': int(config['Bot_Info']['Channel_ID']), + 'Handler': str(config['Config']['Handler']) + } - LOGGER.debug("Found config options:") - for key in config_return.keys(): - LOGGER.debug(f"\t{key} : {config_return[key]}") + LOGGER.debug("Found config options:") + for key in config_return.keys(): + LOGGER.debug(f"\t{key} : {config_return[key]}") - return config_return + return config_return + except Exception as err: + LOGGER.warning(err) + return None def write_config_file(**kwargs): diff --git a/main.py b/main.py index 88aa9af..00825ed 100644 --- a/main.py +++ b/main.py @@ -39,6 +39,10 @@ def main(**passed_config): config = BotResources.read_config_file() + if not config: + LOGGER.warning("No config file exists, please enter this information now") + BotResources.write_config_file(init=True) + # Overwrite config options if they were passed if len(passed_config.keys()) == 0: for sub in config: From 71a8914ac755b5a9117cae68ae01158820c859da Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 26 Nov 2022 20:51:40 -0500 Subject: [PATCH 2/3] Updated requirements.txt --- requirements.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/requirements.txt b/requirements.txt index 45d8f2e..87746ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ -discord~=1.7.3 -numpy==1.22.3 -scipy==1.8.0 -matplotlib~=3.5.1 -pyrtlsdr~=0.2.92 -PyAudio~=0.2.11 +discord==2.1.0 +numpy==1.23.5 +PyAudio==0.2.12 +sounddevice==0.4.5 From c6d120982d0ec90ce0e929b0981ced0547cc70b6 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sat, 26 Nov 2022 20:51:25 -0500 Subject: [PATCH 3/3] Cherry pick 'Update to use intents' to remove NGv2 sections --- bot.py | 13 ++++++++++++- main.py | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index 94e4fab..6b31e92 100644 --- a/bot.py +++ b/bot.py @@ -14,9 +14,11 @@ class Bot(commands.Bot): def __init__(self, **kwargs): # If there is no custom command prefix (!help, ?help, etc.), use '>!' but also accept @ mentions if 'command_prefix' not in kwargs.keys(): + bot_intents = set_server_intents() kwargs['command_prefix'] = '>!' commands.Bot.__init__(self, command_prefix=commands.when_mentioned_or(kwargs['command_prefix']), - activity=discord.Game(name=f"@ me"), status=discord.Status.idle) + activity=discord.Game(name=f"@ me"), status=discord.Status.idle, + intents=bot_intents) # Create the logger for the bot self.logger = logging.getLogger("Discord_Radio_Bot.Bot") @@ -580,3 +582,12 @@ class Bot(commands.Bot): message_body += f"\tSquelch:\t\t\t\t{config[section]['Squelch']}\n" return message_body + + +# Set discord intents and return the intent object +def set_server_intents(): + bot_intents = discord.Intents.default() + #bot_intents.messages = True + #bot_intents.message_content = True + #bot_intents.members = True + return bot_intents \ No newline at end of file diff --git a/main.py b/main.py index 00825ed..caf4990 100644 --- a/main.py +++ b/main.py @@ -42,6 +42,7 @@ def main(**passed_config): if not config: LOGGER.warning("No config file exists, please enter this information now") BotResources.write_config_file(init=True) + config = BotResources.read_config_file() # Overwrite config options if they were passed if len(passed_config.keys()) == 0: