第五讲 smart qq poll包管理 以致 私聊 群聊音信收发

发送 poll包

public static void Login_PostPoll()
{
try
{
string url = “”;
string dat =
“{“ptwebqq”:”#{ptwebqq}”,”clientid”:53999199,”psessionid”:”#{psessionid}”,”key”:””}”;
dat = dat.Replace(“#{ptwebqq}”,
Login_ptwebqq).Replace(“#{psessionid}”, Login_Psessionid);
dat = “r=” + HttpUtility.UrlEncode(dat);
HTTP.Post_Async_Action action = Message_Get;
HTTP.Post_Async(url, dat, action);
}
catch (Exception) { Login_PostPoll(); }
}
#endregion
#region 接纳到新闻的回调函数
/// <summary>
/// 采取到新闻的回调函数
/// </summary>
/// <param name=”data”>选择到的多寡(json卡塔 尔(英语:State of Qatar)</param>
private static bool Running = true;
public static void Message_Get(string data)
{
Task.Run(() => Login_PostPoll());
if (Running)
Task.Run(() =>
Message_Process(data));//那么些是拍卖收到消息的其余二个措施具体处理在源码
}

以上便是poll包的拍卖以致 收到的音讯管理

接下去是 发送的 

图片 1

 

 上边是发送的连年以至 发送后重返的 poll包消息。代码如下 

/// <summary>
///
/// </summary>
/// <param name=”type”>私聊0 群聊1 讨论组2</param>
/// <param name=”uin”>uin</param>
/// <param name=”messageToSend”>消息</param>
/// <param name=”auto”></param>
/// <returns></returns>
public static bool Login_Postsend_buddy_msg(int type, string uin,
string messageToSend)
{
if (messageToSend.Equals(“”) || uin.Equals(“”))
return false;
string[] tmp = messageToSend.Split(“{}”.ToCharArray());
messageToSend = “”;
for (int i = 0; i < tmp.Length; i++)
if (!tmp[i].Trim().StartsWith(“..[face”) ||
!tmp[i].Trim().EndsWith(“]..”))
messageToSend += “\”” + tmp[i] + “\”,”;
else
messageToSend += tmp[i].Replace(“..[face”,
“[\”face\”,”).Replace(“]..”, “],”);
messageToSend = messageToSend.Remove(messageToSend.LastIndexOf(‘,’));
messageToSend = messageToSend.Replace(“rn”, “n”).Replace(“nr”,
“n”).Replace(“r”, “n”).Replace(“n”, Environment.NewLine);
try
{
string to_groupuin_did, url;
switch (type)
{
case 0:
to_groupuin_did = “to”;
url = “”;
break;
case 1:
to_groupuin_did = “group_uin”;
url = “”;
break;
case 2:
to_groupuin_did = “did”;
url = “”;
break;
default:
return false;
}
string postData =
“{“#{type}”:#{id},”content”:”[#{msg},[\”font\”,{\”name\”:\”繁体\”,\”size\”:10,\”style\”:[0,0,0],\”color\”:\”000000\”}]]”,”face”:#{face},”clientid”:53999199,”msg_id”:#{msg_id},”psessionid”:”#{psessionid}”}”;
postData = “r=” + HttpUtility.UrlEncode(postData.Replace(“#{type}”,
to_groupuin_did).Replace(“#{id}”, uin).Replace(“#{msg}”,
messageToSend).Replace(“#{face}”,
SelfInfo.face.ToString()).Replace(“#{msg_id}”, rand.Next(10000000,
99999999).ToString()).Replace(“#{psessionid}”, Login_Psessionid));

string dat = HTTP.Post(url, postData,
“”);
return dat.Equals(“{“errCode”:0,”msg”:”send ok”}”);
}
catch (Exception)
{
return false;
}
}

 

那生龙活虎讲费了大多小时,中间又去查了素材。非常是拍卖回来的 包的json
,不领会怎么格式化,只可以替换出来,得到想要的数据。

 

到今后终结,整个生手smart qq http 左券的教程
已经足以说成功了,因为这么些公约的成效非凡单意气风发,并且非常多都早就被TX去掉的,就如获取好朋友的
真实QQ也风流倜傥度是报错的。接下来就足以做图形界面,还应该有部分职业了(qq机器人自动苏醒等卡塔尔国

 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website