Upload 2 files
Browse files- WarClient.py +3 -1
- WarOnline_Chat.py +13 -4
WarClient.py
CHANGED
|
@@ -6,9 +6,11 @@ PORT = 5000
|
|
| 6 |
def getReply(message):
|
| 7 |
# Returns a reply from the server
|
| 8 |
|
| 9 |
-
# Remove the
|
| 10 |
if message.endswith("."):
|
| 11 |
message = message.rstrip(".")
|
|
|
|
|
|
|
| 12 |
|
| 13 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
| 14 |
try:
|
|
|
|
| 6 |
def getReply(message):
|
| 7 |
# Returns a reply from the server
|
| 8 |
|
| 9 |
+
# Remove the endings that stuck the model
|
| 10 |
if message.endswith("."):
|
| 11 |
message = message.rstrip(".")
|
| 12 |
+
if message.endswith(" ?"):
|
| 13 |
+
message = message.replace(" ?","?")
|
| 14 |
|
| 15 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as client_socket:
|
| 16 |
try:
|
WarOnline_Chat.py
CHANGED
|
@@ -223,16 +223,25 @@ def WarOnlineBot():
|
|
| 223 |
if msg['messageID'].split('-')[-1] in messages_for_bot_IDs:
|
| 224 |
|
| 225 |
originalQuote = msg['reply']
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 227 |
message = ""
|
| 228 |
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
| 230 |
message = WarClient.getReply(message=quote)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
# Post-processing fixes:
|
| 233 |
message = fixString(message)
|
| 234 |
-
|
| 235 |
-
print('Quote: ', originalQuote)
|
| 236 |
print('Reply: ', message)
|
| 237 |
|
| 238 |
login(username=username, password=password, thread_url=thread_url)
|
|
|
|
| 223 |
if msg['messageID'].split('-')[-1] in messages_for_bot_IDs:
|
| 224 |
|
| 225 |
originalQuote = msg['reply']
|
| 226 |
+
if originalQuote == "": # Just images, no text
|
| 227 |
+
continue
|
| 228 |
+
else:
|
| 229 |
+
quote = remove_non_english_russian_chars(msg['reply'])
|
| 230 |
+
|
| 231 |
message = ""
|
| 232 |
|
| 233 |
+
print('Quote: ', originalQuote)
|
| 234 |
+
|
| 235 |
+
FailureCounter = 0 # In case there is a bug in the model
|
| 236 |
+
while (not message) and (FailureCounter<3):
|
| 237 |
message = WarClient.getReply(message=quote)
|
| 238 |
+
FailureCounter+=1
|
| 239 |
+
|
| 240 |
+
if FailureCounter == 3:
|
| 241 |
+
continue # Skip that answer
|
| 242 |
|
| 243 |
# Post-processing fixes:
|
| 244 |
message = fixString(message)
|
|
|
|
|
|
|
| 245 |
print('Reply: ', message)
|
| 246 |
|
| 247 |
login(username=username, password=password, thread_url=thread_url)
|