- 🦏 Bing Bot Help Guide
- 💻 Tech Stuff for Nerds
- Go to the settings Google Sheet at go.osu.edu/bingsettings
- Check or uncheck the box next to any setting
- Go to the settings Google Sheet at go.osu.edu/bingsettings
- Go to the Nicknames tab
- Edit the text in the Nickname column
- Check if Bing is running by asking "Bing, are you alive?" or by visiting this link
- If Bing is not running, log into pythonanywhere.com, and extend Bing's life for 3 more months, reload the web app, and try again.
- Make sure the specific feature is turned on in the settings Google Sheet
- Make sure Bing is in the right GroupMe chat and has the correct GroupMe Bot ID and Access Token
- Check for errors in pythonanywhere
- If you are getting an error like this, that means an environment variable is missing. Add it to the .env file, then reload the web app
File "/usr/local/lib/python3.9/os.py", line 679, in __getitem__ raise KeyError(key) from None *************************************************** If you're seeing an import error and don't know why, we have a dedicated help page to help you debug: https://help.pythonanywhere.com/pages/DebuggingImportError/ ***************************************************
- If there is a bug in the code, consider asking a CSE friend to help update the code
- If you are getting an error like this, that means an environment variable is missing. Add it to the .env file, then reload the web app
- If Bing said "my crayon broke :(" when trying to draw something:
- Try again. Try again in a day or 2. If it still doesn't work, it likely means the API we use to generate images is no longer running, and we are out of luck :(
- If Bing said "i'm not feeling inspired right now. maybe later" when trying to make a meme:
- Try again. Try again in a day or 2. If it still doesn't work, it likely means an API or service we use to generate memes is no longer running, and we are out of luck :(
- This one feature (or multiple features) never works anymore. What gives?
- Bing relies upon many external services and APIs that are not under our control (especially pythonanywhere.com, the Google Sheets API, cron-job.org, and GroupMe). Any of these companies could choose to stop running their services at any time, and that part of Bing just wouldn't work anymore. All things must come to an end eventually :( It was fun while it lasted.
- Relevant Tom Scott video
For some reason, if you go to the Edit page of a GroupMe bot without changing the Avatar URL, the profile picture will stop working. To fix it, go back to the Edit page for Bing in dev.groupme.com, and set the profile picture URL to https://i.imgur.com/Kr6ti95.jpg
We use cron-job.org to run code at a scheduled time, like Bing's unsolicited messages. If you get one of these emails, you don't have to do anything. It's just letting you know that the code failed to run.
If you want to investigate why it failed and try to fix it, check the error logs.
If there is an error like this when running the cron job MEME, just wait a day or 2. it likely means the site api.allorigins.win is down.
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7fbd97939d10>
If there is an error like this when running the cron job ELON, same thing, just wait a day or 2. If it still doesn't work after a few days, it likely means Forbes changed the format of their website, and this message will no longer work going forward :(
AttributeError: 'NoneType' object has no attribute 'text'
To move Bing to a new chat, you need register a GroupMe bot for that chat:
- Log into dev.groupme.com using your GroupMe account
- Click Bots
- Click Create Bot
- Fill in the details:
- Choose the group this bot will live in: (Current H-Row Chat)
- Name:
Bing
- Callback URL:
https://bingbot.pythonanywhere.com
- Avatar URL:
https://i.imgur.com/Kr6ti95.jpg
- Click Submit
- Copy the Bot ID, and paste it into the GroupMe Bot ID field in the Tech Config tab of the settings Google Sheet
- Click Access Token at the top right corner of the screen of dev.groupme.com, copy it, and paste it into the GroupMe Access Token field in the Tech Config tab of the settings Google Sheet
- Have the previous "owner" of Bing log into dev.groupme.com with their GroupMe account and delete the bot from the old chat
- Important: Log into Bing's Gmail account and change the forwarding address to your email so you will get alerts once every 3 months when Bing's code is about to expire, so you can prevent that from happening.
All accounts and services are free. Just make sure Bing doesn't die every 3 months.
- Google Drive / Gmail / Google Cloud Platoform
- Settings Google Sheet
- Recieves emails
- Google Sheets API & credentials from GCP
- pythonanywhere
- Hosts the Python code that runs the web server
- GitHub
- To push code changes, use the bing-bot GitHub account. Colin (c-o-l-i-n) is the repo owner.
- cron-job.org
- Triggers unsolicited messages throughout the day
- OpenWeather
- Weather data API
- Imgflip
- Meme generator API
- Clarifai
- Copmuter vision API
- Stable Horde
- AI image generation API ("Log in with Google," display name: bing bot)
- Open Emoji and College Football Data
- Emoji search API and CFB data API
- There are no password-protected accounts for these sites, but you get a free API key by submitting an email address
The username/email for all accounts is hrow.bing.bot@gmail.com
The password for all accounts is (all lowercase) the nickname of the band, then the serial number on H-Caliber, then an exclamation point.
In free pythonanywhere accounts, web apps are disabled after 3 months unless you click the Run until 3 months from today button.
pythonanywhere will email hrow.bing.bot@gmail.com the link to keep things running 1 week before she is brutally murdered.
pythonanywhere provides a few different log files. Scroll all the way to the bottom for the latest log entries:
- Error log (the useful one)
- Access log
- Server log
You can technically just change the code files directly on the server, but the "right way" is making the changes in git:
- (In a terminal on your compter)
git clone https://github.com/c-o-l-i-n/bing-bot.git
cd bing-bot
- Create a Python virtual environment and install dependencies
python3 -m venv bing-env
source bing-env/bin/activate
pip install -r requirements.txt
touch credentials.json
to create the Google credientials file, then copy the contents from the server.touch .env
to create the.env
file, then add all environment variables. Copy the contents from the server, but these ones need to be different:PROXY_URL=''
GOOGLE_APPLICATION_CREDENTIALS='/path/on/your/computer/to/credentials.json'
- Make code changes
- Test the code by running
python src/app.py
- If you
pip install
any additional packages, make sure topip freeze > requirements.txt
to save them
git commit
any changes to themain
branchgit push
the changes- When prompted to log into GitHub, use Bing's GitHub account.
- Log into pythonanywhere, and open a console.
- Run the commands:
cd /home/bingbot/bing-bot
git pull
- If you get a an error while pulling, run
git reset --hard origin/main
to force pull - If you had to
pip install
additional packages in your changes, run:workon bing-env
pip install -r requirements.txt
- Go to the Web page
- Click Reload bingbot.pythonanywhere.com
If you see this message at the bottom of the server log, that means Bing was started successfully.
spawned 2 offload threads for uWSGI worker 1
If you have no clue what any of that means, ask a CSE major to do it.
You should be able to use the credentials.json currently on the server forever, but if you accidentally delete this file, you can create a new one from inside Google Cloud Platform.
-
Click here to go to the Keys page. If the link doesn't work:
- Log into the Google Cloud console, go to Menu ☰ > IAM & Admin > Service Accounts
- Choose the Bing Bot project, if prompted
- Click bing-bot-service-account@hrow-bing-bot.iam.gserviceaccount.com
- Click the KEYS tab
-
It is impossible to re-download an old key, so we have to make a new one. Click Keys > Add key > Create new key
-
Select JSON, then click Create
-
Your new public/private key pair is generated and downloaded to your machine as a new file. This file is the only copy of this key.
-
Click Close
-
Log into pythonanywhere.com, and go to the credentials.json file. If you get a 404 becuase the file was deleted, create a new one located at /home/bingbot/bing-bot/credentials.json
-
Open the JSON file you downloaded from GCP, copy the contents, and paste it into the file in pythonanywhere
-
Click Save
If the layout of GCP has changed and those steps are no loger valid, check the official instructions from Google.
These environment variables are require in pythonanywhere for Bing to work properly. They are set within the .env
file in the project root. After updating and saving the .env
file, reload the web app to apply the changes.
Key | Value | Notes |
---|---|---|
PROXY_URL |
http://proxy.server:3128 |
pythoneverywhere proxy server URL |
GOOGLE_APPLICATION_CREDENTIALS |
/home/bingbot/bing-bot/credentials.json |
Path to Google credentials file |
SPREADSHEET_ID |
(Settings Google Sheet ID from URL) | docs.google.com/spreadsheets/d/ID /edit |
OPENWEATHER_API_KEY |
(API key from OpenWeather) | Weather data API |
IMGFLIP_API_KEY |
(Password to Imgflip account) | Meme generator API |
CRON_JOB_ORG_API_KEY |
(API key from cron-job.org) | API to change unsolicited message times |
CLARIFAI_PERSONAL_ACCESS_TOKEN |
(PAT from Clarifai) | Computer vision API |
OPEN_EMOJI_API_KEY |
(API key from Open Emoji) | Emoji search API |
COLLEGE_FOOTBALL_API_KEY |
(API key from College Football Data) | College football data |
STABLE_HORDE_API_KEY |
(API key from Stable Horde) | AI image generation API |
Python web apps run on a WSGI server. There is a configuration file in pythonanywhere located at /var/www/bingbot_pythonanywhere_com_wsgi.py. It loads the environment variables from the .env
file and imports the Flask app.
If something happens to that file, replace it with this, and then reload the web app:
# load environment variables from .env file
import os
from dotenv import load_dotenv
project_folder = os.path.expanduser('/home/bingbot/bing-bot/')
load_dotenv(os.path.join(project_folder, '.env'))
# import Flask app
import sys
path = '/home/bingbot/bing-bot/src'
if path not in sys.path:
sys.path.append(path)
from app import app as application