Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
1.5.5: ignore repetition in 5 minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
TURX committed Mar 31, 2020
1 parent 6a9a2d2 commit acd0ff3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion QQCourseBot/GroupInfo.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
namespace QQCourseBot
using System;

namespace QQCourseBot
{
public class GroupInfo
{
public int MessageCount = 1;
public string LastMessage = string.Empty;
public int RepeatCount = 10;
public bool Sent = false;
public DateTime LastRepeatTime = new DateTime();
}
}
16 changes: 15 additions & 1 deletion QQCourseBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static void Main()
if (e is GroupMessageEvent)
{
var me = (e as GroupMessageEvent);
#region WhiteList
foreach (TencentScheduledMeeting i in ScheduledMeetings)
{
if (DateTime.Now < EndTime) break;
Expand All @@ -123,6 +124,8 @@ public static void Main()
}
if (!inWhiteList) return new EmptyResponse();
}
#endregion
#region Preparation
string ThisMessage = me.message.ToString();
if (!Groups.ContainsKey(me.group_id))
{
Expand All @@ -140,12 +143,16 @@ public static void Main()
}
Groups[me.group_id].LastMessage = ThisMessage;
Console.WriteLine("[INFO] Time: " + DateTime.Now + "; Count: " + Groups[me.group_id].MessageCount + "; GroupID: " + me.group_id + "; Message: " + ThisMessage);
#endregion
#region Mention
if (ThisMessage.ToLower().Contains(Personal.Name) || ThisMessage.Contains("[CQ:at,qq=" + Personal.QQ + "]"))
{
Console.WriteLine("[WARNING] You have been mentioned!!!");
Thread.Sleep(random.Next(3000, 6000));
Send(me.group_id, new Message(new ElementText(Mentioned())));
}
#endregion
#region Tencent Meeting
if (ThisMessage.Contains("https://meeting.tencent.com"))
{
ThisMessage = ThisMessage.Replace("会议时间:", "会议时间:");
Expand Down Expand Up @@ -219,6 +226,8 @@ public static void Main()
Console.WriteLine("[WEMEET] Launched");
}
}
#endregion
#region Please send
if (ThisMessage.ToLower().Contains("please send"))
{
int addLen;
Expand Down Expand Up @@ -261,10 +270,15 @@ public static void Main()
}
Groups[me.group_id].Sent = true;
}
if (Groups[me.group_id].MessageCount == Groups[me.group_id].RepeatCount && !Groups[me.group_id].Sent)
#endregion
#region Repeat
if (Groups[me.group_id].MessageCount == Groups[me.group_id].RepeatCount && !Groups[me.group_id].Sent && DateTime.Compare(DateTime.Now.AddMinutes(-5), Groups[me.group_id].LastRepeatTime) > 0)
{
Send(me.group_id, new Message(new ElementText(ThisMessage)));
Groups[me.group_id].LastRepeatTime = DateTime.Now;
Console.WriteLine("[REPEAT] Updated LastRepeatTime: " + Groups[me.group_id].LastRepeatTime);
}
#endregion
}
return new EmptyResponse();
};
Expand Down

0 comments on commit acd0ff3

Please sign in to comment.