#🔒 need help with the userbot telegram

100 messages · Page 1 of 1 (latest)

daring dove
#

hello everyone, I have already created on this topic, but it was closed without an answer, please help me fix the code so that there are no duplicate users when adding
https://paste.pythondiscord.com/4OOA

grave plinthBOT
#

@daring dove

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

high dagger
#

What is the issue?

daring dove
#

he is constantly adding the same users

eager trench
#

Still haven't switched over to SQLite?

daring dove
#

I used pymysql but it still seems to be a problem with the algorithm

eager trench
daring dove
#

MySQL

eager trench
#

Seems like a bit much

daring dove
#

but I think I can do without the database.

#

the script is not used all the time, so I think I can do without the database.

eager trench
#

The whole point of the database is to restrict the data so it doesn't store duplicates

#

Unlike text files, you can store whatever

daring dove
#

i get it

#

I tried using chat gpt, but it didn't do anything useful, but connected the database

eager trench
#

Why don't you try with sqlite first?

#

And then if you wanna switch it to mysql, its a simple connection change

daring dove
#

I've tried it now, but there are duplicates

eager trench
#

show me

daring dove
#

moment

eager trench
#

also don't use chatgpt

#

!rule chatgpt sucks most of the time

grave plinthBOT
#

10. Do not copy and paste answers from ChatGPT or similar AI tools.

daring dove
eager trench
#

Or you could set it as a primary key

#

And, I think you've set it in such a way that it constantly recreates the table. Tho then again, I think thats fine

daring dove
#

I set username as uniq

eager trench
#

Where?

#

How do you set it as unique in the users table?

daring dove
#

I've fixed it now.

eager trench
#

So it works?

daring dove
#

nope

#

it just gives errors something that should be unique

eager trench
#

full error message pls

daring dove
#

moment

#

there are no errors, he duplicates the addition again

#

he checks the database, but there seems to be a problem with reading from the database

#

Please help me fix it

#

I haven't been able to fix it for 3 days

eager trench
#

You could take it to the next level to ensure that it always works with sqlalchemy

daring dove
#

it works without errors

eager trench
#

everything works without errors

daring dove
#

but it no errors its a log

eager trench
#

share your latest code

eager trench
# daring dove

do you have something like sqlitebrowser or some other sqlite viewer to see what is contained in your not_added_users.sqlite3 file?

daring dove
#

yes

#

SQLiteStudio

eager trench
#

Can you open it and see if it did write into that database?

#

actually, should it be .sqlite3?

#

I think it should end in .db

daring dove
#

.sqlite3

#

He didn't write anything down there.

eager trench
daring dove
#

script*

eager trench
#

Change the filenames in the script from .sqlite3 to .db

daring dove
#

but it has not stopped being duplicated, it is duplicated not from the database side but from the script side

eager trench
daring dove
#

the database stores it, but the code starts working again from the first user

eager trench
daring dove
#

Have you looked at the code?

eager trench
daring dove
#

I have repeated users, i.e. he added 50 people, he adds the same 50 people again without switching to the following

#

he had to go through all the users but didn't get stuck on the same ones

eager trench
#

Aren't usernames from Telegram unique by default?

daring dove
#

there are no duplicates themselves, there is a repetition cycle that does not allow you to go to other users

#

I was talking about such duplicates

eager trench
daring dove
#

I wrote them to a file for the test and it repeated the entries, I meant duplicates.

daring dove
eager trench
#

I only see one based on your screenshot

daring dove
eager trench
# daring dove yes

Without proof, I have no idea. But your SQL statements are inserting only unique users

eager trench
#

I see

#

OK so there are duplicates. You still havn't established what you wanna do if there are duplicates

daring dove
#

I would like to understand why he constantly cycles using the same thing

#

can just use a loop when outputting from the database

#

I think this will help fix it.

eager trench
daring dove
#

apps=[

Client("client1"),
Client("client2"),
......
}
eager trench
#

Why is there multiple clients?

#

try with just 1 client

#

🤷‍♂️

daring dove
#

I need all of them at once because I have 10 accounts to add users

eager trench
#

Well, that explains why its repeatedly trying to insert the same users

#

Also this line doesn't make sense now:

    filtered_users = users - added_users
#

Don't need it

daring dove
#

K.

grave plinthBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.