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

Enable commands in DMs #20

Closed
wants to merge 9 commits into from
Closed

Enable commands in DMs #20

wants to merge 9 commits into from

Conversation

kahlstrm
Copy link
Collaborator

enabling commands in DMs:

  • Users can use both graph/expected in DMs, the bot asks the users that which graph they want to see.

closes #17

@kahlstrm kahlstrm marked this pull request as ready for review August 11, 2022 19:39
Comment on lines 14 to 18
query_result = CON.execute(
f'SELECT R.chat_id,chat.title FROM in_chat AS C \
JOIN raffle as R ON C.chat_id=R.chat_id JOIN\
chat ON chat.chat_id=R.chat_id\
WHERE C.user_id={update.effective_user.id}').fetchall()
Copy link
Owner

Choose a reason for hiding this comment

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

F-string = can inject SQL very bad 😞

Comment on lines -25 to +34
chat_id = update.effective_chat.id
chat_title = update.effective_chat.title
if update.callback_query is not None:
chat_id, chat_title, graph_type = update.callback_query.data
message = update.callback_query.message
else:
chat_id = update.effective_chat.id
chat_title = update.effective_chat.title
message = update.message
Copy link
Owner

Choose a reason for hiding this comment

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

Joku data verification vois olla hyvä, jos botti restarttaa tms.
Esim:

if (isinstance(query.data, InvalidCallbackData) or
        len(query.data) != 3 or
        not isinstance(query.data[0], int) or
        not isinstance(query.data[1], str) or
        not isinstance(query.data[2], int)):

    await query.message.edit_text(STRINGS['unknown_error'])
    return ConversationHandler.END

@kahlstrm kahlstrm closed this Aug 22, 2022
@kahlstrm kahlstrm deleted the DM-commands branch August 22, 2022 19:15
@kahlstrm
Copy link
Collaborator Author

closed since the structure of the program has changed drastically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] Make group-based commands usable in DMs -> you have to select channel
2 participants