
    quj                         S r SSK7  S rSr " S S5      r " S S5      r " S	 S5      rS
 r\" SS9S 5       r	\" SS9S 5       r	g)u   
✘ Commands Available

• `{i}bf`
    Text to Brainfuck String Generator with text or reply.

• `{i}rbf`
    Brainfuck Interpreter with string or reply.
   )*c                     [        U 5      nUR                  5       (       a'  UR                  5         UR                  5       (       a  M'  UR                  R	                  5       $ N)BrainfuckInterpreter	availablestepoutputread)commandsinterpreters     %/root/TeamUltroid/addons/brainfuck.pyevaluater      sO    &x0K



!
! 


!
! ""$$    r   c                   4    \ rS rSrSS jrS rSS jrS rSrg)	IOStream   Nc                 $    U=(       d    SU l         g N _bufferselfdatas     r   __init__IOStream.__init__   s    zrr   c                 ,    [        U R                  5      $ r   )lenr   r   s    r   __len__IOStream.__len__    s    4<<  r   c                     U(       d  U R                   nSU l         U$ U R                   S U nU R                   US  U l         U$ r   r   )r   lengthr   s      r   r
   IOStream.read#   sE    <<DDL
  <<(D<<0DLr   c                 .    U =R                   U-  sl         g r   r   r   s     r   writeIOStream.write-   s    r   r   r   )	__name__
__module____qualname____firstlineno__r   r    r
   r&   __static_attributes__ r   r   r   r      s    "!r   r   c                   l    \ rS rSrS rS rS\S\4S jrS rS r	S	\4S
 jr
S rS rS\4S jrS rSrg)IncrementalByteCellArray1   c                 "    S/U l         SU l        g N    
byte_cellsdata_pointerr   s    r   r   !IncrementalByteCellArray.__init__2   s    #r   c                     [        U R                  5      nXS-
  :  a  U R                  X-
  S-   5        U R                  U   $ Nr   r   r5   extend)r   itemcell_amounts      r   __getitem__$IncrementalByteCellArray.__getitem__6   s=    $//*/!KK*Q./t$$r   keyvaluec                     [        U R                  5      nXS-
  :  a  U R                  X-
  S-   5        X R                  U'   g r9   r:   )r   r@   rA   r=   s       r   __setitem__$IncrementalByteCellArray.__setitem__=   s:    $//*q KK)A-.$r   c                 ,    [        U R                  5      $ r   )r   r5   r   s    r   r     IncrementalByteCellArray.__len__D   s    4??##r   c                 6    U R                   R                  5       $ r   )r5   __repr__r   s    r   rH   !IncrementalByteCellArray.__repr__G   s    ''))r   sizec                 6    U =R                   S/U-  -  sl         g r2   )r5   )r   rJ   s     r   r;   IncrementalByteCellArray.extendJ   s    A3:%r   c                 R    U R                  5       S-   S-  nU R                  U5        g )Nr      getsetr   new_vals     r   	increment"IncrementalByteCellArray.incrementM   s"    88:>S(r   c                 \    U R                  5       S-
  nUS:  a  SnU R                  U5        g )Nr   r3      rO   rR   s     r   	decrement"IncrementalByteCellArray.decrementQ   s)    ((*q.Q;Gr   c                 <    U R                  U R                  U5        g r   )rC   r6   )r   rA   s     r   rQ   IncrementalByteCellArray.setX   s    **E2r   c                 8    U R                  U R                  5      $ r   )r>   r6   r   s    r   rP   IncrementalByteCellArray.get[   s     1 122r   r4   N)r(   r)   r*   r+   r   r>   intrC   r    rH   r;   rT   rX   rQ   rP   r,   r-   r   r   r/   r/   1   sP    %%s %3 %$*&3 &3 33r   r/   c                   L    \ rS rSrS\4S jrS rS rSS jrS\	4S	 jr
