Compare commits
205 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cea0f901f | |||
|
|
c6d120982d | ||
|
|
71a8914ac7 | ||
|
|
f36c73b30b | ||
| b2a73726a0 | |||
|
|
a094ba581d | ||
|
|
62f9e1abaa | ||
|
|
e4e04e429f | ||
|
|
0db4f62afc | ||
|
|
4d5c1183d6 | ||
|
|
9dba89a60b | ||
|
|
dcf0de8351 | ||
|
|
bfb049e268 | ||
|
|
b0d83def35 | ||
|
|
8af7a70b65 | ||
|
|
8d090c5c67 | ||
|
|
35e19ee83f | ||
|
|
44d027ab8c | ||
|
|
31d5f8139c | ||
|
|
3837f7abd6 | ||
|
|
b7f0939787 | ||
|
|
cccd974adc | ||
|
|
f4b14c26fc | ||
|
|
a483f83b4b | ||
|
|
458ab5be95 | ||
|
|
dbbd5b6fe3 | ||
|
|
63b37d14cb | ||
|
|
2dabf1c98d | ||
|
|
5551aa6355 | ||
|
|
7ee5d92852 | ||
|
|
5a3729627b | ||
|
|
e4201a2746 | ||
|
|
bb56566d37 | ||
|
|
35e90aa290 | ||
|
|
99ec1d07aa | ||
|
|
bbca25ce3f | ||
|
|
676936eb6f | ||
|
|
8debd690f1 | ||
|
|
5d1a58ee87 | ||
|
|
fd62da0c6f | ||
|
|
b972d09a65 | ||
|
|
21aacde130 | ||
|
|
e26ae52399 | ||
|
|
319de5cf42 | ||
| 5e6b6f02d9 | |||
|
|
25ad3b076c | ||
|
|
d3a18c2421 | ||
|
|
6170719233 | ||
|
|
c8503c856e | ||
|
|
471f668cdb | ||
|
|
579987d571 | ||
|
|
6efca8f0fa | ||
|
|
9e60444bc6 | ||
|
|
9280278ca7 | ||
|
|
c07220f434 | ||
|
|
d650ae4350 | ||
|
|
cbeb90a0f4 | ||
|
|
5c0d0f1f7b | ||
|
|
6135bd81de | ||
|
|
dc178e54af | ||
|
|
f124853332 | ||
|
|
331753ccbf | ||
|
|
fd8fb1ab3d | ||
|
|
5b2d0f9135 | ||
|
|
1357a0509c | ||
|
|
ac4e4349df | ||
|
|
9af6fc254c | ||
|
|
c1ecd092c6 | ||
|
|
34c5fe9c5b | ||
|
|
65b0f25921 | ||
| a8fbd094e1 | |||
|
|
834a74c7f0 | ||
|
|
d2bf7822cf | ||
|
|
22d36c5f19 | ||
|
|
a9cfa89655 | ||
|
|
44e0941a6a | ||
|
|
e6d4c9f467 | ||
|
|
acc76db5f9 | ||
|
|
1ed5436138 | ||
|
|
f8f6cb7e52 | ||
|
|
458d8d12a4 | ||
|
|
319e92b897 | ||
|
|
997c24949b | ||
|
|
326da757cf | ||
|
|
c741288b87 | ||
| d97e51d960 | |||
|
|
8c5cc65a50 | ||
|
|
63ca0fec63 | ||
|
|
8e191531d0 | ||
|
|
83c2971742 | ||
|
|
1a705c2b6c | ||
|
|
3a2d9531f9 | ||
|
|
54e3a3a116 | ||
|
|
0d32d3fa7e | ||
|
|
05e81aea1d | ||
|
|
69c7d4d548 | ||
|
|
79c651be30 | ||
|
|
4eb73c3832 | ||
|
|
f90c84184a | ||
|
|
831c19e7e1 | ||
|
|
97aed314ba | ||
|
|
f64a3dc517 | ||
|
|
5d7a3b2d0b | ||
|
|
0c53e58fab | ||
|
|
8c7075b76c | ||
|
|
dd9643363b | ||
|
|
7cca55a836 | ||
|
|
5fe98bfe0e | ||
|
|
6049af3a25 | ||
|
|
c03521de7f | ||
|
|
e5b3359571 | ||
|
|
492026ed8c | ||
|
|
61f113c475 | ||
|
|
bbe461255a | ||
|
|
7d161baeda | ||
|
|
f68e794d02 | ||
|
|
9986eadaaf | ||
|
|
404ddfc773 | ||
|
|
f94a900c44 | ||
|
|
721ef932ce | ||
|
|
4ab14d2e5d | ||
|
|
9635e11434 | ||
|
|
8fa42d819a | ||
|
|
5a8efa8884 | ||
|
|
e0dba3be4e | ||
|
|
4e839eecb4 | ||
|
|
81dc305197 | ||
|
|
203bee0734 | ||
|
|
7e2cf932dc | ||
|
|
102e0ae473 | ||
|
|
33ea596ab4 | ||
|
|
f965c5de05 | ||
|
|
0bc0d8e031 | ||
|
|
92ab4992cb | ||
|
|
da29c0eaaa | ||
|
|
30d539312e | ||
|
|
9a225010be | ||
|
|
92bd4ffb1f | ||
|
|
bf8adda80b | ||
|
|
f239e87b0a | ||
|
|
136009c07e | ||
|
|
5efb44164a | ||
|
|
6fd30b9609 | ||
|
|
c1084deadf | ||
|
|
cf79050b96 | ||
|
|
22d6d5d3d7 | ||
|
|
24adc47109 | ||
|
|
0329ff7a81 | ||
|
|
48f6812f68 | ||
|
|
b444236dc9 | ||
|
|
287eb0e981 | ||
|
|
7a9dbfb53a | ||
|
|
a13cf36e15 | ||
|
|
465c0e00ea | ||
|
|
12aa4d6f51 | ||
|
|
2dacab263b | ||
|
|
126ba907af | ||
|
|
4f230f8d33 | ||
|
|
1257b713fc | ||
|
|
4f7ec14807 | ||
|
|
ec7880ed1e | ||
|
|
e4cb8647ee | ||
|
|
a205bd2d8a | ||
|
|
8355b98da5 | ||
|
|
c3fb20f12e | ||
|
|
5ebbaca54b | ||
|
|
efe8eda66f | ||
|
|
9f4473ffcc | ||
|
|
759f05eb0c | ||
|
|
0d51b47146 | ||
|
|
ff26cbc0b1 | ||
|
|
9456b91d09 | ||
|
|
b534e2b731 | ||
| fdeb337ca5 | |||
|
|
56a3bdd0ea | ||
|
|
830d299a01 | ||
| 676969a8fe | |||
|
|
760ebd7e43 | ||
|
|
c564a145b5 | ||
|
|
db0922bf68 | ||
|
|
897e53d4c0 | ||
|
|
a1f9869e8e | ||
|
|
73fa560040 | ||
|
|
1f30e05e46 | ||
|
|
56ee57e96a | ||
|
|
5cc8a8c118 | ||
| 26909bce0f | |||
| fc1a742933 | |||
|
|
78d9b9e307 | ||
|
|
ba237d2d53 | ||
|
|
6ad489183f | ||
|
|
b721fa3df4 | ||
|
|
7682d8c72c | ||
|
|
706f4a31df | ||
|
|
7fa11a4abe | ||
|
|
17c528c153 | ||
|
|
f9594e2afe | ||
|
|
167c06f331 | ||
|
|
137d0ae097 | ||
|
|
002288d632 | ||
|
|
59a3ca22ea | ||
|
|
fdb9bb519c | ||
|
|
a5f0a4b193 | ||
|
|
62968654d2 | ||
|
|
a3a592d854 |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,12 +1,12 @@
|
||||
/.idea/
|
||||
/Releases/
|
||||
/Old/
|
||||
/__pycache__/
|
||||
*/__pycache__/
|
||||
/venv/
|
||||
**/__pycache__/
|
||||
**/venv/
|
||||
*.7z
|
||||
*.bat
|
||||
/DSDPlus/
|
||||
._.DS_Store
|
||||
**/._.DS_Store
|
||||
*.log
|
||||
*.ini
|
||||
**/logs/*
|
||||
149
BotResources.py
149
BotResources.py
@@ -1,9 +1,40 @@
|
||||
import sound
|
||||
import configparser
|
||||
import logging
|
||||
import os
|
||||
from datetime import date
|
||||
from os.path import exists
|
||||
from NoiseGatev2 import AudioStream
|
||||
|
||||
PDB_ACCEPTABLE_HANDLERS = ['gqrx', 'op25']
|
||||
PDB_KNOWN_BOT_IDS = [756327271597473863, 915064996994633729, 943742040255115304]
|
||||
# Handler configs
|
||||
PDB_ACCEPTABLE_HANDLERS = {'gqrx': {
|
||||
'Modes': ['wfm', 'fm']
|
||||
},
|
||||
'op25': {
|
||||
'Modes': ['d', 'p25']
|
||||
}}
|
||||
|
||||
# Known bot IDs
|
||||
PDB_KNOWN_BOT_IDS = {756327271597473863: "Greada", 915064996994633729: "Jorn", 943742040255115304: "Brent"}
|
||||
|
||||
# Default value to set noisegate on new or unknown profiles
|
||||
DEFAULT_NOISEGATE_THRESHOLD = 50
|
||||
|
||||
# Initialize the logger for this file
|
||||
LOGGER = logging.getLogger('Discord_Radio_Bot.Bot_Resources')
|
||||
|
||||
# Location of the gqrx binary
|
||||
GQRX_BIN_LOCATION = "/usr/bin/"
|
||||
GQRX_BIN = "/usr/bin/gqrx"
|
||||
|
||||
|
||||
# Default radio settings
|
||||
DEFAULT_RADIO_SETTINGS = {
|
||||
'profile_name': None,
|
||||
'freq': "104700000",
|
||||
'mode': "wfm",
|
||||
'squelch': 0,
|
||||
'noisegate_sensitivity': DEFAULT_NOISEGATE_THRESHOLD,
|
||||
}
|
||||
|
||||
|
||||
def check_if_config_exists():
|
||||
@@ -22,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'])
|
||||
}
|
||||
|
||||
print("Found config options:")
|
||||
for key in config_return.keys():
|
||||
print(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):
|
||||
@@ -84,14 +119,14 @@ def write_config_file(**kwargs):
|
||||
with open('./config.ini', 'w') as config_file:
|
||||
config.write(config_file)
|
||||
|
||||
print("Config Saved")
|
||||
LOGGER.info("Config Saved")
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_device_list():
|
||||
list_of_devices = sound.query_devices().items()
|
||||
print(list_of_devices)
|
||||
list_of_devices = AudioStream().list_devices()
|
||||
LOGGER.debug(list_of_devices)
|
||||
return list_of_devices
|
||||
|
||||
|
||||
@@ -99,38 +134,38 @@ def get_user_device_selection():
|
||||
device_list = get_device_list()
|
||||
org_device_list = []
|
||||
for device, dev_id in device_list:
|
||||
print(f"{dev_id + 1}\t-\t{device}")
|
||||
LOGGER.debug(f"{dev_id + 1}\t-\t{device}")
|
||||
org_device_list.append((dev_id, device))
|
||||
selected_list_id = None
|
||||
selected_device = None
|
||||
while not selected_list_id:
|
||||
print(f"selected device: {selected_list_id}")
|
||||
print(device_list)
|
||||
LOGGER.debug(f"selected device: {selected_list_id}")
|
||||
LOGGER.debug(device_list)
|
||||
|
||||
try:
|
||||
selected_list_id = int(input(f"Please select the input device from above:\t"))
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
LOGGER.warning(e)
|
||||
continue
|
||||
|
||||
if int(selected_list_id) < int(len(device_list)):
|
||||
print("ford")
|
||||
LOGGER.debug("Selected ID within range")
|
||||
continue
|
||||
elif selected_list_id > int(len(device_list)):
|
||||
print("Out of range, try again...")
|
||||
LOGGER.debug("Out of range, try again...")
|
||||
selected_list_id = None
|
||||
continue
|
||||
else:
|
||||
selected_list_id = None
|
||||
print("Internal error, try again")
|
||||
LOGGER.error("Internal error, try again")
|
||||
continue
|
||||
|
||||
for dev_dict in org_device_list:
|
||||
print(list(device_list)[selected_list_id-1][0])
|
||||
LOGGER.debug(list(device_list)[selected_list_id-1][0])
|
||||
if dev_dict[1] == list(device_list)[selected_list_id-1][0]:
|
||||
selected_device = dev_dict
|
||||
print(selected_device)
|
||||
LOGGER.debug(selected_device)
|
||||
|
||||
return selected_device
|
||||
|
||||
@@ -142,7 +177,7 @@ def get_user_token():
|
||||
if len(token) == 59:
|
||||
return token
|
||||
else:
|
||||
print('Length error in token, please try again...')
|
||||
LOGGER.error('Length error in token, please try again...')
|
||||
token = None
|
||||
continue
|
||||
|
||||
@@ -161,7 +196,7 @@ def get_user_mention_channel_id():
|
||||
if len(str(channel_id)) == len('757379843792044102'):
|
||||
return channel_id
|
||||
else:
|
||||
print("Length error in ID, please try again")
|
||||
LOGGER.error("Length error in ID, please try again")
|
||||
channel_id = None
|
||||
continue
|
||||
|
||||
@@ -172,7 +207,8 @@ def get_handler():
|
||||
handler = str(input(f"Please enter the name of the handler you would like to use:\t"))
|
||||
if handler in PDB_ACCEPTABLE_HANDLERS:
|
||||
return handler
|
||||
elif handler == '':
|
||||
elif handler == ['', "none"]:
|
||||
handler = "None"
|
||||
return handler
|
||||
|
||||
|
||||
@@ -185,3 +221,56 @@ def check_negative(s):
|
||||
return False
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
# Check if message is a ping request and respond even if it is a bot
|
||||
async def check_and_reply_to_ping(bot, message):
|
||||
if "check_modules" in message.content:
|
||||
ctx = await bot.get_context(message)
|
||||
await bot.invoke(ctx)
|
||||
return True
|
||||
else:
|
||||
await bot.process_commands(message)
|
||||
return False
|
||||
|
||||
|
||||
# Create the logger
|
||||
def init_global_logger(_verbose_level: str = "WARNING"):
|
||||
numeric_log_level = getattr(logging, _verbose_level.upper(), None)
|
||||
if not isinstance(numeric_log_level, int):
|
||||
raise ValueError('Invalid log level: %s' % _verbose_level)
|
||||
else:
|
||||
# create logger
|
||||
init_logger = logging.getLogger('Discord_Radio_Bot')
|
||||
init_logger.setLevel(logging.DEBUG)
|
||||
|
||||
# create file handler which logs even debug messages
|
||||
if not exists("./logs/"):
|
||||
os.mkdir("./logs/")
|
||||
fh = logging.FileHandler(f'./logs/DRB-{date.today()}.log')
|
||||
fh.setLevel(logging.INFO)
|
||||
|
||||
fh_debug = logging.FileHandler(f'./logs/DRB-{date.today()}.DEBUG.log')
|
||||
fh_debug.setLevel(logging.DEBUG)
|
||||
|
||||
# create terminal handler with a higher log level
|
||||
th = logging.StreamHandler()
|
||||
th.setLevel(numeric_log_level)
|
||||
|
||||
# create formatter and add it to the handlers
|
||||
fh_debug_formatter = logging.Formatter('[%(asctime)s %(name)s->%(funcName)s():%(lineno)s] - %(levelname)s - %(message)s')
|
||||
fh_formatter = logging.Formatter('[%(asctime)s %(name)s->%(funcName)s()] - %(levelname)s - %(message)s')
|
||||
th_formatter = logging.Formatter('[%(asctime)s %(name)s->%(funcName)s()] - %(levelname)s - %(message)s')
|
||||
fh_debug.setFormatter(fh_debug_formatter)
|
||||
fh.setFormatter(fh_formatter)
|
||||
th.setFormatter(th_formatter)
|
||||
|
||||
# add the handlers to the logger
|
||||
init_logger.addHandler(fh)
|
||||
init_logger.addHandler(th)
|
||||
init_logger.addHandler(fh_debug)
|
||||
|
||||
|
||||
#if __name__ is not 'main':
|
||||
# init_global_logger()
|
||||
# LOGGER = logging.getLogger('Discord_Radio_Bot')
|
||||
|
||||
67
NoiseGate.py
67
NoiseGate.py
@@ -1,67 +0,0 @@
|
||||
import threading
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
import discord
|
||||
import sounddevice as sd
|
||||
from threading import Thread, Event
|
||||
|
||||
noise_gate_trigger = 0 # Set this value for the trigger on the noise-gate
|
||||
voice_connection = None
|
||||
audio_stream = None
|
||||
last_callback_value = 0
|
||||
|
||||
|
||||
class NoiseGate(Thread):
|
||||
def __init__(self, trigger_value: int = 700):
|
||||
global noise_gate_trigger
|
||||
super(NoiseGate, self).__init__()
|
||||
self.stream = None
|
||||
self.stop_NG = threading.Event()
|
||||
self.NG_Started = threading.Event()
|
||||
noise_gate_trigger = trigger_value
|
||||
|
||||
def init_stream(self, num, _voice_connection, _audio_stream):
|
||||
global voice_connection, audio_stream
|
||||
self.stream = sd.InputStream(device=num, callback=stream_callback)
|
||||
voice_connection = _voice_connection
|
||||
audio_stream = _audio_stream
|
||||
|
||||
def run(self) -> None:
|
||||
self.NG_Started.set()
|
||||
self.stream.start()
|
||||
while not self.stop_NG.is_set():
|
||||
#print("Main loop start")
|
||||
if last_callback_value >= noise_gate_trigger:
|
||||
trigger_noise_gate(True)
|
||||
while last_callback_value >= noise_gate_trigger:
|
||||
time.sleep(6)
|
||||
trigger_noise_gate(False)
|
||||
#print("Main loop end")
|
||||
|
||||
self.stream.stop()
|
||||
self.stream.close()
|
||||
self.NG_Started.clear()
|
||||
voice_connection.stop()
|
||||
print('Thread #%s stopped' % self.ident)
|
||||
|
||||
|
||||
def stream_callback(indata, *args):
|
||||
global last_callback_value
|
||||
volume_normalization = np.linalg.norm(indata) * 10
|
||||
last_callback_value = int(volume_normalization)
|
||||
#print(f"Callback Value: {last_callback_value}")
|
||||
|
||||
|
||||
def trigger_noise_gate(triggered: bool):
|
||||
if triggered:
|
||||
if not voice_connection.is_playing():
|
||||
voice_connection.play(discord.PCMAudio(audio_stream))
|
||||
# print("|" * int(volume_normalization / 4))
|
||||
print("Noise Gate was Triggered")
|
||||
#time.sleep(10)
|
||||
else:
|
||||
if voice_connection.is_playing():
|
||||
print("Noise Gate stopped")
|
||||
voice_connection.pause()
|
||||
# try disconnecting and reconnecting
|
||||
214
NoiseGatev2.py
Normal file
214
NoiseGatev2.py
Normal file
@@ -0,0 +1,214 @@
|
||||
import audioop
|
||||
import logging
|
||||
import math
|
||||
import time
|
||||
|
||||
import pyaudio
|
||||
import discord
|
||||
import numpy
|
||||
|
||||
voice_connection = None
|
||||
|
||||
LOGGER = logging.getLogger("Discord_Radio_Bot.NoiseGateV2")
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
class AudioStream:
|
||||
def __init__(self, _channels: int = 2, _sample_rate: int = 48000, _frames_per_buffer: int = 1024,
|
||||
_input_device_index: int = None, _output_device_index: int = None, _input: bool = True,
|
||||
_output: bool = True, _init_on_startup: bool = True):
|
||||
self.paInstance_kwargs = {
|
||||
'format': pyaudio.paInt16,
|
||||
'channels': _channels,
|
||||
'rate': _sample_rate,
|
||||
'input': _input,
|
||||
'output': _output,
|
||||
'frames_per_buffer': _frames_per_buffer
|
||||
}
|
||||
|
||||
if _input_device_index:
|
||||
if _input:
|
||||
self.paInstance_kwargs['input_device_index'] = _input_device_index
|
||||
else:
|
||||
LOGGER.warning(f"[AudioStream.__init__]:\tInput was not enabled."
|
||||
f" Reinitialize with '_input=True'")
|
||||
|
||||
if _output_device_index:
|
||||
if _output:
|
||||
self.paInstance_kwargs['output_device_index'] = _output_device_index
|
||||
else:
|
||||
LOGGER.warning(f"[AudioStream.__init__]:\tOutput was not enabled."
|
||||
f" Reinitialize with '_output=True'")
|
||||
|
||||
if _init_on_startup:
|
||||
# Init PyAudio instance
|
||||
LOGGER.info("Creating PyAudio instance")
|
||||
self.paInstance = pyaudio.PyAudio()
|
||||
|
||||
# Define and initialize stream object if we have been passed a device ID (pyaudio.open)
|
||||
self.stream = None
|
||||
|
||||
if _output_device_index or _input_device_index:
|
||||
if _init_on_startup:
|
||||
LOGGER.info("Init stream")
|
||||
self.init_stream()
|
||||
|
||||
def init_stream(self, _new_output_device_index: int = None, _new_input_device_index: int = None):
|
||||
# Check what device was asked to be changed (or set)
|
||||
if _new_input_device_index:
|
||||
if self.paInstance_kwargs['input']:
|
||||
self.paInstance_kwargs['input_device_index'] = _new_input_device_index
|
||||
else:
|
||||
LOGGER.warning(f"[AudioStream.init_stream]:\tInput was not enabled when initialized."
|
||||
f" Reinitialize with '_input=True'")
|
||||
|
||||
if _new_output_device_index:
|
||||
if self.paInstance_kwargs['output']:
|
||||
self.paInstance_kwargs['output_device_index'] = _new_output_device_index
|
||||
else:
|
||||
LOGGER.warning(f"[AudioStream.init_stream]:\tOutput was not enabled when initialized."
|
||||
f" Reinitialize with '_output=True'")
|
||||
|
||||
self.close_if_open()
|
||||
|
||||
# Open the stream
|
||||
self.stream = self.paInstance.open(**self.paInstance_kwargs)
|
||||
|
||||
def close_if_open(self):
|
||||
# Stop the stream if it is started
|
||||
if self.stream:
|
||||
if self.stream.is_active():
|
||||
self.stream.stop_stream()
|
||||
self.stream.close()
|
||||
LOGGER.debug(f"[ReopenStream.close_if_open]:\t Stream was open; It was closed.")
|
||||
|
||||
def list_devices(self, _display_input_devices: bool = True, _display_output_devices: bool = True):
|
||||
info = self.paInstance.get_host_api_info_by_index(0)
|
||||
numdevices = info.get('deviceCount')
|
||||
|
||||
devices = {
|
||||
'Input': {},
|
||||
'Output': {}
|
||||
}
|
||||
for i in range(0, numdevices):
|
||||
if (self.paInstance.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
||||
input_device = self.paInstance.get_device_info_by_host_api_device_index(0, i).get('name')
|
||||
devices['Input'][i] = input_device
|
||||
if _display_input_devices:
|
||||
LOGGER.debug("Input Device id ", i, " - ", input_device)
|
||||
|
||||
if (self.paInstance.get_device_info_by_host_api_device_index(0, i).get('maxOutputChannels')) > 0:
|
||||
output_device = self.paInstance.get_device_info_by_host_api_device_index(0, i).get('name')
|
||||
devices['Output'][i] = output_device
|
||||
if _display_output_devices:
|
||||
LOGGER.debug("Output Device id ", i, " - ", output_device)
|
||||
|
||||
return devices
|
||||
|
||||
async def stop(self):
|
||||
await voice_connection.disconnect()
|
||||
self.close_if_open()
|
||||
self.stream.close()
|
||||
self.paInstance.terminate()
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
class NoiseGate(AudioStream):
|
||||
def __init__(self, _voice_connection, _noise_gate_threshold: int, **kwargs):
|
||||
super(NoiseGate, self).__init__(_init_on_startup=True, **kwargs)
|
||||
global voice_connection
|
||||
voice_connection = _voice_connection
|
||||
self.THRESHOLD = _noise_gate_threshold
|
||||
self.NGStream = NoiseGateStream(self)
|
||||
self.Voice_Connection_Thread = None
|
||||
|
||||
def run(self) -> None:
|
||||
global voice_connection
|
||||
# Start the audio stream
|
||||
LOGGER.debug(f"Starting stream")
|
||||
self.stream.start_stream()
|
||||
# Start the stream to discord
|
||||
self.core()
|
||||
|
||||
def core(self, error=None):
|
||||
if error:
|
||||
LOGGER.warning(error)
|
||||
|
||||
while not voice_connection.is_connected():
|
||||
time.sleep(.2)
|
||||
|
||||
if not voice_connection.is_playing():
|
||||
LOGGER.debug(f"Playing stream to discord")
|
||||
voice_connection.play(self.NGStream, after=self.core)
|
||||
|
||||
async def close(self):
|
||||
LOGGER.debug(f"Closing")
|
||||
await voice_connection.disconnect()
|
||||
if self.stream.is_active:
|
||||
self.stream.stop_stream()
|
||||
LOGGER.debug(f"Stopping stream")
|
||||
|
||||
|
||||
# noinspection PyUnresolvedReferences
|
||||
class NoiseGateStream(discord.AudioSource):
|
||||
def __init__(self, _stream):
|
||||
super(NoiseGateStream, self).__init__()
|
||||
self.stream = _stream # The actual audio stream object
|
||||
self.NG_fadeout = 240/20 # Fadeout value used to hold the noisegate after de-triggering
|
||||
self.NG_fadeout_count = 0 # A count set when the noisegate is triggered and was de-triggered
|
||||
self.process_set_count = 0 # Counts how many processes have been made
|
||||
|
||||
def read(self):
|
||||
try:
|
||||
while voice_connection.is_connected():
|
||||
curr_buffer = bytearray(self.stream.stream.read(960))
|
||||
buffer_rms = audioop.rms(curr_buffer, 2)
|
||||
if buffer_rms > 0:
|
||||
buffer_decibel = 20 * math.log10(buffer_rms)
|
||||
|
||||
if self.process_set_count % 10 == 0:
|
||||
if buffer_decibel >= self.stream.THRESHOLD:
|
||||
LOGGER.debug(f"[Noisegate Open] {buffer_decibel} db")
|
||||
else:
|
||||
LOGGER.debug(f"[Noisegate Closed] {buffer_decibel} db")
|
||||
|
||||
if buffer_decibel >= self.stream.THRESHOLD:
|
||||
self.NG_fadeout_count = self.NG_fadeout
|
||||
self.process_set_count += 1
|
||||
if curr_buffer:
|
||||
return bytes(curr_buffer)
|
||||
|
||||
else:
|
||||
if self.NG_fadeout_count > 0:
|
||||
self.NG_fadeout_count -= 1
|
||||
LOGGER.debug(f"Frames in fadeout remaining: {self.NG_fadeout_count}")
|
||||
self.process_set_count += 1
|
||||
if curr_buffer:
|
||||
return bytes(curr_buffer)
|
||||
|
||||
except OSError as e:
|
||||
LOGGER.warning(e)
|
||||
pass
|
||||
|
||||
def audio_datalist_set_volume(self, datalist, volume):
|
||||
""" Change value of list of audio chunks """
|
||||
sound_level = (volume / 100.)
|
||||
|
||||
for i in range(len(datalist)):
|
||||
chunk = numpy.fromstring(datalist[i], numpy.int16)
|
||||
|
||||
chunk = chunk * sound_level
|
||||
|
||||
datalist[i] = chunk.astype(numpy.int16)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
input_index = int(input("Input:\t"))
|
||||
output_index = int(input("Output:\t"))
|
||||
|
||||
ng = NoiseGate(_input_device_index=input_index, _output_device_index=output_index)
|
||||
|
||||
ng.list_devices()
|
||||
|
||||
ng.start()
|
||||
16
README.md
16
README.md
@@ -9,10 +9,11 @@ This project is intended to allow users in discord to be able to listen to their
|
||||
|
||||
## Setup
|
||||
1. Install the pip packages found in the ```Requirements.txt``` file
|
||||
2. Run ```main.py``` with Python
|
||||
3. Follow the prompts in the terminal
|
||||
4. Ensure your audio is playing on the selected device
|
||||
5. You're all set! Ask the bot to join!
|
||||
- *Optional if you are using OP25* Run `echo 0 > /sys/module/usbcore/parameters/usbfs_memory_mb`
|
||||
3. Run ```main.py``` with Python
|
||||
4. Follow the prompts in the terminal
|
||||
5. Ensure your audio is playing on the selected device
|
||||
5You're all set! Ask the bot to join!
|
||||
|
||||
### Understanding Audio Input
|
||||
This title can be a bit confusing. The bot will display both 'input' and 'output' devices but not always *all* devices connected.
|
||||
@@ -22,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
|
||||
-
|
||||
46
TODO.md
46
TODO.md
@@ -1,20 +1,48 @@
|
||||
## To-Do
|
||||
### Main Bot
|
||||
# To-Do
|
||||
## Main Bot
|
||||
### Main Development
|
||||
#### Core
|
||||
- [ ] Add new handlers for GQRX: https://github.com/gqrx-sdr/gqrx/blob/master/resources/remote-control.txt
|
||||
- [ ] Add logging for Elasticstack https://www.elastic.co/guide/en/ecs-logging/python/master/installation.html
|
||||
- [ ] Add a process handler to start/stop gqrx
|
||||
- [ ] Fix the bug where they *disconnect* after a period of time and must be manually moved out and back in to hear them
|
||||
- *May* have been fixed with the noise gate?
|
||||
- [ ] Fix bug that shows different index number for audio device selection on linux
|
||||
- [ ] New bug on linux shows a bunch of ALSA output
|
||||
- [x] Add more proper help text with real examples for discord commands
|
||||
- [ ] Add command line args with argparse for main bot
|
||||
- [ ] Add method for user to change audio device without redoing entire config file
|
||||
- [x] Add command line args with argparse for main bot
|
||||
- [x] Add method for user to change audio device without redoing entire config file
|
||||
- [ ] Need to create a method for the bot to toggle debug mode for OP25
|
||||
|
||||
#### Features
|
||||
- [ ] Add to a linux service
|
||||
- [ ] Add a function to the bot to allow *authorized* users to; update, restart, git pull, etc.
|
||||
|
||||
### Polishing
|
||||
- [ ] Clean up code
|
||||
- [ ] Transcode radio transmissions to text
|
||||
### Modules
|
||||
#### Willie Timer
|
||||
- [ ] Revise discord help text
|
||||
- [ ] Revise logging
|
||||
|
||||
### Final
|
||||
- [ ] Create setup script
|
||||
- [ ] Test setup
|
||||
- [ ] Revise readme
|
||||
|
||||
--------------------------------------------
|
||||
## Modules
|
||||
### Willie Timer
|
||||
- [ ] Revise the current loop, ensure it re-enters itself after triggering
|
||||
- [ ] Can we use a cron somehow?
|
||||
- [ ] Get more training data for WillieTimer
|
||||
- [ ] Use the ```Phrases.txt``` file as the random seed?
|
||||
- [ ] Figure out a way to give the model a suggestion
|
||||
- [ ] Figure out a way to give the model a suggestion
|
||||
|
||||
### Done Previously
|
||||
-------------------------------
|
||||
## Dreams
|
||||
- [ ] Transcode radio transmissions to text
|
||||
|
||||
---------------------
|
||||
## Done Previously
|
||||
- [x] Interact with soapysdr directly from the bot
|
||||
- [x] Allow chat interaction with soapysdr
|
||||
- [x] Move cogs to their own files
|
||||
|
||||
365
bot.py
365
bot.py
@@ -1,11 +1,11 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import discord
|
||||
|
||||
import BotResources
|
||||
import sound
|
||||
import configparser
|
||||
import NoiseGatev2
|
||||
from discord.ext import commands
|
||||
|
||||
|
||||
@@ -14,9 +14,14 @@ 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")
|
||||
|
||||
# Init the core bot variables
|
||||
self.DEVICE_ID = kwargs['Device_ID']
|
||||
@@ -34,13 +39,16 @@ class Bot(commands.Bot):
|
||||
self.Bot_Connected = False
|
||||
|
||||
# Init the audio devices list
|
||||
self.Devices_List = sound.query_devices().items()
|
||||
#self.Devices_List = sound.query_devices().items()
|
||||
self.Devices_List = NoiseGatev2.AudioStream().list_devices(_display_input_devices=False,
|
||||
_display_output_devices=False)
|
||||
|
||||
# Init radio parameters
|
||||
self.profile_name = None
|
||||
self.freq = "104700000"
|
||||
self.mode = "wfm"
|
||||
self.squelch = 0
|
||||
self.profile_name = BotResources.DEFAULT_RADIO_SETTINGS['profile_name']
|
||||
self.freq = BotResources.DEFAULT_RADIO_SETTINGS['freq']
|
||||
self.mode = BotResources.DEFAULT_RADIO_SETTINGS['mode']
|
||||
self.squelch = BotResources.DEFAULT_RADIO_SETTINGS['squelch']
|
||||
self.noisegate_sensitivity = BotResources.DEFAULT_RADIO_SETTINGS['noisegate_sensitivity']
|
||||
|
||||
# Init SDR Variables
|
||||
self.system_os_type = None
|
||||
@@ -64,17 +72,23 @@ class Bot(commands.Bot):
|
||||
|
||||
# Add discord commands to the bot
|
||||
def add_commands(self):
|
||||
# Test command to see if the bot is on (help command can also be used)
|
||||
@self.command(help="Use this to test if the bot is alive", brief="Sends a 'pong' in response")
|
||||
async def ping(ctx):
|
||||
if ctx.author.id != self.user.id:
|
||||
await ctx.send('pong')
|
||||
# Command to display what channel the bot is in
|
||||
@self.command(help="Use this command to display what channel the bot is in",
|
||||
brief="Where ya at?")
|
||||
async def wya(ctx, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
if self.Bot_Connected:
|
||||
await ctx.send(f"Hey {str(member).capitalize()}, I'm in {ctx.voice_client.channel}")
|
||||
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, I am not in any channel.")
|
||||
|
||||
# Command to join the bot the voice channel the user who called the command is in
|
||||
@self.command(help="Use this command to join the bot to your channel",
|
||||
brief="Joins the voice channel that the caller is in")
|
||||
async def join(ctx, *, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
self.logger.info(f"Join requested by {member}")
|
||||
|
||||
if not self.Bot_Connected:
|
||||
# Wait for the bot to be ready to connect
|
||||
@@ -85,52 +99,116 @@ class Bot(commands.Bot):
|
||||
|
||||
if discord.opus.is_loaded():
|
||||
channel = ctx.author.voice.channel
|
||||
self.logger.debug("Sending hello")
|
||||
await ctx.send(f"Ok {str(member).capitalize()}, I'm joining {channel}")
|
||||
|
||||
# Join the voice channel with the audio stream
|
||||
self.logger.debug('Joining')
|
||||
voice_connection = await channel.connect()
|
||||
|
||||
# Create an audio stream from selected device
|
||||
self.streamHandler = sound.PCMStream()
|
||||
# Ensure the selected device is available and start the audio stream
|
||||
self.streamHandler.change_device(self.DEVICE_ID)
|
||||
|
||||
# Play the stream
|
||||
voice_connection.play(discord.PCMAudio(self.streamHandler))
|
||||
self.logger.debug("Starting noisegate/stream handler")
|
||||
self.streamHandler = NoiseGatev2.NoiseGate(_input_device_index=self.DEVICE_ID,
|
||||
_voice_connection=voice_connection,
|
||||
_noise_gate_threshold=self.noisegate_sensitivity)
|
||||
# Start the audio stream
|
||||
self.streamHandler.run()
|
||||
|
||||
# Start the SDR and begin playing to the audio stream
|
||||
self.logger.debug("Starting SDR")
|
||||
self.start_sdr()
|
||||
|
||||
# Change the activity to the channel and band-type being used
|
||||
self.logger.debug("Changing presence")
|
||||
await self.set_activity()
|
||||
|
||||
# 'Lock' the bot from connecting
|
||||
self.logger.debug("Locking the bot")
|
||||
self.Bot_Connected = True
|
||||
|
||||
else:
|
||||
# Return that the opus library would not load
|
||||
await ctx.send("Opus won't load")
|
||||
self.logger.critical("OPUS didn't load properly")
|
||||
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, I'm already connected")
|
||||
self.logger.info("Bot is already in a channel")
|
||||
|
||||
@self.command(help="Use this command to have the bot leave your channel",
|
||||
brief="Leaves the current voice channel")
|
||||
async def leave(ctx):
|
||||
async def leave(ctx, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
self.logger.info(f"Leave requested by {member}")
|
||||
|
||||
if self.Bot_Connected:
|
||||
# Stop the sound handlers
|
||||
self.streamHandler.clean_up()
|
||||
# Disconnect the client from the voice channel
|
||||
await ctx.voice_client.disconnect()
|
||||
self.logger.debug("Disconnecting")
|
||||
await self.streamHandler.close()
|
||||
|
||||
self.logger.debug("Changing presence")
|
||||
# Change the presence to away and '@ me'
|
||||
await self.set_activity(False)
|
||||
|
||||
# Stop the SDR so it can cool off
|
||||
self.logger.debug("Stopping SDR")
|
||||
self.stop_sdr()
|
||||
|
||||
self.logger.debug("Unlocking the bot")
|
||||
# 'Unlock' the bot
|
||||
self.Bot_Connected = False
|
||||
|
||||
self.logger.debug("Sending Goodbye")
|
||||
await ctx.send(f"Goodbye {str(member).capitalize()}.")
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, I'm not in a channel")
|
||||
self.logger.info("Bot is not in a channel")
|
||||
|
||||
# Add command to change the NoiseGate threshold
|
||||
@self.command(help="Use this command to change the threshold of the noisegate",
|
||||
brief="Change noisegate sensitivity")
|
||||
async def chngth(ctx, _threshold: int, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
self.logger.info(f"Change of NoiseGate threshold requested by {member}")
|
||||
await ctx.send(f"Ok {str(member).capitalize()}, I'm changing the threshold from "
|
||||
f"{self.streamHandler.THRESHOLD} to {_threshold}")
|
||||
self.streamHandler.THRESHOLD = _threshold
|
||||
self.noisegate_sensitivity = _threshold
|
||||
|
||||
# Reset the profile name since we have made a change
|
||||
self.profile_name = None
|
||||
|
||||
# If the SDR is started, restart it with the updates
|
||||
await self.use_current_radio_config()
|
||||
|
||||
# Add commands for GQRX and OP25
|
||||
if self.Handler == 'gqrx' or self.Handler == 'op25':
|
||||
if self.Handler in BotResources.PDB_ACCEPTABLE_HANDLERS.keys():
|
||||
# Command to display the current config
|
||||
@self.command(name='displaycurprofile',
|
||||
help="Use this command to display the current configuration of the bot.\n"
|
||||
"Example command:\n"
|
||||
"\t@ displaycurprofile",
|
||||
breif="Display current bot config")
|
||||
async def _displaycurprofile(ctx, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
message = self.display_current_radio_config()
|
||||
await ctx.send(f"Ok {str(member).capitalize()},\n{message}")
|
||||
self.logger.info(f"Displaying current profile; requested by {member}")
|
||||
|
||||
# Command to display the current config
|
||||
@self.command(name='displayprofiles',
|
||||
help="Use this command to display the saved profiles.\n"
|
||||
"Example command:\n"
|
||||
"\t@ displayprofiles",
|
||||
breif="Display current bot config")
|
||||
async def _displayprofiles(ctx, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
message = self.display_saved_radio_configs()
|
||||
await ctx.send(f"Ok {str(member).capitalize()},\n{message}")
|
||||
self.logger.info(f"Displaying all profiles; requested by {member}")
|
||||
|
||||
# Command to change the current frequency and mode
|
||||
@self.command(name='chfreq', help="Use this command to change the frequency the bot is listening to.\n"
|
||||
"Example GQRX command:\n"
|
||||
"\tTune to 104.7Mhz Wideband FM (Radio) - '@ chfreq wfm 104700000\n"
|
||||
@@ -140,36 +218,27 @@ class Bot(commands.Bot):
|
||||
brief="Changes radio frequency")
|
||||
async def chfreq(ctx, mode: str, freq: str, member: discord.Member = None):
|
||||
# Possible band-types that can be used
|
||||
possible_modes = []
|
||||
|
||||
if self.Handler == 'gqrx':
|
||||
possible_modes = ['wfm', 'fm']
|
||||
|
||||
elif self.Handler == 'op25':
|
||||
possible_modes = ['d', 'p25']
|
||||
|
||||
member = member or ctx.author.display_name
|
||||
self.logger.info(f"{member} requested change of frequency to Mode: {mode}, Freq: {freq}")
|
||||
|
||||
# Check to make sure the frequency input matches the syntax needed
|
||||
if len(freq) >= 6:
|
||||
self.freq = freq
|
||||
# Check to make sure the selected mode is valid
|
||||
if mode in possible_modes:
|
||||
if mode in self.possible_modes:
|
||||
self.mode = mode
|
||||
|
||||
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()
|
||||
await self.use_current_radio_config()
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, {mode} is not valid."
|
||||
f" You may only enter {possible_modes}")
|
||||
f" You may only enter {self.possible_modes}")
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, {freq} is not valid. "
|
||||
f"Please refer to the help page '@ help chfreq'")
|
||||
@@ -184,13 +253,16 @@ class Bot(commands.Bot):
|
||||
brief="Changes radio squelch")
|
||||
async def chsquelch(ctx, squelch: float, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
self.logger.info(f"{member} requested change of squelch to: {squelch}")
|
||||
|
||||
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()
|
||||
await self.use_current_radio_config()
|
||||
|
||||
# Hidden admin commands
|
||||
@self.command(name='saveprofile', hidden=True)
|
||||
@@ -208,12 +280,6 @@ class Bot(commands.Bot):
|
||||
else:
|
||||
await ctx.send(f"{str(member).capitalize()}, there is no profile with the name '{profile_name}'")
|
||||
|
||||
@self.command(name='displayprofile', hidden=True)
|
||||
async def _displayprofile(ctx, member: discord.Member = None):
|
||||
member = member or ctx.author.display_name
|
||||
message = self.display_current_radio_config()
|
||||
await ctx.send(f"Ok {str(member).capitalize()}\n{message}")
|
||||
|
||||
# Hidden admin commands
|
||||
@self.command(name='reload', hidden=True)
|
||||
async def _reload(ctx, module: str, member: discord.Member = None):
|
||||
@@ -225,11 +291,11 @@ class Bot(commands.Bot):
|
||||
await ctx.send(f"{str(member).capitalize()}, something went wrong. Please check the console")
|
||||
|
||||
@self.command(name='startsdr', hidden=True)
|
||||
async def _startsdr(ctx, member: discord.Member = None):
|
||||
async def _startsdr(*args):
|
||||
self.start_sdr()
|
||||
|
||||
@self.command(name='stopsdr', hidden=True)
|
||||
async def _stopsdr(ctx, member: discord.Member = None):
|
||||
async def _stopsdr(*args):
|
||||
self.stop_sdr()
|
||||
|
||||
# Add discord events to the bot
|
||||
@@ -239,36 +305,33 @@ class Bot(commands.Bot):
|
||||
async def on_ready():
|
||||
# Check the ./modules folder for any modules (cog.py)
|
||||
await self.check_for_modules()
|
||||
print("Bot started!")
|
||||
|
||||
@self.event
|
||||
async def on_message(message):
|
||||
await self.check_and_reply_to_ping(message)
|
||||
self.logger.info("Bot started!")
|
||||
|
||||
# Check to see if other bots are online
|
||||
async def check_other_bots_online(self):
|
||||
print('Checking if other bots are online')
|
||||
self.logger.info('Checking if other bots are online')
|
||||
channel = self.get_channel(self.Default_Channel_ID)
|
||||
print(f"Channel to be tested in: {channel}")
|
||||
self.logger.debug(f"Testing in: {channel}")
|
||||
|
||||
bots_online = []
|
||||
|
||||
def verify_bot_msg(msg):
|
||||
if msg.author.id in BotResources.PDB_KNOWN_BOT_IDS:
|
||||
bots_online.append(msg.author.id)
|
||||
if msg.author.id in BotResources.PDB_KNOWN_BOT_IDS.keys():
|
||||
bots_online.append(BotResources.PDB_KNOWN_BOT_IDS[msg.author.id])
|
||||
|
||||
await self.wait_until_ready()
|
||||
|
||||
await channel.send(f"{self.Command_Prefix}ping")
|
||||
# Send the ping command with the prefix the current bot is using
|
||||
await channel.send(f"{self.Command_Prefix}check_modules")
|
||||
|
||||
seconds_waited = 0
|
||||
while seconds_waited < 2:
|
||||
while seconds_waited < 3:
|
||||
try:
|
||||
await self.wait_for("message", check=verify_bot_msg, timeout=1)
|
||||
except asyncio.exceptions.TimeoutError:
|
||||
seconds_waited += 1
|
||||
|
||||
print(f"Bots Online: {bots_online}")
|
||||
self.logger.debug(f"Bots Online: {bots_online}")
|
||||
|
||||
if len(bots_online) == 0:
|
||||
return False
|
||||
@@ -278,38 +341,54 @@ class Bot(commands.Bot):
|
||||
# Check the handler being used during init
|
||||
def check_handler(self):
|
||||
if self.Handler == "gqrx":
|
||||
print("Starting GQRX handler")
|
||||
self.logger.info("Starting GQRX handler")
|
||||
from gqrxHandler import GQRXHandler
|
||||
self.GQRXHandler = GQRXHandler()
|
||||
self.GQRXHandler.start()
|
||||
self.possible_modes = BotResources.PDB_ACCEPTABLE_HANDLERS['gqrx']['Modes']
|
||||
|
||||
elif self.Handler == 'op25':
|
||||
print("Starting OP25 handler")
|
||||
self.logger.info("Starting OP25 handler")
|
||||
from op25Handler import OP25Handler
|
||||
self.OP25Handler = OP25Handler()
|
||||
self.OP25Handler.start()
|
||||
self.possible_modes = BotResources.PDB_ACCEPTABLE_HANDLERS['op25']['Modes']
|
||||
|
||||
# Load the proper OPUS library for the device being used
|
||||
def load_opus(self):
|
||||
# Check the system type and load the correct library
|
||||
if self.system_os_type == 'Linux_32':
|
||||
discord.opus.load_opus('./opus/libopus.so')
|
||||
elif self.system_os_type == 'Linux_64':
|
||||
# Linux ARM AARCH64 running 32bit OS
|
||||
if self.system_os_type == 'Linux_ARMv7l':
|
||||
self.logger.debug(f"Loaded OPUS library for {self.system_os_type}")
|
||||
discord.opus.load_opus('./opus/libopus_armv7l.so')
|
||||
# Linux ARM AARCH64 running 64bit OS
|
||||
if self.system_os_type == 'Linux_AARCH64':
|
||||
self.logger.debug(f"Loaded OPUS library for {self.system_os_type}")
|
||||
discord.opus.load_opus('./opus/libopus_aarcch64.so')
|
||||
elif self.system_os_type == 'Windows':
|
||||
discord.opus.load_opus('./opus/libopus.dll')
|
||||
# Windows 64bit
|
||||
if self.system_os_type == 'Windows_x64':
|
||||
self.logger.debug(f"Loaded OPUS library for {self.system_os_type}")
|
||||
discord.opus.load_opus('./opus/libopus_amd64.dll')
|
||||
|
||||
# Check to make sure the selected device is still available and has not changed it's index
|
||||
def check_device(self):
|
||||
for device, index in self.Devices_List:
|
||||
if int(index) == self.DEVICE_ID and str(device) == self.DEVICE_NAME:
|
||||
return True
|
||||
# Check to make sure the selected device is still available and has not changed its index
|
||||
def check_device(self, _override):
|
||||
# Check to see if an override has been passed
|
||||
if not _override:
|
||||
self.logger.debug(f"Device list {self.Devices_List}")
|
||||
for device, index in self.Devices_List['Input']:
|
||||
if int(index) == self.DEVICE_ID and str(device) == self.DEVICE_NAME:
|
||||
return True
|
||||
|
||||
for device, index in self.Devices_List:
|
||||
if str(device) == self.DEVICE_NAME:
|
||||
self.DEVICE_ID = int(index)
|
||||
return True
|
||||
for device, index in self.Devices_List['Input']:
|
||||
if str(device) == self.DEVICE_NAME:
|
||||
self.DEVICE_ID = int(index)
|
||||
return True
|
||||
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
# If an override has been passed just reply true
|
||||
return True
|
||||
|
||||
# Search the ./modules folder for any modules to load
|
||||
async def check_for_modules(self):
|
||||
@@ -320,50 +399,55 @@ class Bot(commands.Bot):
|
||||
if str(folder_name)[0] == '.':
|
||||
continue
|
||||
elif os.path.exists(os.path.join("modules", folder_name, "cog.py")):
|
||||
print(f"Loaded extension: {folder_name}")
|
||||
self.logger.debug(f"Loaded extension: {folder_name}")
|
||||
self.load_extension(f"modules.{folder_name}.cog")
|
||||
|
||||
# Reload a selected module for changes
|
||||
def reload_modules(self, module):
|
||||
try:
|
||||
self.unload_extension(f"modules.{module}.cog")
|
||||
print(f"Unloaded {module}")
|
||||
self.logger.debug(f"Unloaded {module}")
|
||||
self.load_extension(f"modules.{module}.cog")
|
||||
print(f"Loaded {module}")
|
||||
self.logger.debug(f"Loaded {module}")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.logger.error(e)
|
||||
return False
|
||||
|
||||
# Check and store the OS type of the system for later use
|
||||
def check_os_type(self):
|
||||
processor = platform.machine()
|
||||
if os.name == 'nt':
|
||||
self.system_os_type = 'Windows'
|
||||
if processor == "AMD64":
|
||||
self.system_os_type = 'Windows_x64'
|
||||
self.logger.debug(f"OS/Arch is {self.system_os_type}")
|
||||
else:
|
||||
processor = platform.architecture()[0]
|
||||
if processor == "64bit":
|
||||
self.system_os_type = 'Linux_64'
|
||||
elif processor == "32bit":
|
||||
self.system_os_type = 'Linux_32'
|
||||
if processor == "aarch64":
|
||||
self.system_os_type = 'Linux_AARCH64'
|
||||
self.logger.debug(f"OS/Arch is {self.system_os_type}")
|
||||
elif processor == "armv7l":
|
||||
self.system_os_type = 'Linux_ARMv7l'
|
||||
self.logger.debug(f"OS/Arch is {self.system_os_type}")
|
||||
|
||||
# Check to see if there is only one frequency
|
||||
def start_sdr(self):
|
||||
if self.Handler in ['gqrx', 'op25']:
|
||||
if self.Handler in BotResources.PDB_ACCEPTABLE_HANDLERS.keys():
|
||||
if type(self.freq) == str:
|
||||
# Single freq sent
|
||||
# Stop the SDR if it is running
|
||||
self.stop_sdr()
|
||||
|
||||
# Start the radio
|
||||
print(f"Starting freq: {self.freq}")
|
||||
self.logger.debug(f"Starting freq: {self.freq}")
|
||||
|
||||
if self.Handler == 'gqrx':
|
||||
# Set the settings in GQRX
|
||||
self.GQRXHandler.set_all_settings(self.mode, self.squelch, self.freq)
|
||||
self.GQRXHandler.set_gqrx_parameters(_frequency=self.freq, _squelch=self.squelch,
|
||||
_fm_mode=self.mode, _output_device_name=self.DEVICE_NAME,
|
||||
_start=True)
|
||||
|
||||
elif self.Handler == 'op25':
|
||||
self.OP25Handler.set_op25_parameters(self.freq)
|
||||
self.OP25Handler.start()
|
||||
self.OP25Handler.set_op25_parameters(self.freq, _start=True, _output_device_name=self.DEVICE_NAME)
|
||||
|
||||
# Set the started variable for later checks
|
||||
self.sdr_started = True
|
||||
@@ -372,16 +456,22 @@ class Bot(commands.Bot):
|
||||
def stop_sdr(self):
|
||||
if self.sdr_started:
|
||||
# Wait for the running processes to close
|
||||
|
||||
# Close the GQRX handler
|
||||
if self.Handler == 'gqrx':
|
||||
self.GQRXHandler.set_gqrx_parameters(_stop=True)
|
||||
|
||||
# Close the OP25 handler
|
||||
if self.Handler == 'op25':
|
||||
self.OP25Handler.close_op25()
|
||||
self.OP25Handler.set_op25_parameters(_stop=True)
|
||||
# self.OP25Handler.join()
|
||||
# Need a way to 'close' GQRX
|
||||
|
||||
self.sdr_started = False
|
||||
|
||||
# Set the activity of the bot
|
||||
async def set_activity(self, connected=True):
|
||||
if connected:
|
||||
if self.Handler in ['gqrx', 'op25']:
|
||||
if self.Handler in BotResources.PDB_ACCEPTABLE_HANDLERS.keys():
|
||||
if self.profile_name is None:
|
||||
await self.change_presence(activity=discord.Activity(type=discord.ActivityType.listening,
|
||||
name=f"{self.freq[:-1]}"
|
||||
@@ -399,43 +489,64 @@ class Bot(commands.Bot):
|
||||
await self.change_presence(activity=discord.Game(name=f"@ me"), status=discord.Status.idle)
|
||||
|
||||
# Save the current radio settings as a profile
|
||||
async def save_radio_config(self, profile_name):
|
||||
async def save_radio_config(self, _profile_name: str):
|
||||
self.logger.debug(f"Saving profile {_profile_name}")
|
||||
config = configparser.SafeConfigParser()
|
||||
|
||||
if os.path.exists('./profiles.ini'):
|
||||
config.read('./profiles.ini')
|
||||
|
||||
profile_name = str(_profile_name).upper()
|
||||
|
||||
if not config.has_section(str(profile_name)):
|
||||
config.add_section(str(profile_name))
|
||||
|
||||
config[str(profile_name)]['Frequency'] = self.freq
|
||||
config[str(profile_name)]['Mode'] = self.mode
|
||||
config[str(profile_name)]['Squelch'] = str(self.squelch)
|
||||
config[str(profile_name)]['Noisegate_Sensitivity'] = str(self.noisegate_sensitivity)
|
||||
|
||||
with open('./profiles.ini', 'w+') as config_file:
|
||||
config.write(config_file)
|
||||
|
||||
self.profile_name = profile_name
|
||||
|
||||
await self.use_current_radio_config()
|
||||
|
||||
async 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
|
||||
async def load_radio_config(self, profile_name):
|
||||
self.logger.debug(f"Loading profile {profile_name}")
|
||||
config = configparser.ConfigParser()
|
||||
if os.path.exists('./profiles.ini'):
|
||||
config.read('./profiles.ini')
|
||||
if config.has_section(str(profile_name)):
|
||||
self.profile_name = profile_name
|
||||
self.freq = config[str(profile_name)]['Frequency']
|
||||
self.mode = config[str(profile_name)]['Mode']
|
||||
self.squelch = float(config[str(profile_name)]['Squelch'])
|
||||
|
||||
if self.sdr_started:
|
||||
self.start_sdr()
|
||||
await self.set_activity()
|
||||
if config.has_section(str(profile_name).upper()):
|
||||
self.profile_name = str(profile_name).upper()
|
||||
self.freq = config[self.profile_name]['Frequency']
|
||||
self.mode = config[self.profile_name]['Mode']
|
||||
self.squelch = float(config[self.profile_name]['Squelch'])
|
||||
try:
|
||||
self.noisegate_sensitivity = int(config[self.profile_name]['Noisegate_Sensitivity'])
|
||||
except KeyError:
|
||||
self.logger.warning(f"Config does not contain a 'noisegate sensitivity' value, "
|
||||
f"creating one now with the default value: "
|
||||
f"{BotResources.DEFAULT_NOISEGATE_THRESHOLD}")
|
||||
self.noisegate_sensitivity = BotResources.DEFAULT_NOISEGATE_THRESHOLD
|
||||
await self.save_radio_config(self.profile_name)
|
||||
|
||||
await self.use_current_radio_config()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@@ -445,20 +556,38 @@ class Bot(commands.Bot):
|
||||
def display_current_radio_config(self):
|
||||
message_body = ""
|
||||
if self.profile_name:
|
||||
message_body += f"Profile Name: {self.profile_name}\n"
|
||||
message_body += f"Frequency: {self.freq}\n" \
|
||||
f"Mode: {self.mode}\n"
|
||||
message_body += f"Profile Name: {str(self.profile_name).upper()}\n"
|
||||
message_body += f"\tMode:\t\t\t\t\t{self.mode}\n" \
|
||||
f"\tFrequency:\t\t\t{self.freq}\n" \
|
||||
f"\tNoisegate Sensitivity:\t{self.noisegate_sensitivity}"
|
||||
if self.squelch:
|
||||
message_body += f"Squelch: {self.squelch}"
|
||||
message_body += f"\tSquelch:\t\t\t\t{self.squelch}"
|
||||
|
||||
return message_body
|
||||
|
||||
# Check if message is a ping request and respond even if it is a bot
|
||||
async def check_and_reply_to_ping(self, message):
|
||||
if "ping" in message.content:
|
||||
ctx = await self.get_context(message)
|
||||
await self.invoke(ctx)
|
||||
return True
|
||||
else:
|
||||
await self.process_commands(message)
|
||||
return False
|
||||
def display_saved_radio_configs(self):
|
||||
message_body = f"Saved configs\n"
|
||||
config = configparser.ConfigParser()
|
||||
if os.path.exists('./profiles.ini'):
|
||||
config.read('./profiles.ini')
|
||||
for section in config.sections():
|
||||
message_body += f"\nProfile Name: {section}:\n" \
|
||||
f"\tMode:\t\t\t\t\t{config[section]['Mode']}\n" \
|
||||
f"\tFrequency:\t\t\t{config[section]['Frequency']}\n"
|
||||
try:
|
||||
message_body += f"\tNoisegate Sensitivity:\t{config[section]['Noisegate_Sensitivity']}\n"
|
||||
except KeyError:
|
||||
self.logger.warning(f"Config does not contain a 'noisegate sensitivity' value. Please load the profile")
|
||||
|
||||
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
|
||||
253
gqrxHandler.py
253
gqrxHandler.py
@@ -1,48 +1,239 @@
|
||||
import configparser
|
||||
import shutil
|
||||
import logging
|
||||
import threading
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
from telnetlib import Telnet
|
||||
from BotResources import check_negative
|
||||
from BotResources import *
|
||||
from time import sleep
|
||||
|
||||
class GQRXHandler():
|
||||
def __init__(self, hostname: str = "localhost", port: int = 7356):
|
||||
self.hostname = hostname
|
||||
self.port = port
|
||||
|
||||
self.telnet_connection = None
|
||||
def reset_crashed(_config_path):
|
||||
config = configparser.SafeConfigParser()
|
||||
config.read(_config_path)
|
||||
if config.has_section('General'):
|
||||
if config.getboolean('General', 'crashed'):
|
||||
config['General']['crashed'] = 'false'
|
||||
with open(_config_path, 'w') as config_file:
|
||||
config.write(config_file)
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def enable_agc(_config_path):
|
||||
config = configparser.SafeConfigParser()
|
||||
config.read(_config_path)
|
||||
if config.has_option('receiver', 'agc_off'):
|
||||
config.remove_option('receiver', 'agc_off')
|
||||
with open(_config_path, 'w') as config_file:
|
||||
config.write(config_file)
|
||||
return True
|
||||
|
||||
|
||||
class GQRXHandler(threading.Thread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.GQRX_Config_Path = Path(f"{Path.home()}/.config/gqrx/drb_defaults.conf")
|
||||
self.GQRXDir: str = GQRX_BIN_LOCATION
|
||||
self.GQRXEXE: str = shutil.which(GQRX_BIN)
|
||||
self.GQRXProc = None
|
||||
self.GQRX_Started = False
|
||||
|
||||
self.logger = logging.getLogger("Discord_Radio_Bot.GQRXHandler")
|
||||
|
||||
self.Frequency = None
|
||||
|
||||
self.Mode = DEFAULT_RADIO_SETTINGS['mode']
|
||||
self.Frequency = DEFAULT_RADIO_SETTINGS['freq']
|
||||
self.Squelch = DEFAULT_RADIO_SETTINGS['squelch']
|
||||
|
||||
self.Start_GQRX = False
|
||||
self.Stop_GQRX = False
|
||||
|
||||
self.Output_Device_Name = None
|
||||
|
||||
self.hostname = "localhost"
|
||||
self.port = 7356
|
||||
|
||||
self.tel_conn = None
|
||||
|
||||
def run(self) -> None:
|
||||
while True:
|
||||
if self.Start_GQRX:
|
||||
self.open_gqrx()
|
||||
|
||||
self.Start_GQRX = False
|
||||
self.Stop_GQRX = False
|
||||
|
||||
self.logger.debug("GQRX is open, waiting for it to close")
|
||||
|
||||
while not self.Stop_GQRX:
|
||||
sleep(1)
|
||||
|
||||
self.logger.debug('Request to close GQRX')
|
||||
|
||||
self.close_gqrx()
|
||||
sleep(.5)
|
||||
|
||||
def set_gqrx_parameters(self, _frequency: str = False, _start: bool = False, _stop: bool = False,
|
||||
_output_device_name: str = None, _fm_mode: str = None, _squelch: float = None,
|
||||
_hostname: str = None, _port: int = None, _start_dsp: bool = None):
|
||||
if _frequency:
|
||||
self.Frequency = _frequency
|
||||
if self.GQRX_Started:
|
||||
self.change_freq(_frequency)
|
||||
|
||||
if _output_device_name:
|
||||
self.Output_Device_Name = _output_device_name
|
||||
|
||||
if _fm_mode:
|
||||
self.Mode = _fm_mode
|
||||
if self.GQRX_Started:
|
||||
self.change_mode(_fm_mode)
|
||||
|
||||
if _squelch:
|
||||
self.Squelch = _squelch
|
||||
if self.GQRX_Started:
|
||||
self.change_squelch(_squelch)
|
||||
|
||||
if _hostname:
|
||||
self.hostname = _hostname
|
||||
self.Start_GQRX = True
|
||||
|
||||
if _port:
|
||||
self.port = _port
|
||||
self.Start_GQRX = True
|
||||
|
||||
if _start_dsp:
|
||||
self.start_dsp()
|
||||
|
||||
if _start:
|
||||
self.Start_GQRX = _start
|
||||
|
||||
if _stop:
|
||||
self.Stop_GQRX = _stop
|
||||
|
||||
def open_gqrx(self):
|
||||
if self.GQRX_Started:
|
||||
self.close_gqrx()
|
||||
|
||||
gqrx_kwargs = [f"gqrx", "-c", "drb_defaults.conf"]
|
||||
|
||||
self.logger.info(f"Resetting 'crashed' option in the GQRX config")
|
||||
|
||||
self.reset_or_create_config()
|
||||
|
||||
self.logger.info(f"Starting GQRX")
|
||||
|
||||
self.logger.debug(f"GQRX Keyword Args: {gqrx_kwargs}")
|
||||
|
||||
self.GQRXProc = subprocess.Popen(gqrx_kwargs, executable=self.GQRXEXE, shell=False)
|
||||
|
||||
while not self.tel_conn:
|
||||
self.create_telnet_connection()
|
||||
sleep(2)
|
||||
self.logger.debug(f"Waiting for GQRX to start")
|
||||
|
||||
self.GQRX_Started = True
|
||||
|
||||
self.start_dsp()
|
||||
|
||||
self.set_all_settings(_squelch=self.Squelch, _mode=self.Mode, _freq=self.Frequency)
|
||||
self.logger.debug('Finished opening GQRX')
|
||||
|
||||
def close_gqrx(self):
|
||||
self.logger.info(f"Closing GQRX")
|
||||
try:
|
||||
self.GQRXProc.kill()
|
||||
|
||||
seconds_waited = 0
|
||||
while self.GQRXProc.poll() is None:
|
||||
# Terminate the process every 5 seconds
|
||||
if seconds_waited % 5 == 0:
|
||||
self.logger.info("Terminating GQRX")
|
||||
self.GQRXProc.terminate()
|
||||
sleep(1)
|
||||
self.logger.debug(f"Waited {seconds_waited} seconds")
|
||||
seconds_waited += 1
|
||||
self.logger.debug("GQRX Closed")
|
||||
self.GQRX_Started = False
|
||||
self.tel_conn = None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(e)
|
||||
|
||||
def create_telnet_connection(self):
|
||||
print("Creating connection")
|
||||
tel_conn = Telnet(self.hostname, self.port)
|
||||
tel_conn.open(self.hostname, self.port)
|
||||
self.logger.debug("Creating connection")
|
||||
try:
|
||||
self.tel_conn = Telnet(self.hostname, self.port)
|
||||
self.tel_conn.open(self.hostname, self.port)
|
||||
self.logger.debug(f"GQRX is open")
|
||||
return True
|
||||
except Exception as err:
|
||||
self.logger.warning(err)
|
||||
self.tel_conn = None
|
||||
return False
|
||||
|
||||
return tel_conn
|
||||
def check_dsp(self):
|
||||
self.logger.debug(f"Checking if DSP is running on GQRX")
|
||||
self.tel_conn.write(bytes(f"u DSP", 'utf-8'))
|
||||
if self.tel_conn.read_some() == b"1":
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def start_dsp(self):
|
||||
if not self.check_dsp():
|
||||
self.logger.debug(f"Starting DSP on GQRX")
|
||||
self.tel_conn.write(bytes(f"U DSP 1", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
def change_freq(self, freq):
|
||||
tel_conn = self.create_telnet_connection()
|
||||
print(f"Changing freq to {freq}")
|
||||
tel_conn.write(bytes(f"F {int(freq)}", 'utf-8'))
|
||||
sleep(1)
|
||||
|
||||
tel_conn.close()
|
||||
self.logger.debug(f"Changing freq to {freq}")
|
||||
self.tel_conn.write(bytes(f"F {int(freq)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
def change_squelch(self, squelch):
|
||||
tel_conn = self.create_telnet_connection()
|
||||
if not check_negative(squelch):
|
||||
squelch = float(-abs(squelch))
|
||||
print(f"Changing squelch to {squelch}")
|
||||
tel_conn.write(bytes(f"L SQL {float(squelch)}", 'utf-8'))
|
||||
sleep(1)
|
||||
|
||||
tel_conn.close()
|
||||
self.logger.debug(f"Changing squelch to {squelch}")
|
||||
self.tel_conn.write(bytes(f"L SQL {float(squelch)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
def change_mode(self, mode):
|
||||
tel_conn = self.create_telnet_connection()
|
||||
print(f"Changing mode to {mode}")
|
||||
tel_conn.write(bytes(f"M {str(mode)}", 'utf-8'))
|
||||
sleep(1)
|
||||
self.logger.debug(f"Changing mode to {mode}")
|
||||
self.tel_conn.write(bytes(f"M {str(mode)}", 'utf-8'))
|
||||
self.tel_conn.read_until(b'RPRT 0')
|
||||
|
||||
tel_conn.close()
|
||||
def set_all_settings(self, _mode, _squelch, _freq):
|
||||
self.change_squelch(0)
|
||||
self.change_mode(_mode)
|
||||
self.change_freq(_freq)
|
||||
self.change_squelch(_squelch)
|
||||
|
||||
def set_all_settings(self, mode, squelch, freq):
|
||||
self.change_mode(mode)
|
||||
self.change_freq(freq)
|
||||
self.change_squelch(squelch)
|
||||
def creat_config(self):
|
||||
from templates.gqrx_config_template import drb_defaults
|
||||
config = drb_defaults
|
||||
try:
|
||||
with open(self.GQRX_Config_Path, 'w+') as config_file:
|
||||
config_file.write(config)
|
||||
except OSError as err:
|
||||
self.logger.error(err)
|
||||
|
||||
def reset_or_create_config(self):
|
||||
if self.GQRX_Config_Path.is_file():
|
||||
try:
|
||||
self.logger.debug(f"Enabling AGC in the GQRX config")
|
||||
enable_agc(_config_path=self.GQRX_Config_Path)
|
||||
|
||||
self.logger.debug(f"GQRX Config exists, resetting 'crashed' setting")
|
||||
reset_crashed(_config_path=self.GQRX_Config_Path)
|
||||
except configparser.DuplicateOptionError as err:
|
||||
self.logger.warning(err)
|
||||
self.creat_config()
|
||||
else:
|
||||
self.logger.debug(f"GQRX config does not exist, creating it from template")
|
||||
self.creat_config()
|
||||
|
||||
116
main.py
116
main.py
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
import bot
|
||||
import argparse
|
||||
from BotResources import check_if_config_exists, write_config_file, read_config_file
|
||||
import BotResources
|
||||
|
||||
# Jorn
|
||||
#token = 'OTE1MDY0OTk2OTk0NjMzNzI5.YaWKsA.Y9yaCGg_VXRL_qQVbs05vo7gSAc'
|
||||
@@ -15,52 +16,125 @@ from BotResources import check_if_config_exists, write_config_file, read_config_
|
||||
|
||||
#name = "VoiceMeeter Output"
|
||||
|
||||
LOGGER = logging.getLogger("Discord_Radio_Bot.Main")
|
||||
|
||||
|
||||
class BotDeviceNotFound(Exception):
|
||||
def __init__(self, device):
|
||||
print(f"Unable to find the device: {device}")
|
||||
LOGGER.debug(f"Unable to find the device: {device}")
|
||||
try:
|
||||
os.remove('./config.ini')
|
||||
except OSError:
|
||||
print("Config file not found, restarting.")
|
||||
LOGGER.warning("Config file not found, restarting.")
|
||||
#os.execv(__file__, sys.argv)
|
||||
|
||||
|
||||
def main(**passed_config):
|
||||
print('Checking config file...')
|
||||
if not check_if_config_exists():
|
||||
print("No config file exists, please enter this information now")
|
||||
write_config_file(init=True, **passed_config)
|
||||
# Don't create a config if the user passed parameters
|
||||
if len(passed_config.keys()) == 0:
|
||||
LOGGER.info('Checking config file...')
|
||||
if not BotResources.check_if_config_exists():
|
||||
LOGGER.warning("No config file exists, please enter this information now")
|
||||
BotResources.write_config_file(init=True)
|
||||
|
||||
config = read_config_file()
|
||||
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)
|
||||
config = BotResources.read_config_file()
|
||||
|
||||
# Overwrite config options if they were passed
|
||||
for sub in config:
|
||||
# checking if key present in other dictionary
|
||||
if sub in passed_config:
|
||||
config[sub] = passed_config[sub]
|
||||
if len(passed_config.keys()) == 0:
|
||||
for sub in config:
|
||||
# checking if key present in other dictionary
|
||||
if sub in passed_config and passed_config[sub]:
|
||||
config[sub] = passed_config[sub]
|
||||
|
||||
print('Starting Bot...')
|
||||
LOGGER.info('Starting Bot...')
|
||||
|
||||
discord_bot_client = bot.Bot(Token=config['Bot Token'], Device_ID=config['Device ID'], Device_Name=config['Device Name'],
|
||||
Mention_Group=config['Mention Group'], Channel_ID=config['Channel ID'], Handler=config['Handler'])
|
||||
discord_bot_client = bot.Bot(Token=config['Bot Token'], Device_ID=config['Device ID'],
|
||||
Device_Name=config['Device Name'], Mention_Group=config['Mention Group'],
|
||||
Channel_ID=config['Channel ID'], Handler=config['Handler'])
|
||||
|
||||
print(f"Verifying audio device:\t{config['Device Name']}")
|
||||
LOGGER.debug(f"Verifying audio device:\t{config['Device Name']}")
|
||||
|
||||
if not discord_bot_client.check_device():
|
||||
if not discord_bot_client.check_device(_override=bool("Device ID" in passed_config.keys())):
|
||||
raise BotDeviceNotFound(config['Device Name'])
|
||||
|
||||
discord_bot_client.start_bot()
|
||||
|
||||
|
||||
def cmd_arguments():
|
||||
parser = argparse.ArgumentParser(description='Discord Bot Gang - Premium Discord Bot\n'
|
||||
'The more you listen, the less you can see')
|
||||
# Add the arguments
|
||||
|
||||
# Arg to override bot token
|
||||
parser.add_argument('-t', '--token',
|
||||
metavar='Bot Token',
|
||||
dest='Bot Token',
|
||||
type=str,
|
||||
help='Override saved bot token')
|
||||
|
||||
# Arg to override the input device in the config
|
||||
parser.add_argument('-i', '--input_device_id',
|
||||
metavar='Device ID',
|
||||
dest='Device ID',
|
||||
type=int,
|
||||
help='Override saved input device')
|
||||
|
||||
# Arg to override mention group
|
||||
parser.add_argument('-m', '--mention',
|
||||
metavar='Mention Group',
|
||||
dest='Mention Group',
|
||||
type=str,
|
||||
help='Override saved mention group')
|
||||
|
||||
# Arg to override default channel to send messages
|
||||
parser.add_argument('-c', '--channel',
|
||||
metavar='Channel ID',
|
||||
dest='Channel ID',
|
||||
type=int,
|
||||
help='Override saved sending channel')
|
||||
|
||||
# Arg to override handler
|
||||
parser.add_argument('-u', '--handler',
|
||||
metavar='Handler',
|
||||
dest='Handler',
|
||||
type=str,
|
||||
help='Override saved SDR handler')
|
||||
|
||||
# Arg to save the overridden arguments
|
||||
#parser.add_argument('-s', '--save',
|
||||
# metavar='save_overrides',
|
||||
# dest='save_overrides',
|
||||
# type=str,
|
||||
# help='Save the overridden arguments passed')
|
||||
|
||||
# Retrieve the args
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
return args
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
cmd_args = cmd_arguments()
|
||||
BotResources.init_global_logger()
|
||||
|
||||
if not all(cmd_args.values()):
|
||||
LOGGER.debug("Passed arguments:")
|
||||
for arg in cmd_args:
|
||||
if cmd_args[arg]:
|
||||
LOGGER.debug(f"\t{arg}:\t{cmd_args[arg]}")
|
||||
|
||||
try:
|
||||
print('Starting...')
|
||||
LOGGER.info('Starting...')
|
||||
while True:
|
||||
try:
|
||||
main()
|
||||
main(**cmd_args)
|
||||
except BotDeviceNotFound:
|
||||
print("Restarting...")
|
||||
LOGGER.info("Restarting...")
|
||||
time.sleep(2)
|
||||
except KeyboardInterrupt:
|
||||
print("Exiting...")
|
||||
LOGGER.error("Exiting...")
|
||||
|
||||
52
modules/ClearChannelMessages/cog.py
Normal file
52
modules/ClearChannelMessages/cog.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import logging
|
||||
from discord.ext import commands
|
||||
|
||||
LOGGER = logging.getLogger("Discord_Radio_Bot.LinkCop")
|
||||
|
||||
|
||||
class ClearMessages(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.Bot = bot
|
||||
|
||||
@commands.command(name='clear',
|
||||
help="Use this command to clear a given number of messages from the channel it is called in.\n"
|
||||
"There is a limit of 100 messages. Please be patient, it may take a while to process a large request."
|
||||
"Example command:\n"
|
||||
"\t@ clear\n"
|
||||
"\t@ clear 10",
|
||||
breif="Clear x messages in the channel it's called in")
|
||||
async def clear(self, ctx, amount=2):
|
||||
member = ctx.author.display_name
|
||||
member_id = ctx.author.id
|
||||
mtn_member = f"<@{member_id}>"
|
||||
|
||||
if isinstance(amount, int):
|
||||
if not amount > 0:
|
||||
ctx.channel.send(f"{member}, the number needs to be positive...")
|
||||
|
||||
else:
|
||||
LOGGER.info(f"Clear {amount} messages requested by {member}")
|
||||
|
||||
authors = {}
|
||||
async for message in ctx.channel.history(limit=amount):
|
||||
if message.author not in authors:
|
||||
authors[message.author] = 1
|
||||
else:
|
||||
authors[message.author] += 1
|
||||
await message.delete()
|
||||
|
||||
msg = f"{mtn_member}, I deleted {sum(authors.values())} messages from {len(authors.keys())} users:\n"
|
||||
LOGGER.debug(f"Deleted {sum(authors.values())} messages from {ctx.message.channel}")
|
||||
|
||||
for author in authors.keys():
|
||||
msg += f"\t{str(author).split('#', 1)[0]}: {authors[author]}\n"
|
||||
LOGGER.debug(f"Deleted {authors[author]} messages from {author}")
|
||||
|
||||
await ctx.channel.send(msg)
|
||||
|
||||
else:
|
||||
ctx.channel.send(f"{member}, you should check out the 'help' section...")
|
||||
|
||||
|
||||
def setup(bot: commands.Bot):
|
||||
bot.add_cog(ClearMessages(bot))
|
||||
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
import re
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
import random
|
||||
from BotResources import PDB_KNOWN_BOT_IDS
|
||||
from BotResources import PDB_KNOWN_BOT_IDS, check_and_reply_to_ping
|
||||
|
||||
regex_link = re.compile('(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)')
|
||||
|
||||
@@ -26,6 +27,8 @@ random_message = ["{%mtn_user%}, tsk tsk. Links belong here:\n{%ref_og_msg%}", "
|
||||
# welcome 757379843792044102
|
||||
# the-round-table 367396189529833474
|
||||
|
||||
LOGGER = logging.getLogger("Discord_Radio_Bot.LinkCop")
|
||||
|
||||
class LinkCop(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
@@ -44,9 +47,7 @@ class LinkCop(commands.Cog):
|
||||
# Bring in the known bot IDs from PDB bots
|
||||
self.whitelisted_ID = PDB_KNOWN_BOT_IDS
|
||||
|
||||
self.whitelisted_ID.append([
|
||||
235148962103951360 # Carl Bot
|
||||
])
|
||||
self.whitelisted_ID['Carl Bot'] = 235148962103951360
|
||||
|
||||
self.add_events()
|
||||
|
||||
@@ -61,7 +62,7 @@ class LinkCop(commands.Cog):
|
||||
try:
|
||||
if not any(item.id in self.whitelisted_groups for item in ctx.author.roles):
|
||||
if check_message(ctx.content):
|
||||
print('Msg with links detected in a blocked channel')
|
||||
LOGGER.info('Msg with links detected in a blocked channel')
|
||||
|
||||
response_text = self.generate_response(ctx)
|
||||
|
||||
@@ -70,10 +71,10 @@ class LinkCop(commands.Cog):
|
||||
# Delete the original message
|
||||
await ctx.delete()
|
||||
except AttributeError as err:
|
||||
print(f"Link Cop Error: '{err}'")
|
||||
print(f"Bot or other non-user that has not been whitelisted sent a message")
|
||||
LOGGER.error(f"Link Cop Error: '{err}'\nBot or other non-user that has not "
|
||||
f"been whitelisted sent a message")
|
||||
|
||||
await self.bot.check_and_reply_to_ping(ctx)
|
||||
await check_and_reply_to_ping(self.bot, ctx)
|
||||
|
||||
async def send_message(self, message):
|
||||
send_channel = self.bot.get_channel(id=self.reply_channel_id)
|
||||
@@ -125,7 +126,7 @@ def check_message(message_text):
|
||||
def get_links(message_text):
|
||||
links = regex_link.findall(message_text)
|
||||
|
||||
print(links)
|
||||
LOGGER.error(links)
|
||||
|
||||
if len(links) > 0:
|
||||
return links
|
||||
|
||||
24
modules/ModuleProbe/cog.py
Normal file
24
modules/ModuleProbe/cog.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from discord.ext import commands
|
||||
from BotResources import check_and_reply_to_ping
|
||||
|
||||
|
||||
class ModuleProbe(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.channel_id = 767303243285790721
|
||||
|
||||
self.add_events()
|
||||
|
||||
def add_events(self):
|
||||
@self.bot.event
|
||||
async def on_message(message):
|
||||
await check_and_reply_to_ping(self.bot, message)
|
||||
|
||||
@commands.command(help="This command is used by other bots to test if there are any bots online with modules.")
|
||||
async def check_modules(self, ctx):
|
||||
if ctx.author.id != self.bot.user.id:
|
||||
await ctx.send('pong')
|
||||
|
||||
|
||||
def setup(bot: commands.Bot):
|
||||
bot.add_cog(ModuleProbe(bot))
|
||||
@@ -1,44 +1,81 @@
|
||||
import threading
|
||||
import logging
|
||||
import shutil
|
||||
import subprocess
|
||||
import asyncio
|
||||
import os
|
||||
import threading
|
||||
import time
|
||||
from BotResources import DEFAULT_RADIO_SETTINGS
|
||||
|
||||
|
||||
class OP25Handler: #(threading.Thread):
|
||||
class OP25Handler(threading.Thread):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.OP25Dir: str = "/home/pi/op25/op25/gr-op25_repeater/apps"
|
||||
self.OP25EXE: str = shutil.which("/home/pi/op25/op25/gr-op25_repeater/apps/rx.py")
|
||||
self.OP25Proc = None
|
||||
|
||||
self.Frequency = None
|
||||
self.Frequency = DEFAULT_RADIO_SETTINGS['freq']
|
||||
|
||||
def start(self) -> None:
|
||||
self.open_op25()
|
||||
self.HTTP_ENABLED = False
|
||||
|
||||
def set_op25_parameters(self, _frequency):
|
||||
self.Frequency = _frequency
|
||||
self.Start_OP25 = False
|
||||
|
||||
self.Stop_OP25 = False
|
||||
|
||||
self.Output_Device_Name = None
|
||||
|
||||
self.logger = logging.getLogger("Discord_Radio_Bot.OP25Handler")
|
||||
|
||||
def run(self) -> None:
|
||||
while True:
|
||||
if self.Start_OP25:
|
||||
self.open_op25()
|
||||
|
||||
self.Start_OP25 = False
|
||||
self.Stop_OP25 = False
|
||||
|
||||
while not self.Stop_OP25:
|
||||
time.sleep(1)
|
||||
|
||||
self.close_op25()
|
||||
|
||||
time.sleep(.5)
|
||||
|
||||
def set_op25_parameters(self, _frequency: str = False, _http_enabled: bool = True, _start: bool = False,
|
||||
_stop: bool = False, _output_device_name: str = None):
|
||||
if _frequency:
|
||||
self.Frequency = _frequency
|
||||
|
||||
if _start:
|
||||
self.Start_OP25 = _start
|
||||
|
||||
if _stop:
|
||||
self.Stop_OP25 = _stop
|
||||
|
||||
if _http_enabled:
|
||||
self.HTTP_ENABLED = _http_enabled
|
||||
|
||||
if _output_device_name:
|
||||
self.Output_Device_Name = _output_device_name
|
||||
|
||||
def open_op25(self):
|
||||
if self.OP25Proc is not None:
|
||||
self.close_op25()
|
||||
|
||||
print(f"Starting OP25")
|
||||
p25_kwargs = [f"./rx.py", "--args", "rtl", "-N", "LNA:49", "-s", "200000", "-o", "25600", "-w", "-U", "-O",
|
||||
f"{self.Output_Device_Name}", "-f", f"{self.Frequency}e6", "-X", "-2"]
|
||||
|
||||
cwd = os.getcwd()
|
||||
print(cwd)
|
||||
self.logger.info(f"Starting OP25")
|
||||
# Change the interpreter's working directory (idr why)
|
||||
if self.HTTP_ENABLED:
|
||||
p25_kwargs.extend(["-l", "http:0.0.0.0:8080"])
|
||||
|
||||
os.chdir(self.OP25Dir)
|
||||
self.logger.debug(f"OP25 Keyword Args: {p25_kwargs}")
|
||||
|
||||
print(os.getcwd())
|
||||
|
||||
self.OP25Proc = subprocess.Popen([f"./rx.py", "--args", "rtl", "-N", "LNA:49", "-s",
|
||||
"200000", "-o", "25600", "-U", "-f", f"{self.Frequency}e6", "-X", "-2",
|
||||
"-l" "http:0.0.0.0:8080"])
|
||||
|
||||
os.chdir(cwd)
|
||||
self.OP25Proc = subprocess.Popen(p25_kwargs, executable=self.OP25EXE, shell=False, cwd=self.OP25Dir,
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||
|
||||
def close_op25(self):
|
||||
print(f"Closing OP25")
|
||||
self.logger.info(f"Closing OP25")
|
||||
try:
|
||||
self.OP25Proc.kill()
|
||||
|
||||
@@ -46,11 +83,11 @@ class OP25Handler: #(threading.Thread):
|
||||
while self.OP25Proc.poll() is None:
|
||||
# Terminate the process every 5 seconds
|
||||
if seconds_waited % 5 == 0:
|
||||
print("Terminating OP25")
|
||||
self.logger.info("Terminating OP25")
|
||||
self.OP25Proc.terminate()
|
||||
asyncio.sleep(1000)
|
||||
print(f"Waited {seconds_waited} seconds")
|
||||
time.sleep(1)
|
||||
self.logger.debug(f"Waited {seconds_waited} seconds")
|
||||
seconds_waited += 1
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.logger.error(e)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
discord~=1.7.3
|
||||
sounddevice~=0.4.3
|
||||
pynacl~=1.5.0
|
||||
discord==2.1.0
|
||||
numpy==1.23.5
|
||||
PyAudio==0.2.12
|
||||
sounddevice==0.4.5
|
||||
|
||||
62
sound.py
62
sound.py
@@ -1,62 +0,0 @@
|
||||
import sounddevice as sd
|
||||
from pprint import pformat
|
||||
|
||||
DEFAULT = 0
|
||||
sd.default.channels = 2
|
||||
sd.default.dtype = "int16"
|
||||
sd.default.latency = "low"
|
||||
sd.default.samplerate = 48000
|
||||
|
||||
class PCMStream:
|
||||
globals()
|
||||
|
||||
def __init__(self):
|
||||
self.stream = None
|
||||
|
||||
def read(self, num_bytes):
|
||||
# frame is 4 bytes
|
||||
frames = int(num_bytes / 4)
|
||||
data = self.stream.read(frames)[0]
|
||||
|
||||
# convert to pcm format
|
||||
return bytes(data)
|
||||
|
||||
def change_device(self, device_ID):
|
||||
self.clean_up()
|
||||
|
||||
self.stream = sd.RawInputStream(device=device_ID)
|
||||
|
||||
self.stream.start()
|
||||
|
||||
def clean_up(self):
|
||||
if self.stream is not None:
|
||||
self.stream.stop()
|
||||
self.stream.close()
|
||||
|
||||
|
||||
class DeviceNotFoundError(Exception):
|
||||
def __init__(self):
|
||||
self.devices = sd.query_devices()
|
||||
self.host_apis = sd.query_hostapis()
|
||||
super().__init__("No Devices Found")
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
f"Devices \n"
|
||||
f"{self.devices} \n "
|
||||
f"Host APIs \n"
|
||||
f"{pformat(self.host_apis)}"
|
||||
)
|
||||
|
||||
|
||||
def query_devices():
|
||||
options = {
|
||||
device.get("name"): index
|
||||
for index, device in enumerate(sd.query_devices())
|
||||
if (device.get("max_input_channels") > 0 and device.get("hostapi") == DEFAULT)
|
||||
}
|
||||
|
||||
if not options:
|
||||
raise DeviceNotFoundError()
|
||||
|
||||
return options
|
||||
0
templates/__init__.py
Normal file
0
templates/__init__.py
Normal file
41
templates/gqrx_config_template.py
Normal file
41
templates/gqrx_config_template.py
Normal file
@@ -0,0 +1,41 @@
|
||||
drb_defaults = """[General]
|
||||
configversion=2
|
||||
crashed=false
|
||||
|
||||
[audio]
|
||||
gain=-20
|
||||
udp_host=localhost
|
||||
|
||||
[dxcluster]
|
||||
DXCAddress=localhost
|
||||
DXCFilter=
|
||||
DXCPort=7300
|
||||
DXCSpotTimeout=10
|
||||
DXCUsername=nocall
|
||||
|
||||
[fft]
|
||||
averaging=85
|
||||
fft_window=5
|
||||
waterfall_span=1
|
||||
|
||||
[gui]
|
||||
geometry=@ByteArray(\x1\xd9\xd0\xcb\0\x3\0\0\0\0\x4t\0\0\0$\0\0\a\x7f\0\0\x3\x12\0\0\x4v\0\0\0\x42\0\0\a\x7f\0\0\x3\x12\0\0\0\0\0\0\0\0\a\x80\0\0\x4v\0\0\0\x42\0\0\a\x7f\0\0\x3\x12)
|
||||
state=@ByteArray(\0\0\0\xff\0\0\0\0\xfd\0\0\0\x2\0\0\0\x1\0\0\x1G\0\0\x2t\xfc\x2\0\0\0\x2\xfc\0\0\0\x42\0\0\x1\x89\0\0\x1\x89\0\b\0!\xfa\0\0\0\x1\x2\0\0\0\x3\xfb\0\0\0\x18\0\x44\0o\0\x63\0k\0I\0n\0p\0u\0t\0\x43\0t\0l\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1P\0\xff\xff\xff\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0R\0x\0O\0p\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\x1g\0\a\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0\x46\0\x66\0t\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc8\0\a\xff\xff\xfc\0\0\x1\xd1\0\0\0\xe5\0\0\0\xc3\0\xff\xff\xff\xfa\0\0\0\0\x2\0\0\0\x2\xfb\0\0\0\x12\0\x44\0o\0\x63\0k\0\x41\0u\0\x64\0i\0o\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\xc3\0\xff\xff\xff\xfb\0\0\0\xe\0\x44\0o\0\x63\0k\0R\0\x44\0S\0\0\0\0\0\xff\xff\xff\xff\0\0\0h\0\xff\xff\xff\0\0\0\x3\0\0\0\0\0\0\0\0\xfc\x1\0\0\0\x1\xfb\0\0\0\x1a\0\x44\0o\0\x63\0k\0\x42\0o\0o\0k\0m\0\x61\0r\0k\0s\0\0\0\0\0\xff\xff\xff\xff\0\0\x1\x42\0\xff\xff\xff\0\0\x1\xbd\0\0\x2t\0\0\0\x1\0\0\0\x2\0\0\0\b\0\0\0\x2\xfc\0\0\0\x1\0\0\0\x2\0\0\0\x1\0\0\0\x16\0m\0\x61\0i\0n\0T\0o\0o\0l\0\x42\0\x61\0r\x1\0\0\0\0\xff\xff\xff\xff\0\0\0\0\0\0\0\0)
|
||||
|
||||
[input]
|
||||
dc_cancel=true
|
||||
device="rtl=0"
|
||||
frequency=154785000
|
||||
gains=@Variant(\0\0\0\b\0\0\0\x1\0\0\0\x6\0L\0N\0\x41\0\0\0\x2\0\0\x1P)
|
||||
sample_rate=1800000
|
||||
|
||||
[receiver]
|
||||
demod=3
|
||||
filter_high_cut=2500
|
||||
filter_low_cut=-2500
|
||||
offset=-590400
|
||||
sql_level=-50
|
||||
|
||||
[remote_control]
|
||||
allowed_hosts=localhost, 127.0.0.1, ::1
|
||||
enabled=true"""
|
||||
Reference in New Issue
Block a user