Forum Replies Created
-
AuthorPosts
-
May 30, 2023 at 3:28 pm #213169spid3rMember
It work !!!! thanks a lot
May 12, 2023 at 10:50 am #213154spid3rMemberok now bot find room, problem still send text in room 😐
May 10, 2023 at 10:48 am #213152spid3rMemberhello guys, i try to write bot for paltalk with chatgpt incorporated. I have a problem with bot when it has to type in room. It seems it cant recognize list user and room name.
here my coode :
import openai import time import pywinauto import win32gui import win32api import win32con from pywinauto import Application import keyboard import pygetwindow as gw import psutil # Add these lines after the imports section LVM_GETITEMCOUNT = 0x1000 LVM_GETITEMW = 0x104B LVM_GETITEMTEXTA = 0x1045 CHAT_ROOM_NAME = "INSERT ROOM NAME" PALTALK_WINDOW_CLASS = "Paltalk Messenger Window Class" # Replace with your Paltalk username PAL_USERNAME = "INSERT YOUR NICK BOT" # Replace with your OpenAI API keys openai.api_key = "INSERT YOUR CHATGPT API" # The conversation prompt to start a conversation with the OpenAI API conversation_prompt = ("The following is a conversation with an AI assistant. " "The assistant is helpful, creative, clever, and very friendly." "User: Hello, who are you?") # The maximum number of messages the bot can send in a row max_num_responses = 3 # The amount of time (in seconds) to wait before sending another message delay_between_responses = 2 def find_chat_window(): chat_window = win32gui.FindWindow("DlgGroupChat Window Class", None) print(f"Chat window: {chat_window}") # Add this line return chat_window def find_chat_input(chat_window): def callback(hwnd, hwnds): if win32gui.GetClassName(hwnd) == "RichEdit20W": hwnds.append(hwnd) return True hwnds = [] win32gui.EnumChildWindows(chat_window, callback, hwnds) chat_input = hwnds[0] if hwnds else None print(f"Chat input: {chat_input}") # Add this line return chat_input def find_chat_input(chat_window): def callback(hwnd, hwnds): if win32gui.GetClassName(hwnd) == "RichEdit20W": hwnds.append(hwnd) return True hwnds = [] win32gui.EnumChildWindows(chat_window, callback, hwnds) return hwnds[0] if hwnds else None def get_main_window_handle(app_name): app_windows = pywinauto.findwindows.find_elements(title_re=app_name, backend='uia') if app_windows: return app_windows[0].handle return None def get_user_count(chat_window): sysheader = None def callback(hwnd, hwnds): nonlocal sysheader if win32gui.GetClassName(hwnd) == "SysHeader32": sysheader = hwnd return True win32gui.EnumChildWindows(chat_window, callback, []) return win32api.SendMessage(sysheader, LVM_GETITEMCOUNT, 0, 0) def get_user_info(chat_window, index): sysheader = None def callback(hwnd, hwnds): nonlocal sysheader if win32gui.GetClassName(hwnd) == "SysHeader32": sysheader = hwnd return True win32gui.EnumChildWindows(chat_window, callback, []) lvitem = win32api.SendMessage(sysheader, LVM_GETITEMW, index, 0) user_on_mic = lvitem.iImage == 10 user_nickname = win32api.SendMessage(sysheader, LVM_GETITEMTEXTA, index, 0) return user_on_mic, user_nickname def send_message(chat_window, message): # Remove logic to restart Paltalk chat_window_title = CHAT_ROOM_NAME chat_windows = gw.getWindowsWithTitle(chat_window_title) chat_window = None for window in chat_windows: if window.isActive: chat_window = window break # Check if Paltalk process is running before assuming it's closed for process in psutil.process_iter(): if "Paltalk.exe" in process.name(): is_running = True break else: is_running = False if not is_running: print("Paltalk does appear to actually be closed.") return if chat_window is None: print("Unable to find Paltalk chat window.") return # Use the PyGetWindow window object chat_window.activate() chat_window.restore() # Default to searching for "Paltalk Messenger Window" if title search fails if not chat_window and not chat_windows: chat_window = gw.getWindowsWithTitle("Paltalk Messenger Window")[0] if not chat_window: print("Paltalk does not appear to be open. Restarting...") # Add logic to restart Paltalk... return # Use the window object's methods chat_window.activate() chat_window.restore() # ACTIVE CHAT WINDOW IS chat_window - NO active_chat VARIABLE NEEDED chat_window.activate() chat_window.restore() # Use .activate() and .restore() as a fallback if SetForegroundWindow doesn't work active_chat.activate() active_chat.restore() # Increase sleep time while win32gui.GetForegroundWindow() != chat_window: print(f"Foreground window: {win32gui.GetForegroundWindow()}, chat window: {chat_window}") time.sleep(0.5) # Increased from 0.1 chat_window_gw = chat_windows[0] # Ensure the chat window is visible and focused print("Restoring and activating the chat window...") chat_window_gw.restore() chat_window_gw.activate() # Fallback: use SetForegroundWindow if the chat window is still not in the foreground if win32gui.GetForegroundWindow() != chat_window: print("Using SetForegroundWindow as a fallback...") win32gui.SetForegroundWindow(chat_window) # Wait for the window to be active print("Waiting for the chat window to be in the foreground...") while win32gui.GetForegroundWindow() != chat_window: print(f"Foreground window: {win32gui.GetForegroundWindow()}, chat window: {chat_window}") time.sleep(0.1) # Send the message print("Sending the message...") time.sleep(0.5) # Add this line to introduce a delay before sending the message keyboard.write(message) keyboard.press("enter") keyboard.release("enter") print("Message sent.") # Try different combinations of titles and window classes titles = [CHAT_ROOM_NAME, "untitled - Chat Window"] classes = [PALTALK_WINDOW_CLASS, "Paltalk Chat Window Class"] for title in titles: for window_class in classes: # Search by title and class chat_window = win32gui.FindWindow(window_class, title) if chat_window: break # If still not found, just search by title if not chat_window: chat_window = gw.getWindowsWithTitle(title) if chat_window: break # Very broad searches as a last resort if not chat_window: chat_window = win32gui.FindWindow(None, "*Paltalk*") # Additional error handling if not chat_window: print("Unable to find the Paltalk chat window. Retrying...") time.sleep(5) # Retry after 5 seconds send_message(chat_window, message) def generate_response(message): response = openai.Completion.create( engine="davinci", prompt=f"{conversation_prompt} User: {message}", max_tokens=1024, n=1, stop=None, temperature=0.7, ) response_text = response.choices[0].text.strip() return response_text def main(): print("Bot is running...") chat_window = find_chat_window() if not chat_window: print("Couldn't find the chat window") return joined_rooms = ["INSERT ROOM NAME", ] for room in joined_rooms: send_message(chat_window, f"Hello everyone, I've just joined the room {room}!") while True: user_count = get_user_count(chat_window) for i in range(user_count): user_on_mic, user_nickname = get_user_info(chat_window, i) if user_on_mic: print(f"{user_nickname} is on the mic") time.sleep(10) if __name__ == "__main__": main()
iF someone wanna help me about this code it will be appreciate. I tried a lot of library for def send message but nothing…
December 27, 2019 at 1:44 pm #174549spid3rMemberloooll ….
very easy to do …. u need a virtual machine …… install in local the vpn, then use paltalk from virtual
September 24, 2018 at 4:24 pm #174571spid3rMemberHey Loco 🙂
thanks a lot, there was a problem with the registration of file .ocx , i fixed it but script dont work anymoreSeptember 23, 2018 at 4:26 pm #174573spid3rMemberhello guyz,
thanks for all programs. I have a question …. Do u have a program for rss feed on paltalk?
thanks in advance
-
AuthorPosts