kertser commited on
Commit
cf8e5a9
1 Parent(s): f3aee58

Upload WarOnline_Chat.py

Browse files
Files changed (1) hide show
  1. WarOnline_Chat.py +9 -1
WarOnline_Chat.py CHANGED
@@ -23,6 +23,11 @@ password = 'naP2tion'
23
  # Start a session to persist the login cookie across requests
24
  session = requests.Session()
25
 
 
 
 
 
 
26
  def compare_pages(url1, url2):
27
  #Compares 2 pages and returns True if they are the same
28
  return urllib.urlopen(url1).geturl() == urllib.urlopen(url2).geturl()
@@ -210,13 +215,16 @@ def WarOnlineBot():
210
  for msg in messagesForBot:
211
  if msg['messageID'].split('-')[-1] in messages_for_bot_IDs:
212
 
213
- originalQuote = quote
214
  quote = remove_non_english_russian_chars(msg['reply'])
215
  message = ""
216
 
217
  while not message:
218
  message = WarClient.getReply(message=quote)
219
 
 
 
 
220
  print('Quote: ', originalQuote)
221
  print('Reply: ', message)
222
 
 
23
  # Start a session to persist the login cookie across requests
24
  session = requests.Session()
25
 
26
+ def fixString(S):
27
+ # Substitute multiple commas with a single one
28
+ S = re.sub(",+", ",", S)
29
+ return S
30
+
31
  def compare_pages(url1, url2):
32
  #Compares 2 pages and returns True if they are the same
33
  return urllib.urlopen(url1).geturl() == urllib.urlopen(url2).geturl()
 
215
  for msg in messagesForBot:
216
  if msg['messageID'].split('-')[-1] in messages_for_bot_IDs:
217
 
218
+ originalQuote = msg['reply']
219
  quote = remove_non_english_russian_chars(msg['reply'])
220
  message = ""
221
 
222
  while not message:
223
  message = WarClient.getReply(message=quote)
224
 
225
+ # Post-processing fixes:
226
+ message = fixString(message)
227
+
228
  print('Quote: ', originalQuote)
229
  print('Reply: ', message)
230