Fix discord channel name and add verification
This commit is contained in:
parent
cc40e9dcf3
commit
d645fecae0
7 changed files with 23 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
import re
|
||||
from typing import NewType
|
||||
|
||||
from breadtube_bot.unidecode import unidecode
|
||||
|
|
@ -68,7 +69,10 @@ class SubscriptionInfo:
|
|||
@staticmethod
|
||||
def discord_compatible_name(text: str) -> SubscriptionName:
|
||||
assert text, 'Channel name cannot be empty'
|
||||
return SubscriptionName(unidecode(text[:100].replace(' ', '-')))
|
||||
name = unidecode(text[:100].replace(' ', '-'))
|
||||
name = re.sub(r'-+', '-', name)
|
||||
name = re.sub(r'-+$', '', name)
|
||||
return SubscriptionName(name)
|
||||
|
||||
@staticmethod
|
||||
def from_dict(info: dict) -> SubscriptionInfo:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue