Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed connect parsing. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Connect_Link_Bot/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ async def on_message(message):
if message.author == client.user:
return

#Checks if there is a match using regex
p = re.compile("connect\s*(\S+)\s*;\s*password\s*(\S+)").match(message.content)
#Run if there is a match.
if p:
groups = p.groups()
await client.send_message(message.channel, "steam://connect/" + groups[0] + "/" + groups[1])


if message.content.startswith('connect '):
tempMsg = str.replace(message.content, 'connect ');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be tempMsg = msg.replace('connect ', '');
Append a line below: tempMsg = tempMsg.replace('"', '');

temp = temMsg.partition(";password ")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: temp = tempMsg.partition("; password ")

if temp[2].startswith('"') and temp[2].endswith('"'):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the entire if block. It should be replaced by the line recommended above.

temp[2] = temp[2].lstrip('"')
temp[2] = temp[2].rstrip('"')

await client.send_message(message.channel, "steam://connect/" + temp[0] + "/" + temp[2])

client.run('<token here>', bot=True)