changed channel to parse messages
This commit is contained in:
parent
26173c0305
commit
dc5f5035fc
24
main.py
24
main.py
@ -34,26 +34,28 @@ def clean_message(last_message: str, previous_message: str) -> str:
|
||||
previous_rank = int(m.group(3))
|
||||
new_rank = int(m.group(4))
|
||||
striker_po = m.group(5)
|
||||
n = n + 1
|
||||
n = 1
|
||||
elif m.group(2) == 'dropped':
|
||||
struck = m.group(1)
|
||||
previous_rank = int(m.group(4))
|
||||
new_rank = int(m.group(3))
|
||||
struck_po = m.group(5)
|
||||
n = n + 1
|
||||
n = 2
|
||||
m = re.search(REGEXP2, previous_message)
|
||||
if m and len(m.groups()) == 5:
|
||||
if m.group(2) == 'climbed':
|
||||
if int(m.group(3)) == previous_rank and int(m.group(4)) == new_rank:
|
||||
striker = m.group(1)
|
||||
striker_po = m.group(5)
|
||||
n = n + 1
|
||||
if n == 2:
|
||||
n = 3
|
||||
elif m.group(2) == 'dropped':
|
||||
if int(m.group(3)) == new_rank and int(m.group(4)) == previous_rank:
|
||||
struck = m.group(1)
|
||||
struck_po = m.group(5)
|
||||
n = n + 1
|
||||
if n == 2:
|
||||
if n == 1:
|
||||
n = 3
|
||||
if n == 3:
|
||||
return striker + '(' + striker_po + ') ' + str(previous_rank) + '->' + str(new_rank) + ' ' + struck + '(' + struck_po + ')'
|
||||
|
||||
|
||||
@ -74,21 +76,21 @@ async def on_message(message: Message) -> None:
|
||||
return
|
||||
|
||||
print(f'received {message}')
|
||||
print(f'content {message.content}')
|
||||
|
||||
message_content: str = message.content
|
||||
# if not user_message:
|
||||
# for embed in message.embeds:
|
||||
# user_message = embed.description
|
||||
if not message_content and message.embeds:
|
||||
print('try to get embedded information as message content')
|
||||
for embed in message.embeds:
|
||||
message_content = embed.description
|
||||
if not message_content:
|
||||
print('message is empty or not parseable, ignoring', flush=True)
|
||||
print('no message content, ignoring', flush=True)
|
||||
return
|
||||
# if 'Kriss' not in message_content:
|
||||
# print('message not implying "Kriss"', flush=True)
|
||||
# return
|
||||
|
||||
channel = client.get_channel(tracker_channel)
|
||||
previous_message = [msg async for msg in channel.history(limit=2)][0]
|
||||
previous_message = [msg async for msg in channel.history(limit=2)][1]
|
||||
|
||||
print(f'previous message content: {previous_message.content}')
|
||||
print(f'received message content: {message_content}')
|
||||
|
Loading…
Reference in New Issue
Block a user