Bot Changes
- Improved handlers
- Added new function to use the newly set or loaded settings
- Any change to frequency, squelch, mode, or noisegate threshold will show no profile
    - The user is responsible for saving their changes

Readme Changes
- Update with notes on the bot change above
This commit is contained in:
Logan Cusano
2022-04-09 02:21:53 -04:00
parent 2dabf1c98d
commit 63b37d14cb
2 changed files with 30 additions and 15 deletions

View File

@@ -23,4 +23,9 @@ Voicemeeter is **highly** recommended for this bot. See a detailed guide on how
To change the audio source, simply delete the ```config.ini``` that was generated and restart the bot.
It will re-do the setup and allow you to select a new device.
### [To-Do](https://git.vpn.cusano.net/Discord_Bot_Gang/Discord-Radio-Bot/src/branch/master/TODO.md)
### [To-Do](https://git.vpn.cusano.net/Discord_Bot_Gang/Discord-Radio-Bot/src/branch/master/TODO.md)
**Notes for readme leter on**
- Users need to save profile after any change in discord
-

38
bot.py
View File

@@ -173,8 +173,12 @@ class Bot(commands.Bot):
f"{self.streamHandler.THRESHOLD} to {_threshold}")
self.streamHandler.THRESHOLD = _threshold
self.noisegate_sensitivity = _threshold
if self.sdr_started:
await self.set_activity()
# Reset the profile name since we have made a change
self.profile_name = None
# If the SDR is started, restart it with the updates
self.use_current_radio_config()
# Add commands for GQRX and OP25
if self.Handler in BotResources.PDB_ACCEPTABLE_HANDLERS.keys():
@@ -225,13 +229,11 @@ class Bot(commands.Bot):
await ctx.send(f"Ok {str(member).capitalize()}, I'm changing the mode to "
f"{str(self.mode).upper()} and frequency to {self.freq}")
# Reset the profile name since we have made a change to the freq
# Reset the profile name since we have made a change
self.profile_name = None
# If the SDR is started, restart it with the updates
if self.sdr_started:
self.start_sdr()
await self.set_activity()
self.use_current_radio_config()
else:
await ctx.send(f"{str(member).capitalize()}, {mode} is not valid."
f" You may only enter {self.possible_modes}")
@@ -254,9 +256,11 @@ class Bot(commands.Bot):
self.squelch = squelch
await ctx.send(f"Ok {str(member).capitalize()}, I'm changing the squelch to {self.squelch}")
# Reset the profile name since we have made a change
self.profile_name = None
# If the SDR is started, restart it with the updates
if self.sdr_started:
self.start_sdr()
self.use_current_radio_config()
# Hidden admin commands
@self.command(name='saveprofile', hidden=True)
@@ -505,8 +509,19 @@ class Bot(commands.Bot):
self.profile_name = profile_name
self.use_current_radio_config()
def use_current_radio_config(self):
if self.sdr_started:
self.start_sdr()
# Set the loaded profile settings into GQRX
if self.Handler == "gqrx":
self.GQRXHandler.set_gqrx_parameters(_frequency=self.freq, _squelch=self.squelch,
_fm_mode=self.mode)
# Restart OP25 to use the loaded profile
if self.Handler == "op25":
self.start_sdr()
# Set the activity to reflect the loaded profile
await self.set_activity()
# Load a saved profile into the current settings
@@ -528,11 +543,6 @@ class Bot(commands.Bot):
f"{BotResources.DEFAULT_NOISEGATE_THRESHOLD}")
self.noisegate_sensitivity = BotResources.DEFAULT_NOISEGATE_THRESHOLD
await self.save_radio_config(self.profile_name)
if self.sdr_started:
self.start_sdr()
await self.set_activity()
return True
else:
return False