This guy is so confusing

So long story short..me and this guy we’re friends since middle school and recently started talking on Twitter he is a very handsome respectful guy or so i thought we were having fun conversations and than things started getting heated and we flirted from what i remember he flirted first a few weeks went by he got a girlfriend and started acting different i wasn’t mad because it wasn’t that serious it was only talking. Fast forward i back off and he randomly writes me once telling me “i hope your ok” “ i hope your doing good” as he knew i was having a tough time in my life to and he’ll reply to some of my tweets and last night he started flirting with me again and He would switch up again like oh i was testing to see if you would let me flirt with you while i had my girlfriend and for me to not give in no matter who it is so i can show i respect myself and I’m just like ok but you know before your girlfriend i liked you and what not i wasn’t even flirting i was just telling him i didn’t wanna be THAT girl that makes you cheat or feel guilty of anything and that i do think he’s obviously handsome and sweet but he’s in a relationship and he was kind and said that it was good i don’t know to me it sounds like he likes me but he gots a girl he’s happy with and she’s pretty. I never made myself seem easy in fact i always seem like a challenge cause he knows my life is a rollercoaster right now. Today i wrote him as a friend way cause I’m sick and just needed someone to talk to and he’s acting totally different from last night like anything i say is dieting and he’s not aloud to flirt but I’m not ???