radio: minor/misc_util: add coffee 'Kopi luwak'
This commit is contained in:
parent
cf688b88af
commit
55f8f29a31
@ -62,7 +62,7 @@ class Util:
|
||||
'a chocolate frappuccino', 'a butter pecan coffee', 'a maple pecan latte',
|
||||
'a sea salt caramel mocha', 'a nitro cold brew', 'a pumpkin cold brew',
|
||||
'a honey almond flat white', 'a sweet cream cold brew', 'a matcha latte',
|
||||
'a golden latte', 'a turmeric latte', 'a beetroot latte',]
|
||||
'a golden latte', 'a turmeric latte', 'a beetroot latte', 'a Kopi luwak']
|
||||
self.LAST_5_COFFEES: list = []
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ import logging
|
||||
import traceback
|
||||
from typing import Optional
|
||||
from discord.ext import bridge, commands, tasks
|
||||
from util.radio_util import get_now_playing
|
||||
from util.radio_util import get_now_playing, skip
|
||||
import discord
|
||||
from disc_havoc import Havoc
|
||||
|
||||
@ -116,6 +116,21 @@ class Radio(commands.Cog):
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
@bridge.bridge_command()
|
||||
@commands.is_owner()
|
||||
async def skip(self, ctx) -> None:
|
||||
"""
|
||||
Skip - Convenience Command
|
||||
Args:
|
||||
ctx (Any)
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
|
||||
await skip()
|
||||
return await ctx.respond("OK", ephemeral=True)
|
||||
|
||||
|
||||
def cog_unload(self) -> None:
|
||||
"""Run on Cog Unload"""
|
||||
self.radio_state_loop.cancel()
|
||||
|
@ -7,7 +7,8 @@ from aiohttp import ClientSession, ClientTimeout
|
||||
async def get_now_playing() -> Optional[str]:
|
||||
"""
|
||||
Get radio now playing
|
||||
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
str
|
||||
"""
|
||||
@ -25,3 +26,25 @@ async def get_now_playing() -> Optional[str]:
|
||||
logging.critical("Now playing retrieval failed: %s",
|
||||
str(e))
|
||||
return None
|
||||
|
||||
async def skip() -> bool:
|
||||
"""
|
||||
Ask LiquidSoap server to skip to the next track
|
||||
Args:
|
||||
None
|
||||
Returns:
|
||||
bool
|
||||
"""
|
||||
try:
|
||||
ls_uri: str = "http://127.0.0.1:29000"
|
||||
async with ClientSession() as session:
|
||||
async with session.get(f"{ls_uri}/next",
|
||||
timeout=ClientTimeout(connect=2, sock_read=2)) as request:
|
||||
request.raise_for_status()
|
||||
text: Optional[str] = await request.text()
|
||||
return text == "OK"
|
||||
except Exception as e:
|
||||
logging.debug("Skip failed: %s", str(e))
|
||||
|
||||
return False # failsafe
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user