forked from kate/uniborg
make constants uppercase
This commit is contained in:
parent
24f5b88d3a
commit
785b215c90
|
@ -4,10 +4,11 @@ import re
|
||||||
from telethon import events
|
from telethon import events
|
||||||
from telethon.tl.functions.channels import EditTitleRequest
|
from telethon.tl.functions.channels import EditTitleRequest
|
||||||
|
|
||||||
|
MULTI_EDIT_TIMEOUT = 80
|
||||||
prog_tech_id = 1040270887
|
REVERT_TIMEOUT = 2 * 60 * 60
|
||||||
|
CHANNEL_ID = 1040270887
|
||||||
|
DEFAULT_TITLE = "Programming & Tech"
|
||||||
prog_tech_channel = None
|
prog_tech_channel = None
|
||||||
default_title = "Programming & Tech"
|
|
||||||
lock = asyncio.Lock()
|
lock = asyncio.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,14 +25,14 @@ def fix_title(s):
|
||||||
async def edit_title(title):
|
async def edit_title(title):
|
||||||
global prog_tech_channel
|
global prog_tech_channel
|
||||||
if prog_tech_channel is None:
|
if prog_tech_channel is None:
|
||||||
prog_tech_channel = await borg.get_entity(prog_tech_id)
|
prog_tech_channel = await borg.get_entity(CHANNEL_ID)
|
||||||
await borg(EditTitleRequest(
|
await borg(EditTitleRequest(
|
||||||
channel=prog_tech_channel, title=title
|
channel=prog_tech_channel, title=title
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
@borg.on(events.NewMessage(
|
@borg.on(events.NewMessage(
|
||||||
pattern=re.compile(r"(?i)programming (?:&|and) (.+)"), chats=prog_tech_id))
|
pattern=re.compile(r"(?i)programming (?:&|and) (.+)"), chats=CHANNEL_ID))
|
||||||
async def on_name(event):
|
async def on_name(event):
|
||||||
new_topic = fix_title(event.pattern_match.group(1))
|
new_topic = fix_title(event.pattern_match.group(1))
|
||||||
new_title = f"Programming & {new_topic}"
|
new_title = f"Programming & {new_topic}"
|
||||||
|
@ -43,9 +44,9 @@ async def on_name(event):
|
||||||
|
|
||||||
with (await lock):
|
with (await lock):
|
||||||
await edit_title(new_title)
|
await edit_title(new_title)
|
||||||
await asyncio.sleep(80)
|
await asyncio.sleep(MULTI_EDIT_TIMEOUT)
|
||||||
await asyncio.sleep(2 * 60 * 60)
|
await asyncio.sleep(REVERT_TIMEOUT)
|
||||||
if lock.locked():
|
if lock.locked():
|
||||||
return
|
return
|
||||||
with (await lock):
|
with (await lock):
|
||||||
await edit_title(default_title)
|
await edit_title(DEFAULT_TITLE)
|
||||||
|
|
Loading…
Reference in New Issue