Replace channel name spaces to hyphens

This commit is contained in:
BreadTube 2026-05-25 00:26:25 +09:00
commit 4133bca460
4 changed files with 15 additions and 1 deletions

View file

@ -365,6 +365,7 @@ class Bot:
break
if selected_category is None:
selected_category = category_ranges[-1][2]
self.logger.debug('Creating new channel: %s for id %s', subscription.name, subscription.channel_id)
sub_channel = self.discord_manager.create_text_channel(
self.guild_id, {
'name': subscription.name,

View file

@ -68,7 +68,7 @@ class SubscriptionInfo:
@staticmethod
def discord_compatible_name(text: str) -> SubscriptionName:
assert text, 'Channel name cannot be empty'
return SubscriptionName(unidecode(text[:100]))
return SubscriptionName(unidecode(text[:100].replace(' ', '-')))
@staticmethod
def from_dict(info: dict) -> SubscriptionInfo:

BIN
tests/data/subscriptions.csv (Stored with Git LFS) Normal file

Binary file not shown.
1 version https://git-lfs.github.com/spec/v1
2 oid sha256:43048fa740f1583dcd33c27ffa38b15a03aa53177aa6c1ce23b2adebb04546af
3 size 91

View file

@ -0,0 +1,10 @@
import logging
from pathlib import Path
from breadtube_bot.youtube_subscription import SubscriptionHelper
def test_helper():
subscriptions = SubscriptionHelper.read_text(Path('tests/data/subscriptions.csv').read_bytes())
assert subscriptions['UUlDye0T4xTEq46sA5evq9fA'].name == 'a-gauche'
assert subscriptions['UUFrDDP81MX_QfOHrRZOgD4g'].name == 'l214'