Skip to content

Commit

Permalink
修复鉴权
Browse files Browse the repository at this point in the history
  • Loading branch information
reitowo committed Nov 27, 2023
1 parent 1a7de22 commit c4c2985
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
4 changes: 4 additions & 0 deletions Models/Types/GuildEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public enum GuildEvents
/// </summary>
AT_MESSAGE_CREATE,
/// <summary>
/// 公域消息撤回
/// </summary>
PUBLIC_MESSAGE_DELETE,
/// <summary>
/// 重连事件补发完毕
/// </summary>
RESUMED,
Expand Down
2 changes: 0 additions & 2 deletions WS/FunctionWebSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ public partial class FunctionWebSocket : BaseWebSocket {

private int[] _shard;

private IdentifyData _identifyData;

public FunctionWebSocket(QQChannelApi api) {
_sessionInfo = new();
_shard = api.Shard;
Expand Down
36 changes: 17 additions & 19 deletions WS/FunctionWebSocketProcess.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq;
using ChannelModels.Returns;
using ChannelModels.Types;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using QQChannelFramework.Models;
using QQChannelFramework.Models.AudioModels;
using QQChannelFramework.Models.Forum;
using QQChannelFramework.Models.MessageModels;
using QQChannelFramework.Models.Types;
using QQChannelFramework.Models.WsModels;
using QQChannelFramework.Tools;

namespace QQChannelFramework.WS;

partial class FunctionWebSocket {
Expand Down Expand Up @@ -91,56 +87,58 @@ private async void Process(JObject data) {

case GuildEvents.GUILD_MEMBER_ADD:

NewMemberJoin?.Invoke(data["d"].ToObject<Models.MemberWithGuildID>());
NewMemberJoin?.Invoke(data["d"].ToObject<MemberWithGuildID>());

break;

case GuildEvents.GUILD_MEMBER_UPDATE:

MemberInfoChange?.Invoke(data["d"].ToObject<Models.MemberWithGuildID>());
MemberInfoChange?.Invoke(data["d"].ToObject<MemberWithGuildID>());

break;

case GuildEvents.GUILD_MEMBER_REMOVE:

MemberLeaveGuild?.Invoke(data["d"].ToObject<Models.MemberWithGuildID>());
MemberLeaveGuild?.Invoke(data["d"].ToObject<MemberWithGuildID>());

break;

case GuildEvents.AT_MESSAGE_CREATE:

ReceivedAtMessage?.Invoke(data["d"].ToObject<Models.MessageModels.Message>());
ReceivedAtMessage?.Invoke(data["d"].ToObject<Message>());

break;

case GuildEvents.MESSAGE_CREATE:

ReceivedUserMessage?.Invoke(data["d"].ToObject<Models.MessageModels.Message>());
ReceivedUserMessage?.Invoke(data["d"].ToObject<Message>());

break;

case GuildEvents.MESSAGE_DELETE:
UserRetractMessage?.Invoke(data["d"].ToObject<RetractMessage>());
break;

UserRetractMessage?.Invoke(data["d"].ToObject<Models.MessageModels.RetractMessage>());

case GuildEvents.PUBLIC_MESSAGE_DELETE:
UserRetractMessage?.Invoke(data["d"].ToObject<RetractMessage>());
break;

case GuildEvents.DIRECT_MESSAGE_CREATE:

ReceivedDirectMessage?.Invoke(data["d"].ToObject<Models.MessageModels.Message>());
ReceivedDirectMessage?.Invoke(data["d"].ToObject<Message>());

break;

case GuildEvents.MESSAGE_REACTION_ADD:

MessageReactionIsAdded?.Invoke(data["d"].ToObject<Models.MessageModels.MessageReaction>());
MessageReactionIsAdded?.Invoke(data["d"].ToObject<MessageReaction>());

break;

case GuildEvents.MESSAGE_REACTION_REMOVE:

MessageReactionIsRemoved?.Invoke(data["d"]
.ToObject<Models.MessageModels.MessageReaction>());
.ToObject<MessageReaction>());

break;

Expand Down Expand Up @@ -248,7 +246,7 @@ private async void Process(JObject data) {
heartbeatTimer.Start();

// 目前用新的令牌鉴权会失败
_identifyData ??= new IdentifyData {
var identifyData = new IdentifyData {
intents = 0,
token = $"QQBot {await _openApiAccessInfo.GetAuthorization()}",
shard = _shard
Expand All @@ -262,12 +260,12 @@ private async void Process(JObject data) {
break;
}
foreach (var type in _registeredEvents) {
_identifyData.intents += (int)type;
identifyData.intents += (int)type;
}

Load load = new() {
op = (int)OpCode.Identify,
d = _identifyData
d = identifyData
};

SendAsync(JsonConvert.SerializeObject(load));
Expand Down

0 comments on commit c4c2985

Please sign in to comment.