static void Room_UserStateChanged(Room room, User user, LiveCodingChat.Xmpp.UserState state)
{
if (state == LiveCodingChat.Xmpp.UserState.Available)
{
userCount++;
}
else
{
userCount--;
}
if (!isStarted)
return;
if (user.ID == chatRoom.Client.Nick)
return;
if (state == LiveCodingChat.Xmpp.UserState.Available)
{
System.Timers.Timer tmr = new System.Timers.Timer();
tmr.Interval = 20000;
tmr.Elapsed +=delegate {
if (welcomeUser.Count != 0)
for (int i = 0; i < welcomeUser.Count; i++)
if (Convert.ToInt32(welcomeUser[i].Remove(0, welcomeUser[i].Length - 3)) <= stopWatch.Elapsed.Minutes - timeToSayHelloAgainInMinutes)
welcomeUser.Remove(welcomeUser[i]);
if (!welcomeUser.Exists(t => t.Substring(0, t.Length - 3) == user.ID.ToLower()))
{
room.SendMessage("Willkommen @" + user.ID + ".Ich bin Adam der Bot dieses Streams. Sprich mich an, wenn du Infos zum Stream brauchst");
welcomeUser.Add(user.ID.ToLower() + stopWatch.Elapsed.Minutes.ToString("000"));
}
if (userCount % 10 == 0)
{
room.SendMessage("@" + user.ID + " ist der " + userCount + " besucher dieses Streams :hi:");
}
tmr.Stop();
};
tmr.Start();
}
}