@Kiryl What you mean is "fan" not fun 🙂
I think you can configure the thermistor and a thermostatic fan like it's done for a hotend fan.
M308 Sm P"temp? " Y"thermistor" T100000 B4725 C7.06e-8 ; define thermistor 'm'
M950 Fn C"fan?" Q500 ; create fan 'n'
M106 Pn T40 Hm ; switch on fan 'n' by reading thermistor 'm'