|
When posting your question please:
- Ensure this question is about Python..
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers
Chris Maunder
|
|
|
|
|
how can i prompt Ai to build me a simple script that can do the following:
I have two files containing thousands of lines of number combinations,
each line containing six numbers. Something like this:
2 12 46 52 65 3
1 2 21 37 43 21
9 11 30 43 69 20
3 11 13 24 39 22
2 26 45 46 52 21
To be clear, they are lottery combinations. So i have two files containing such data, thousands of lines of combinations per file. Let us call the two files FileOfu and FileAbuo.
I want a script that can look at all the combinations in FileAbuo and then check if they also exist in FileOfu. All the combinations in FileAbuo that also exist in FileOfu will be deleted, i.e, duplicates that exist in both files. The output file therefore will contain the remaining lines of combinations in FileOfu that do not also exist in FileAbou.
Literally just compare two files and eliminate identical number combinations.
I have tried prompting AI to make the script, but the script it makes always falls short. With a few hundreds of lines of combinations, it works. But with thousands of lines, it fails. I wonder where i am making the mistake.
I am not a programmer, just a script kiddie.
I have tried Python script. I wonder if other languages can give better script maybe.
|
|
|
|
|
You're not going to get it in a single description. For what you want, it's going to be an iterative process, and you have to know what you're doing and what the code is that's coming back from the AI.
AI CANNOT write an entire application for you and WILL make mistakes in the code it does write. If you don't know enough about writing code, you will have no idea what you're looking at or even what the mistakes are and how to describe to the AI what they and how to fix them.
|
|
|
|
|
Ohh. Ok. Thanks for the reply. I appreciate
|
|
|
|
|
|
|
Hello/Good evening everyone,
I'm new to the field of programming and have been trying to fill my knowledge gap with AI. My goal is to create a bot that instantly sends a message to a user whenever they request membership to the group the bot is affiliated with.
After numerous attempts with the help of AI, I managed to obtain a usable code. Unfortunately, when I run it, nothing happens.
Here is the link to my GitHub project: https://github.com/tesbgtoi/ybot
If anyone has experience with the Telegram API and could help me identify what's not working or provide advice on fixing my code, I would be extremely grateful.
Thank you very much for your help!
import logging
from telegram import Bot
from telegram.error import TelegramError
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
logger = logging.getLogger(__name__)
TOKEN = "TOKEN_DU_BOT"
GROUP_ID = 123456789
async def get_membership_requests(bot: Bot, group_id: int) -> list:
try:
administrators = await bot.get_chat_administrators(chat_id=group_id)
membership_requests = []
for admin in administrators:
if not admin.user.is_bot:
member = await bot.get_chat_member(chat_id=group_id, user_id=admin.user.id)
if member.status == 'restricted':
membership_requests.append(member)
return membership_requests
except TelegramError as e:
logger.error(f"Erreur lors de la récupération des demandes d'adhésion : {e}")
return []
async def send_membership_notifications(bot: Bot, group_id: int, membership_requests: list) -> None:
for request in membership_requests:
try:
await bot.send_message(
chat_id=request.user.id,
text="Votre demande d'adhésion au groupe a été reçue. Veuillez patienter pendant que l'administrateur approuve votre demande."
)
logger.info(f"Notification envoyée à l'utilisateur : {request.user.id}")
except TelegramError as e:
logger.error(f"Erreur lors de l'envoi de la notification à l'utilisateur {request.user.id} : {e}")
async def main() -> None:
bot = Bot(token=TOKEN)
membership_requests = await get_membership_requests(bot, GROUP_ID)
await send_membership_notifications(bot, GROUP_ID, membership_requests)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
modified 12-Jul-24 19:34pm.
|
|
|
|
|
Hi,
I think i maybe able to help you i have a lot of experience with telegram bots.
Although i won't actually help you in coding but i can help you build a logic for you bot.
|
|
|
|
|
I recently upgraded a Blue Iris install which was working with CP 2.5.6 without any difficulties. However, after upgrading to CP 2.6.5 (and installing new modules Yolov5.net, Optical Character Recognition, and License Plate reader, I noticed that there is a slow buildup of ram use by Python that I did not have before. In the past, the system ram use was stable over weeks and months but now over the course of several days system ram use slowly ramps up.
In Task Manager, I can see that Python is using the majority of the system RAM. If I stop the License Plate Reader module leaving the other two modules running, python memory use disappears from Task manager and overall ram use is normal. Restarting License Plate Reader module restarts python with typical normal RAM use but after several days, it will become excessive (in excess of 6 GB).
appears to be a memory leak in License Plate Reader with CP 2.6.5 that did not exist in 2.5.6?
|
|
|
|
|
|
source code of glocery management system using php
|
|
|
|
|
1. This is the Python forum.
2. This site does not provide code to order.
|
|
|
|
|
The only code you are ever going to get is the code YOU write.
Stop being lazy and start thinking about the problems you're facing and try to design a system to solve those problems.
|
|
|
|
|
I want to use python for decoder my .dat binary file generate by MSC Huawei MSOFTX3000 i need a compiler and other class to optimize and autamatise process for .dat file to oracle database
|
|
|
|
|
|
I'm looking for advice on how to efficiently search a solution space under certain conditions.
The solution space is a multidimensional array of positive integers. At each point in the array I run a function that either fails or passes. Importantly, if a point passes, then every point "under" it will also pass and doesn't need to be tested.
To illustrate, a 2D example would be an array of X and Y where X is 0 - 10 and Y is 0 - 15. If the point (2,3) passes then I know that (2,2), (2,1), (2,0), (1,3), (1,2), (1,1), (1,0), (0,3), (0,2) (0,1), (0,0) will also pass. Each of those points is "under" (2,3) in the sense that each element is less than or equal to it. There can be multiple “upper” pass points - for example, (1,5) could be a pass point in addition to (2,3).
I've already gleaned that it's more efficient to search the solution space from high to low values, because if an "upper" point passes then there's no need to test the "lower" points. But any advice beyond that is greatly appreciated, thank you!
modified 20-Apr-24 11:17am.
|
|
|
|
|
Your description implies that the search needs to start from the end of the array and work back to the beginning. That is in the case described going from [9, 14] back to [0, 0]. But maybe that is not quite what you do mean.
|
|
|
|
|
It’s definitely more efficient to test points from high values to lows. For example, you always want to test point (5,8) before you test point (4,7) because if the former passes there’s no need to test the latter. But beyond that I’m lost on how to improve the efficiency of the search.
|
|
|
|
|
That may be true, but your question is not clear (to me). Please edit your original post and add some more detail of what you are trying to do.
|
|
|
|
|
I edited the post to add more detail.
|
|
|
|
|
Binary search along one axis to find the greatest value that passes. Repeat for the each successive axis. That seems like it should work.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Second option, binary search along the diagonal, e.g. from (0,0), (1,1), ... (n,n) where n is min(max-x, max-y), until you find last pass. Call this point (p,p).
If f(p+1, p) passes : binary search for last pass along x axis between [p+2...max-x].
Else if f(p,p+1) passes : binary search for last pass along the y axis between [p+2...max-y].
Else answer is (p,p)
assuming I've understood your problem set correctly.
If f is not too complex, and your data matrix is not large, then maybe a simple linear search is "good enough" wrt the above.
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown
|
|
|
|
|
Hello I'm working on a Twitter Clone project and receiving an error when I try to delete profile. Here's the error message.
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "user_id" of relation "messages" violates not-null constraint
DETAIL: Failing row contains (11, Hello Guys, 2024-04-19 13:02:36.170058, null).
|
|
|
|
|
Try using serial datatype instead of int4 datatype in your target (table?) creation code.
|
|
|
|
|
Thank you I'll try that see what happens
|
|
|
|
|