Skip to content

Commit

Permalink
#23 implement alpha version of radio
Browse files Browse the repository at this point in the history
  • Loading branch information
halbrd committed Jul 28, 2021
1 parent 71564e6 commit c5d78a0
Show file tree
Hide file tree
Showing 9 changed files with 394 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Lemmy components to ignore
config/*
!config/*.example.ini
data
venv
cache


.vscode

# Byte-compiled / optimized / DLL files
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apk add --no-cache imagemagick-dev
RUN apk add --no-cache git
RUN apk add --no-cache gcc
RUN apk add --no-cache musl-dev
# TODO: install ffmpeg
RUN pip install pipenv

WORKDIR /app
Expand Down
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ verify_ssl = true
googletrans = "*"
emoji = "*"
requests = "*"
"discord.py" = "*"
"discord.py" = {extras = ["voice"], version = "*"}
Wand = "*"
youtube-dl = "*"

[requires]
python_version = "3.8"
151 changes: 134 additions & 17 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/contexts.example.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[DEFAULT]
symbol = /
manifest = Core Lenny Translate Jebrim CustomCommands Memes Info Emoters CallLogger Neet
manifest = Core Lenny Translate Jebrim CustomCommands Memes Info Emoters CallLogger Neet Radio

[12345678901234567]
symbol = $
Expand Down
10 changes: 9 additions & 1 deletion lemmy.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def load_all_sync(self):
async def load_all_async(self):
await self.load_playing_message()
await self.announce_servers()
await self.disconnect_all_voice()

def load_config(self):
for config_file in ['lemmy', 'contexts']:
Expand Down Expand Up @@ -147,7 +148,13 @@ async def load_playing_message(self):
async def announce_servers(self):
servers = await self.client.fetch_guilds(limit=None).flatten()
servers = sorted([ server.name for server in servers ])
self.log('\n'.join(['Logging in to servers:'] + servers))
self.log('Connected to servers: ' + ', '.join(servers))

async def disconnect_all_voice(self):
for vc in self.client.voice_clients:
if vc.is_playing():
vc.stop()
await vc.disconnect()

def setup_logging(self):
logging.basicConfig(format='%(message)s', level=logging.WARNING)
Expand All @@ -160,6 +167,7 @@ def setup_logging(self):

async def shutdown(self):
self.log('Shutting down...')
await self.disconnect_all_voice()
await self.client.close()

def get_context(self, context):
Expand Down
1 change: 1 addition & 0 deletions lemmy.service
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Restart=always
RestartSec=1
User=will
WorkingDirectory=/opt/lemmy
ExecStartPre=/usr/bin/pipenv install
ExecStart=/usr/bin/pipenv run python lemmy.py

[Install]
Expand Down
2 changes: 1 addition & 1 deletion modules/calllogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_channel_populations(self):
]

return {
str(channel.id): len(channel.members)
str(channel.id): len(channel.members) # TODO: don't count Lemmy in this
for channel in voice_channels
}

Expand Down
Loading

0 comments on commit c5d78a0

Please sign in to comment.