S
 rSrg)r   _   r   c                     Xl         [        5       U l        [        5       U l        SU l        [        5       U l        / U l        g r2   )	_commandsr   inputr	   instruction_pointerr/   cells_opening_bracket_indexes)r   r   s     r   r   BrainfuckInterpreter.__init__`   s3    !Z
j#$ -/
(*%r   c                     U R                   U R                  S  nSnU R                  nU H)  nUS:X  a  US-  nOUS:X  a  US-  nUS:X  a  Us  $ US-  nM+     g )Nr3   [r   ]rb   rd   )r   remaining_commandsloop_counterindexcommands        r   _look_forward"BrainfuckInterpreter._look_forwardk   sl    !^^D,D,D,FG(()G#~!C!q QJE *r   c                    U R                   U R                     nUS:X  a   U R                  =R                  S-  sl        g US:X  a   U R                  =R                  S-  sl        g US:X  a  U R                  R	                  5         g US:X  a  U R                  R                  5         g US:X  a=  U R                  R                  [        U R                  R                  5       5      5        g US:X  a5  U R                  R                  U R                  R                  S5      5        g US:X  a[  U R                  R                  5       S	:X  a  U R                  5       nX l        g U R                  R                  U R                  5        g US
:X  a`  U R                  R                  5       S	:w  a&  U R                  R!                  S5      nUS-
  U l        g U R                  R!                  S5        g g )N>r   <+-.,ri   r3   rj   )rb   rd   re   r6   rT   rX   r	   r&   chrrP   rQ   rc   r
   rp   rf   appendpop)r   instructionloop_endopening_bracket_indexs       r   
_interpretBrainfuckInterpreter._interpret{   sp   nnT%=%=>#JJ##q(#CJJ##q(#CJJ  "CJJ  "CKKc$**.."234CJJNN4::??1-.Czz~~1$--/+3(--44T5M5MNCzz~~1$(,(E(E(I(I"(M%+@1+D(--11"5  r   returnNc                 N    U R                  5         U =R                  S-  sl        g r9   )r   rd   r   s    r   r   BrainfuckInterpreter.step   s      A% r   c                 H    U R                   [        U R                  5      :  + $ r   )rd   r   rb   r   s    r   r   BrainfuckInterpreter.available   s    ++s4>>/BBBr   c                 4    U R                   U R                     $ r   rk   r   s    r   ro   BrainfuckInterpreter.command   s    ~~d6677r   )rb   rf   re   rc   rd   r	   )r   N)r(   r)   r*   r+   strr   rp   r   r   boolr   ro   r,   r-   r   r   r   r   _   s0    	+ 	+ 6:&C4 C8r   c                     / nU  H>  nUR                  SS[        U5      S-  -  -   S-   S[        U5      S-  -  -   S-   5        M@     SR                  U5      $ )Nz[-]>[-]<ru   
   z[>++++++++++<-]>z.<r   )r{   ordjoin)textitemscs      r   bfr      sn    Ec!fl#% ! c!frk"$ 		
  775>r   r   )patternc                   #    U R                   SS  nU(       dI  U R                  (       a%  U R                  5       I S h  vN nUR                  nO[	        U SSS9I S h  vN $ U R                  [        U5      5      I S h  vN   g  NG N) N	7f)N   Give me some text lol   time)r   reply_to_msg_idget_reply_messagemessageeodeorr   eventinput_previous_messages      r   _r      sv      ZZ^F  %*%<%<%>>%--FU$;!DDD
))BvJ
	  ? Es3   ;BBBB!B?B	 BB	Brbfc                   #    U R                   SS  nU(       dI  U R                  (       a%  U R                  5       I S h  vN nUR                  nO[	        U SSS9I S h  vN $ U R                  [        U5       5      I S h  vN   g  NH N* N	7f)Nr   r   r   )r   r   r   r   r   r   r   r   s      r   r   r      sz      ZZ^F  %*%<%<%>>%--FU$;!DDD
))x'(
***	  ? E*s3   ;BBBB"B B
BB
BN)
__doc__r   r   __all__r   r/   r   r   ultroid_cmdr   r-   r   r   <module>r      sz    % ! *+3 +3\A8 A8H
    ++r   