make constants uppercase

This commit is contained in:
udf 2018-11-14 00:33:35 +02:00
parent 24f5b88d3a
commit 785b215c90
Signed by untrusted user: kate
GPG Key ID: E40724BAD73AF77B
1 changed files with 9 additions and 8 deletions

View File

@ -4,10 +4,11 @@ import re
from telethon import events
from telethon.tl.functions.channels import EditTitleRequest
prog_tech_id = 1040270887
MULTI_EDIT_TIMEOUT = 80
REVERT_TIMEOUT = 2 * 60 * 60
CHANNEL_ID = 1040270887
DEFAULT_TITLE = "Programming & Tech"
prog_tech_channel = None
default_title = "Programming & Tech"
lock = asyncio.Lock()
@ -24,14 +25,14 @@ def fix_title(s):
async def edit_title(title):
global prog_tech_channel
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(
channel=prog_tech_channel, title=title
))
@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):
new_topic = fix_title(event.pattern_match.group(1))
new_title = f"Programming & {new_topic}"
@ -43,9 +44,9 @@ async def on_name(event):
with (await lock):
await edit_title(new_title)
await asyncio.sleep(80)
await asyncio.sleep(2 * 60 * 60)
await asyncio.sleep(MULTI_EDIT_TIMEOUT)
await asyncio.sleep(REVERT_TIMEOUT)
if lock.locked():
return
with (await lock):
await edit_title(default_title)
await edit_title(DEFAULT_TITLE)