kertser commited on
Commit
3152d9e
1 Parent(s): 608edc4

Upload WarOnline_Chat.py

Browse files
Files changed (1) hide show
  1. WarOnline_Chat.py +16 -12
WarOnline_Chat.py CHANGED
@@ -5,8 +5,9 @@ from bs4 import BeautifulSoup
5
 
6
  # Define the login URL and the thread URL
7
  login_url = 'https://waronline.org/fora/index.php?login/login'
8
- thread_url = 'https://waronline.org/fora/index.php?threads/Творчество-роботов-нейросети-и-т-п.17617/'
9
- #thread_url = 'https://waronline.org/fora/index.php?threads/%D0%A2%D0%B2%D0%BE%D1%80%D1%87%D0%B5%D1%81%D1%82%D0%B2%D0%BE-%D1%80%D0%BE%D0%B1%D0%BE%D1%82%D0%BE%D0%B2-%D0%BD%D0%B5%D0%B9%D1%80%D0%BE%D1%81%D0%B5%D1%82%D0%B8-%D0%B8-%D1%82-%D0%BF.17617/'
 
10
 
11
  # Define the login credentials
12
  username = 'WarBot'
@@ -44,17 +45,20 @@ soup = BeautifulSoup(response.text, 'html.parser')
44
  # Extract the _xfToken value from the hidden form field
45
  xf_token = soup.find('input', {'name': '_xfToken'}).get('value')
46
 
47
- # Post a message to the thread
48
- post_data = {
49
- 'message_html': 'Hello world!', # Replace with your message
50
- 'last_date': '', # Leave empty for a new post
51
- 'watch_thread': '1', # Subscribe to the thread (optional)
52
- '_xfToken': xf_token, # Retrieve the token from the page HTML '1676385710,1cdf871cad6915a8f95aa9ddb0e03cc9'
53
- '_xfRequestUri': thread_url, # Retrieve from the page HTML
54
- '_xfWithData': '1', # Required for some XenForo versions
55
- '_xfResponseType': 'json' # Receive the response in JSON format
 
 
56
  }
57
- response = session.post(thread_url, data=post_data)
 
58
 
59
  # Check if the post was successful
60
  if not response.ok:
 
5
 
6
  # Define the login URL and the thread URL
7
  login_url = 'https://waronline.org/fora/index.php?login/login'
8
+ thread_url = 'https://waronline.org/fora/index.php?threads/warbot-playground.17636/'
9
+
10
+ message = "Hello World"
11
 
12
  # Define the login credentials
13
  username = 'WarBot'
 
45
  # Extract the _xfToken value from the hidden form field
46
  xf_token = soup.find('input', {'name': '_xfToken'}).get('value')
47
 
48
+ post_url = "https://waronline.org/fora/index.php?threads/warbot-playground.17636/add-reply"
49
+
50
+ # Construct the message data for the POST request
51
+ message_data = {
52
+ '_xfToken': xf_token,
53
+ 'message': message,
54
+ 'attachment_hash': '',
55
+ 'last_date': '',
56
+ '_xfRequestUri': post_url,
57
+ '_xfWithData': '1',
58
+ '_xfResponseType': 'json'
59
  }
60
+
61
+ response = session.post(post_url, data=message_data)
62
 
63
  # Check if the post was successful
64
  if not response.ok: