randomness fix

This commit is contained in:
array-in-a-matrix 2022-02-14 13:22:10 -05:00
parent d0ce4a638f
commit fb68614f66
2 changed files with 6 additions and 6 deletions

View file

@ -1,7 +1,7 @@
# Instagram Markov Chatbot
An Instagram chat bot which generates new sentences and sends them in direct messages.
Used code from [here](https://towardsdatascience.com/simulating-text-with-markov-chains-in-python-1a27e6d13fc6) as a base.
Used code from [here](https://towardsdatascience.com/simulating-text-with-markov-chains-in-python-1a27e6d13fc6) as a base. If the dataset is too small the bot will break.
## Dependancy
- firefox
@ -27,6 +27,6 @@ Used code from [here](https://towardsdatascience.com/simulating-text-with-markov
### Command-line
- **`headless`**
- If you want to run the program headlessly append `MOZ_HEADLESS=1` to the beginning of the command.
- If you want to run the program headlessly append `MOZ_HEADLESS=1` to the beginning of the python command.
- **`message length`**
- Optional argument (integer) that determine the length of the sentence. If no argument is provided or a non integer number was given, messages will generate with variable length between 1 and 30.

View file

@ -35,8 +35,8 @@ sleep(5)
browser.find_element(By.CSS_SELECTOR, "button.aOOlW:nth-child(2)").click()
sleep(5)
# browser.find_element(
# By.XPATH, "/html/body/div[1]/section/div/div[2]/div/div/div[1]/div[2]/div/div/div/div/div[1]/a").click()
browser.find_element(
By.XPATH, "/html/body/div[1]/section/div/div[2]/div/div/div[1]/div[2]/div/div/div/div/div[1]/a").click()
# selects most recent chat ^ chat order
while True:
@ -51,9 +51,9 @@ while True:
if cmd_length.isdigit():
message = markov(int(cmd_length) - 1)
else:
message = markov(np.random.randint(30))
message = markov(randint(30))
except IndexError:
message = markov(np.random.randint(30))
message = markov(randint(30))
sleep(5)
print(message)