INNER CODE UNIT · Python

find_chat_room

zapek/Xeres · scripts/bot/bot.py:146

def find_chat_room(name, room_array):
	for room in room_array:
		if room['name'] == name:
			return room['id']
	return 0


def leave_room(id):
	r = requests.delete(XERES_API_URL + XERES_API_PREFIX + "/chat/rooms/" + str(id) + "/subscription")
	if r.status_code != 204:
		raise RuntimeError(f"Couldn't leave room: {r.status_code}")


def upload_avatar(path):
	with open(path, 'rb') as img:
		files = [('file', (AVATAR, img, "image/png"))]
		r = requests.post(XERES_API_URL + XERES_API_PREFIX + "/identities/1/image", data={}, files=files)
		if r.status_code != 201:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…