Chatlog

Chatlog is an esoteric programming language made by User:Retro.
==Usage==
A Chatlog program is split into multiple lines. The first line doesn't have to, but should be a title for the program.
Any line that shouldn't be treated as an instruction, or is a comment, should begin with the character #.
For a Chatlog program to work, at least 1 user must join the chatlog before any instructions.
Any amount of users can join or leave, but every user must leave before the chatlog ends.
For the syntax examples, assume "username" is the username, and "message" is the message, both of which can be changed.
The syntax for an user joining would be: username joined
After you at least have 1 user that has joined, you may execute brainfuck instructions by adding a message syntax to the next line.
The syntax for an user chatting a message would be: [username]: message
The actual message does not matter, but the length of it does.
The brainfuck instruction to execute is picked out from an array by using the result of a modulo operation with the message length and 8 (the amount of brainfuck instructions).
The array is in this order: '>', '<', '+', '-', '.', ',', '[', ']'.
Thus, having a message like "hi", with the length 2, would pick the third instruction from the list, which is +, assuming the language you implement Chatlog in counts from 0.
The brainfuck instructions are executed after going through the Chatlog program.
Because of the modulo operation, if the message length is higher than the index of the last instruction, ], it will loop over back to 0, which chooses > and so on.
As said above, before the Chatlog program ends, all users must leave.
This can be done in any place of the program, but the last user should leave after the last instruction.
The syntax for an user leaving would be: username left
==Examples==
A hello world program in Chatlog
(Note that the messages can be changed to anything, as long as they remain the same length, but in this example any messages use only the letter "a")
(Only one user is required, however two users were used in this example)
 Chatlog - Hello World! - 11.02.2021
 
 User_One joined
 User_Two joined
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaaaaaa
 [User_Two]: aaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaa
 [User_Two]: aaaaaaaaa
 [User_One]: aaaaaaaaa
 [User_Two]: aaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaaa
 [User_Two]: aaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaa
 [User_One]: aaaaaaaaaaa
 [User_Two]: aaaaaaaaaaaa
 [User_One]: aaaaaaaa
 [User_Two]: aaaaaaaaaa
 [User_One]: aaaaaaaaaaaa
 [User_Two]: aaaaaaaa
 [User_One]: aaaaaaaaaaaa
 User_One left
 User_Two left
==Interpreter==
Here is the Chatlog interpreter, written in Python 3.
 import re
 ins = ['>','<','+','-','.',',','[',']']
 prg = """Enter Chatlog program here!"""
 
 def evalb(code):
 array = [0]
 pointerLocation = 0
 i = 0
 c = 0
 while i < len(code):
 if code[i] == '<':
 if pointerLocation > 0:
 pointerLocation -= 1
 elif code[i] == '>':
 pointerLocation += 1
 if len(array) <= pointerLocation:
 array.append(0)
 elif code[i] == '+':
 array[pointerLocation] += 1
 elif code[i] == '-':
 if array[pointerLocation] > 0:
 array[pointerLocation] -= 1
 elif code[i] == '.':
 print(chr(array[pointerLocation]),end=)
 elif code[i] == ',':
 x = input()
 array[pointerLocation] = ord(x)
 elif code[i] == '[':
 if array[pointerLocation] == 0:
 open_braces = 1
 while open_braces > 0:
 i += 1
 if code[i] == '[':
 open_braces += 1
 elif code[i] == ']':
 open_braces -= 1
 elif code[i] == ']':
 open_braces = 1
 while open_braces > 0:
 i -= 1
 if code[i] == '[':
 open_braces -= 1
 elif code[i] == ']':
 open_braces += 1
 i -= 1
 i += 1
 
 users = []
 code = ''
 for line in prg.split('\n'):
 try:
 if line[0] == '#':
 continue
 except:
 pass
 chatm = re.match('\[(.+)\]: (.+)',line)
 joinedm = re.match('(.+) joined',line)
 leftm = re.match('(.+) left',line)
 if joinedm:
 user = list(joinedm.groups())[0]
 if user in users:
 raise Exception('User '+user+' joined, but already was in')
 else:
 users.append(user)
 elif leftm:
 user = list(leftm.groups())[0]
 if user in users:
 users.remove(user)
 else:
 raise Exception('User '+user+' left, but never joined')
 elif chatm:
 user,msg = chatm.groups()
 i = ins[len(msg)%8]
 code = code + i
 if len(users) > 0:
 raise Exception('Every user must leave before the chatlog ends: '+', '.join(users))
 evalb(code)
Category:Brainfuck equivalents
Category:2021
Category:Languages
Category:Turing complete
Category:Brainfuck derivatives
Category:Thematic