V
V
volodik5872021-07-19 14:58:33
Python
volodik587, 2021-07-19 14:58:33

How to add IDs to config.py?

How to add IDs to the config, I add it through and and it's simple, but it takes only the latest id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-07-19
@volodik587

> operator = "4609....71" and "109....307"
Pardon my French, but what the hell is this? You apply logical operators to strings, didn't you suspect something was wrong?
You need a collection of ids, and you need to check if this collection exists!
For example, a set (since I don't think the operator should appear in the list twice, right?):

operators = {"4609....71",  "109....307"}
for op in operators: #перебираем элементы множества
    await bot.forward_message(op, message.from_user.id, message.message_id)

Then adding a new operator will be easy and simple: At the same time, when you try to add it again, nothing will happen. Similarly, you can delete: If you try to delete a missing statement, a KeyError will be thrown. Well, if you need to check if id is an operator:
operators.add("1234....890")
operators.remove("1234....890")
if "1234...890" in operators:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question