Skip to content
Permalink
master
Go to file
Latest commit 95a8f62 Feb 5, 2017 History
Password support managed to accidentally store password in the place
where the bot keeps its nickname. Move nickname saving from the
save-loader-settings block into the login packet construction block,
since that's the convenient fix, and avoids needing to swap strings.
1 contributor

Users who have contributed to this file

499 lines (460 sloc) 23.7 KB
v load permanent fingerprints and remap v 0*aa0)S+*aa20**aaa*aa" "<
>"GNIF"4#v($$v > 0"89b.tognuf"#@i$$$$ v
v ># #<0a".detroppus ton GNIF">:#,_@ (^reload)
>"NRTS"4#v($$'S'UZv
v ZQ'C'># #<0a".detroppus ton NRTS">:#,_@
>"KCOS"4 #v($$v
vZT'O'YL'YA'># #<0a".detroppus ton KCOS">:#,_@
>"EKCS"4#v($$v
v YP'># #<0a".detroppus ton EKCS">:#,_@
initialize funge-space state
>'G'KZ'P'BZ'L'IZ"ELIF"4#v(0000"tad.tognuf/atad"#vOv
v -a0 p***aaa200 <) ># ># ># ># #< >0a".dab "v
> >:0\0\p v defs v _^#:G^#g 15p1e :<-a0 p15< v"State"<
v$_^#!: +1 < > 1-I0e1gB $ 1+ : | >:#,_51gC@
v) Cg15 p\0\0 $$$># ^#<000< >$2aaa***v
>'KY'BY'IYv v:G^#Bg1e0I-1 _^#:G^#g15 p1e: < +2<
v < >!#^_1-IV0e1g1+:e1pp$ 1>: v $
> 1+^
| gg1e: pg1e \$\VI-1_v#:Gv#g15 <
> > ^
> ^
>000aa+-pv
v < TODO FIXME: load ignore from statefile
try to load REXP for ignores
>"PXER"4#v($$'C'BZ'CY'FY00aa+-g!#v_00aa+-G7#vBv
vp-+aa000< $
v < < <
save settings from the loader
> f2P 41p#vIv
v p17V p10>#<0a".sserdda PI dilavnI">:#,_@
non-persistent state init
> 000f-p 010f-p 0"cri.nib.ledom"00fe+-P v
v p-+aa000 P-+ff00"tokens.bin.irc"0 <
load the babble model list
> 0ccc**00"tsil.selyts"#vi$$$$v
v < <
Build initial login packet at (0,0)
>:!#v_0" SSAP"00PN5+11p5v
vp11<+1p0\a:+1p0\d:g11P0<
>f1Pf1GN51p0" KCIN"11g:5+11p0P11g0P11g51g+:d\0p1+:a\0p v
vp11++2*93g11P0g11"USER fungot * * :fungot-0.1"da0p11+1<
Create a socket, set SO_KEEPALIVE and connect to server
>221#vSv
vp12:>#<0a".tekcos a etaerc ot elbanU">:#,_@
>:1\3\#vTv
v >#<0a".deliaf EVILAPEEK_OS gnitteS">:#,_@
>2 71g 01g #vCv
v >#<0a".tcennoc ot elbanU">:#,_@
Send out the registration packet.
>0011g21g#vW11g-!#v_0a".deliaf dnes kciN">:#,_@
v ># #<^
Main dispatch loop: parse IRC messages.
>0:02p12pv
v < > >0a".deliaf daer CRI">:#,_@
>12g0fff**21g#^R:#v_^
vp11 < .
0 >v .
>:11g\`| coming here if this byte needs to be processed emptycmd .
v <> :12g+0g :a-#v_ v and here if newline v 0< .
# >:d-#v_> $:0\12g+0p 02g0G03P :12g+1+ 02p 03g!| .
^+1$ < < .
end of bytes from irc .
>12g+12pv updated eptr .
v < toggle to print raw: .
have to memmove message v$_,#! #:<"RAW >>> "0 < .
v +1 p0 -g20 < >03G>:#,_$v .
>02g >:12g\`! #v_ ::0g ^ v" <<<"a0< .
^ p200p21-g20< >:#,_$ v .
0 <-- dummy value to discard up there .
irc message handler ^ return here when finished .
v># ^# < .
.
check for prefix v +1< .
> 03g':-#v_104p 1>:3g" "-| .
v 0 p400< v P41G31p3\0:< .
v +1 < .
.
command start pos at stack .
find next space or 0 .
> :31p>:3g:#v_ >\ :0\3p 31g3G15P v .
>:" "-!| .
^ +1$< .
v _v#! p13+1 < .
0 1
0 0 command ends in nonzero, so at least one option
5 5 parse the options in a loop, :opt ends
p p v <
>31g :3g':-#^_ 1+ 0\:v
>:3g:#v_ >\ :0\3p 31g >3G 05g5+0\P v
>:" "-!|
^ +1$<
^ p50+1g50 _v# p13+1 <
v < end of options
irc message has been split, process it
^ _v#!-e<
ping? pong! > v
> 15G0"GNIP"Q#v_0ad"tognuf: GNOP"03P03e21g#vW^
v < v"Pong send failed."a0<
>:#,_@
^ < < <
privmsg!
> 15G0"GSMVIRP"Q| parse privmsg target/prefix for reply
>06g'#-!#v_ 04g!| v+1 < > > ^
v <p4\!'<> 1>:4g:!#v_ '!- |v1 6 < privmsg print
| P60 G41 <1p4\0:<>p0v_^#`g16:*2*ff_^#-g17g16 <
v _ d-if $># $61g:d\3p1+: a\3p1+ v
check the ignore list ^W^# g 12\3\0 <
> ^
> 04g!#v_00aa+-g!#v_ 14G0#vE 51p>51g:!#^_1-51pv
v < < < ^ P51<
build reply prefix
v_v#!-g14 < >0": "06GA0" GSMVIRP"A v
cmdchk ^g70 P30 p17p16:N <
non-command privmsg handling
catch-all own-name hook
looptest
vP-f01G41 ># 0# v# <
>10f-G14GQ#^_00f-g1+>:00f-p3`!#^_61g71p ^
$ >$)'KY'BY ^
^ < YB'YK' <)< <Cg17 $<
>f1G07GF!#^_>_v>'G'KZ'P'BZ"ELIF"4#^( 080 00fe+-K #^O71p 882**e1p01-v
v:g4:<1_v#g40< # >#v ^# p9\2+1_v#`*ff:g18 < p180p901p9:<
v_$$ v> ^^ P3p16+g< < v _v#! -2g9 < ^ <
' >0':14GAN51p61g:51 ^ >71g00#vS$81gv 0
! >1+^ p > > > > > > ^
>-#^_0\4^ > ^ v p15g9:<-1 <
v p17O^# K -+ff00 080Cg17< >:!#v_ 71g\0\#^S$^
> 0 > :9g:2- #v_$$71gC^ ^p9+ < pickword:
>1p3B1+^ >281g1 ^ >$$ 71g091gc1g8*+ #^S5 #^R$v
^6+g15:g16 p15N < v 0< v0< v+1/3g18_v# g80 <
v_^#!`+< 1?v#<4?v#<
^ 2< ^8<
0 ^ 3 < ^c <
f > 0v vc0 <> ^
> \4*#v? 1>+\1-:#v_$ 18ge1g* 28g+e 1g*v p
v<> 2^ vp15%+g84 *g1e+ g83< 9
^ >#< 3^ p
>51g\-#^ 5# 1# p#< > 71g 8 #^R $ v 1
^_v#!`g1 5:+g87*g1e+g86*g1e+g85*g1eg84< 8
>$ 08g e1g*18g+e1g*28g+e1g*38g+ 81g1+:^
^ < <
> ^ 0SE":,)'..!f"('?/s
>:98 +`#v_ 0\ jvvvvvvvvvvvvvvvvvv
v S^#*4\0\g1 7\0< ^ " fno" "rd"< >"): "^
>4#^R18ge1g* 28g+v^ << >'/ ^
vg80 S^#\0 +g83 *g1e<^ "'< >'? ^
>:51p#^R$ 51gv ^ :'< >"' " ^
v :-1 < ^ ,'< >"( " ^
> 8g\ :#^_ $" " ^ )'< >'"" " ^
^ "'"< >"(: " ^
^ .'< >'! ^
>"..." ^
>$ > ^ <
v3*g1e+g82*g1e+g81*g1eg80 $R^#4g17 <^ < <
>8g+:c1p1-b1p0a1p71g#^L91p$ > a1gb1g`#v_ 71g 0 a1gb1g+2/ 8*91g+#^Sv
> ^ >0^ 8
cur> ^ p1b-1/2+g1bg1a $_v#`g15: +g83*g1e+g82*g1e+g81*g1eg80 $R^#<
>51g\`#v_ 48ge1g*58g+e1g*68g+e1g*78g+ ^
cur< ^ p1a+1/2+g1bg1a < ^match
check for owner-prefix to make it easier for other commands
>04g!#v_f2G14GQ#v_v
v p150< <
v p151 <
actual command-character commands
^ < < < <
"reload" >51g!#^_ "SYOT"4#^( ^
>17G 0"daoler"Q!| prefix check ^W^# g12\3\0+bg16P3g16"Reloaded."ad0<
v < >^
^ < <
"raw" >v > 51g!#^_ 57GN51p03P 51g:d\3p1+:a\3p1+ v
>17GN3`|>4L0" war"v > >0a".deliaf dnes waR" >:#,_@
v P51<0 _^#Q < ^_^#!-W^# g12\3\0: <
^ < < <
"code" >v > 51g!#^_ 0"R0"67GA08P "RBUS"4#^(v ^ ) <
>17GN4` |>5L0" edoc"v v YO'YJ'YA'<
v P51<0 _^#Q < > 080C 'R'AZ'R'JZ'R'OZ ^
^ < >#<$#)<
"save" >51g!#^_ > 'G'KZ'P'BZ"ELIF"4#^( 001 v
>17G0"evas"Q!| vPv#AK\0\a\0\g15:<-a0 p15O^#"data/fungot.dat"0 <
v < >$ 1+:#^_$vv_v#gg1e:$Pv#AUgg1e\a\0\g15 <
v B80"Fail: "<S'0$C< v!g\0:< ***aaa2 <> v :
v B80"OK."0 Cg15 $_v ^+1 $< v$\ < >1+ ^
>:51g\0\a\0\KA#vP$1+:e1 p:0\g51g\0\a\UA#vP$1^
^ P'0$C< < <
^ ># #< )'KY'BY 08G>N51p61g:51g+61p3P ^
"ignor">v >51g!#^_77g:#v_$00aa+-G ^
>17GN5` |>6 L0"erongi" v>" "-#v_87G7#vB87G00aa+-P 0".KO"^
v P51<0_^#Q <v < >U0" :er daB"A ^
v <
v
"bool" >?>0".oN" 61g:3+61p3P> ^
>17G0"loob"Q!|>0".seY" 61g:4+61p3P^
v <
>$ ^
"style">v >$ 67g:#v_$ 0":elbaliavA" 61g:a+61p3P ccc**v
>17GN4` |>5L0"elyts"v >" "-v v p15N " "G\0: _^#g\0:<+1 < p3p16<
v P51<0 _^#Q <010 _ccc**v > 61g:51g+61p3P :0\Ga0ef+-GQ#^_'*61g:1+^
> 1+ >:0\g#v_$0".dnuof toN">N51p 61g:51g+61p3P ^
^ _v#QG77G\0:< ^G77 <
vP-+ef00A"model.bin."0G77 >#pa#1<
>77G0".nib.snekot"A00ff+-P 77GN1+a1gG0" :elyts detceleS"A 77P15P ^
"str" >v > 67g" "-!#v_> > >0"]txet[ dda/tes/teg 9-0 rts"41gv
>17GN3`|>4L0" rts"vv0'g75< $ $ $ v"Usage: "<
v P51<0 _^#Q <>- :9`| >N51p61g:51g+61p3P ^
>:0\`#^_a- 7>:7g:" "-#v_$ v
^ >$ ^v p800 $_^#! \+1\<
v_v#Q"set"0G77 _v#Q"get"0G77 < P80G7+1 p7\0: <
>7 7G0"dda"Q | > >:0\g!#v_ 0\G >N51p 61g:51g+61p3P^
>51p08G051gP 0" :teS"61g:5+61p3P 51g^ >0".ytpmE"^
>:51p 0\GNe1p 051gP 08Ge1g51gP 0".deddA"61g:6+61p3P ^
> 61v
^ < v$_^#`g16:*2*ff<p |
"bf" >v > 61g71p 0480 vv ># v# <
>17GN2`|>3L0" fb"vv\0:_v#!-!'_v#:g7:<4< vp3\a:+1p3\d:g16< < |#
v P51<0 _^#Q <>7p v> 1+^ >1+0\3\21g#vW$v |-g17g16 <
v p15+1 <-1 $< ^ < < < #
v g8080 <
|
"ul" >v v $ <
> 17GN2`|>3L0" lu"Q#v_v #
v P51<0 < -
v 1842 < 2
v g8080 < :
^ < <
"show">v >$ 2aaa *** 57g:#v_$>:0\g#v_$ 0^
> 17GN3`|>4L0"wohs"v ^ $<| -" "< ^ +2 <>:0\" "\0\GAN51p v
v P51<0 _^#Q < >2+ >:0\G67GQv ^ p16+g15g16P3g16 < >+
^ _^#g\0: _ 1+:0\g:#v_$e1p1> :e1gg0\ jvvvvvvv
not bf v < + > $$0^
> 61g:51g+61p3P v 2 $$''''
^ p15 NU < > ^ [].,
> > >61g:1+61p3P :1-#^_$ ^ P3p16+1:g16 < <<<<
- < ^ >'< 01
: ' ' ^+'_^#g150_v#!`p1c:<**288_v#g15:gg1e+1:p15<<
1 ^_^#g150-\*2g1c< ^**5aa <
-
^ $$ _$ 1\GN51p 61g:51g+61p 3P 0^
ul
v $<
"def" >v > 15>:7g:#v_>$$$0">edoc< >gnal< >dnammoc< fed" 41g" :egas"v
> 17GN3`|>4L0" fed"]+1< > " "-#v_:0\7p1+57G08P:>:7g:#v_$ ^ vP3g16p15NU'<
v P51<0 _^#Q < ^ < >1+^ >61g51g+61p f^
v\0:_v#g\0:< ***2aaa P90G7\+1p7\0:_^# !-" "< |
G > :51p08G051gP v > :0\0\p:0\1\p ^ v"Defined."0$ <
>08GQ!#v_2+^ v p\0\0+2: < ^ < >61g3Pv #
> >1+ 09G0"fb"Q!#v_ 09G0"lu"Q!#v_ ^ v+8g16< -
v \ p\0\0: < \0< >61p 1^1
code URL handlers hook here ^ \1 < :
>e1p\v
v <
"str:">v >$ :5+7g!#v_ > 0".LRU :rts daB"61g:d+61p3P $$$$ f^
> :7GN3`|>4L0":rts"vvg7+4:< > >$^
v P51<0 _^#Q <>'0-:0\`|
>:9`|
v P7g15G\0-a \p15:\ <
"http://srv/path">:7+:>:7g:#v_$$ 0".LRU daB"61g:8+61p3P $$$$ f^
v :7G7L0"//:ptth"Q!| >1+^> :7G 0fP 0\7p v URL parsed
v < ^ _^#-/'<>0".dnuo" "f ton tsoH"61g:f+61p3P $$$ f^
v H^# G7 <
>>\v
v g1e< finished with URL handlers, restore args
^ <
defines $
> 1>:7g:" "-#v_$:0\7p1+>51p 2aaa*** >:0\g!#^_ :0\ v
^+1 _ ^ ^+2 _v#QG71G <
v g\0: \0 +1 <
PROG EXECS:
exec prog-copy if not at line 8 (maybe check lang)
>\:8-!#v_:e1p 0\g08p 1> ::e1gg: !#v_\8p v
v <$< ^ +1 <
: ^ p8\<
!
#
>$ aaaaaa*****81p 88+:*91p aaa**:a1p >1-:0\v
|bf exec v10 $_^#!:p9<
v\+1\g8:<+1 p18-1_v#:g18 <
j >$$$ 0"!emit fo tuo... " 61g3P 61g88++61p ^
>$$ ^
>:8gb1p\b1g+a1g%\ ^ <> ret^
>:8gb1p\::9gb1g+91g%\9p\ ^ +-
>\:9g v >\ ^ [
>\:9g!>#^_\8g ^ ] >$$$$0"... "61g1-3P61g3+61p ^
>\:9g:a-: #v_$ >$'.> 61g:1+61p:ff*`| out
>\:51g:7g:#v_v>3-!#^_ ^ ^ \ p3 < in
: > \1+51pv ^ <
1 >$ >91g+91g% \9p\ ^
-
!
#
>$ ffaa***81p 009p019p 091p v
|ul exec >0"!kcats fo tuo... " 61g3P61g89++61p ^
v 1 < ^$ <
> :8g :#v_$ ^
+ >81g1-:81p#v_$$ 0"!emit fo tuo... " 61g3P 61g88++61p ^
1v_v#`0+ *:*dc g19 <
> $$ 0"!kcats hcum oot... " 61g:a9++61p3P ^
> \:0dc*:*- `#v_$$ 0"!gorp hcum oot... " 61g:99++61p3P ^
v \<
>:'~-#v_$ 91g:9G Na1p 0aP a1g1++9G N :91ga1g2+++0`!#v_0aP0aP ^
v < v P9++1g1bg19Ga0 P9g19 p1b <
^ <
>:':-#v_$ 91g9G N :91g1++0`!#v_$0aP ^
v < > 1+91g\-:91p9P v
^ <
>:'!-#v_$ 91g9G N 91g1++ :0`!#v_$$ ^
v < v Pa0 p19 <
^ <
>:'*-#v_$ 91g9G N:a1p 91g1++9G N91g2a1g+++0`!#v_0aP0aP ^
v < v P9p19:+1g19 A <
^ <
>:'(-#v_$ :1\1+>:8g :#v_$$$ 0"!( detanimretnu... " 61g3P61ga9++61p ^
v < >:'(-!#v_')-#v_\1-:#v_v
^ +1< \+1\$ < $
^ < \<
^ g1a P9p19:-\g19+1N G8+1 p8\0 p1a: <
>:'a-#v_$ 0') 91g9G N91g1++0`!#v_0aP0aP ^
v < v P9p19:-2g19AA ('0 <
^ <
>:'^-#v_$ 91g9G N:a1p 91g1++ :0`!#v_$$ ^
v < >91p 0aP :1+8gb1p v
^ -1 p8\g1b+1\ P8g1aGa0 p1a: --1g1a: <
$
$ >'S-!#v_ $ 0"!nsni dab... " 61g3P61gd+61p ^
$ > 91g9G N 91g1++ :0`! #v_ $$ ^
$ ^_v#` g16 **777 P3p16+g15:g16p15N p19 <
^ < > 0"!tuptuo hcum oot... " 777** :aa++61p 3P ^
PROG PREPS:
:
!>$ 88+:*91p v
# v p1a**aaa < v$$ <
>^>e1p:0\> :7g :#v_$$!#v_ >$0".][ dehctamsiM" 61g3P 61ge+61p $f^
|bf prep >:'[- #v_$\1+\v #
>']-#v_ \:#v_^
^ +1< <\-1<
v p181 pg1e00< v># v#<
> #v #+ #1 #<^#<p18+2g18 pg1e+1g18 pg1eg18 <
> :7g :#v_ v
parsed >:'!-!#v_ >:'<-#v_$1\>:1+7g'<-!#v_\a1g%a1g\-v
v pg1eg180 $$< ^ +1\+1\<
>:'>-#v_$1\>:1+7g'>-!#v_\v <
v-\g19%g19\_v#--'g7+1:<\1$_v#!--':< ^ +1\+1\< >a1g% 1 ^
# > v >\1+\1+ ^ > > > > ^
^2%g19<\_v#-+'g7+1:<\1$_v#!-+':<
1 >\1+\1+ ^ >:'[-#v_$03^>:'.-#v_$15^>16^
>:e1gg:#v_$$ v >:']-#^_$04^>',-!#^_ ^
^+2_v#-3< > ^
> ::1\>2+:e1gg:3-!#v_4-#v_\1-:#v_v
+ ^ \+1\$<v < \< $
: 2 ^ < v p1b:+1 <
1 ^ pg1eg1b+1: pg1e+1\ <
-
!
# v+1 <
>$:1\0\p e1p :1-d1p >::7g \d1g-e1gp :7g#^_$ ^
|ul prep
$
$
$
^ <
fungespace storage:
(*,0): data packet storage
(*,1): misc. variables
(0,1): server IP address
(1,1): often data packet length
(2,1): server socket
(3,1): at message-splitting, start of current command/option
(4,1): command character
(5,1): temp ; nick length when building login packet
(6,1): privmsg reply packet prefix len
(7-10,1): temp ; 7 = server port before connecting
(15-,1): bot's nickname
(*,2): socket message-splitting vars
(0,2): start of message
(1,2): end of message
(15-,2): owner prefix
(*,3): current raw irc message to handle/also reply packet
(*,4-x): parsed irc message
(0,4): 1 if prefix, 0 if not
(1-x,4): the prefix string if (0,4) is 1
(0,5): amount of command options, 0..15
(1-x,5): command string (always)
(*,6-x): command options, depending on amount
babble generator:
(5,1): short-time temp
(7,1): model/token file handle
(8,1): last output token generated
(9,1): bsearch table file offset (ret)
(a,1): bsearch min idx
(b,1): bsearch max idx
(c,1): bsearch entry amount (ret)
(e,1): constant 256
(*,8): I/O buffer for file ops
(*,9): generated token stream
code interpretation:
langs: 0=bf, 1=underload
column 5 is used to go to program prep: stack: retaddr src_x dst_y lang
returns via column 80 with stack popped (src_y=7, dst_x=0)
column 6 is used to go to program exec: stack: retaddr org_y lang
returns via column 79 (copies prog to y=8 if org_y != 8)
(5,1): input string pointer (x, y=7)
(6,1): reply packet current length
(7,1): reply packet initial length for checking
(e,1): temp storage for y for progcopy/progprep
brainfuck bytecode:
two-cell opcodes: first cell op, second arg. ops:
0: end program (no arg)
1: add arg (modulo 1000) to bfarray pointer - used for <>
2: add arg (modulo 256) to cell value - used for +-
3: jump to arg if cell zero - used for [
4: jump to arg if cell nonzero - used for ]
5: output cell (arg dummy 1) - used for .
6: input cell (arg dummy 1) - used for ,
brainfuck exec:
(8,1): cycle limit
(9,1): 256 - used in % for cell values
(a,1): 1000 - used in % for bfarray locs
top of stack (usually): input prog pointer (x, y=8)
second on stack: data array pointer (x, y=9)
brainfuck prep:
in pseudo:
- check that [] match
- convert instructions to bytecode with [] args missing
- scan bytecode and write targets to all [] pairs
(8,1): output program position
underload does not use a bytecode format, mostly because of ^.
underload prep just copies the program
underload exec:
top of stack: input prog pointer (x, y=8)
y=9 is used for the stack
y=10 is used for temp. data storage,
y=1 is used for variables (standard fungot):
9,1: underload stack top
a/b/c,1: temp
underload stack goes to negative fungespace
the stack pointer starts at 0 meaning empty stack,
and there must always be a 0 at x=0/1,y=9 for string term.
brainfuck interp uses:
(5,1): input string position (x, y=7)
(6,1): output message position (x, y=3)
(7,1): output message start (to check if any; +2 for crlf)
(8,1): cycle count for limit
(9,1): 256; for modulo
(a,1): 255: for modulo
top of stack (at start): input program position (x, y=7)
second on stack: input data array position (x, y=8)
bfcmd data block:
(0,2000) base
two rows per registered command
first row has zero-terminated command name
second row first cell is language code, 0=bf
rest of second row has the bytecode
--- this code block prints out parts of the IRC message ---
--- if you put it at the point where the message has been split ---
> 04g!#v_ 0" :xiferP">:#,_$ 14G>:#,_$ a, v
v < <
> 0" :dnammoC">:#,_$ 15G>:#,_$ a, v
v1 $_,#! #:<"arguments:"0.g50 <
> :05g` #v_ "' ",, v
^+1,''$_,#! #:<G\0+5: <
^ ,a <
You can’t perform that action at this time.