123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using pomelo.connector;
- using CommonLang.Property;
- using pomelo.area;
- using SimpleJson;
- namespace XmdsBotTest.Runner
- {
- public class ChatFunc : BotRunner.RunnerModule
- {
- private pomelo.player.Player player;
- public ChatFunc() {
- module_name = "聊天";
- }
- public ChatFunc(BotRunner r) : base(r)
- {
-
- }
- protected internal override void OnGateBindPlayer(BindPlayerResponse e)
- {
- base.OnGateBindPlayer(e);
- player = e.s2c_player;
- }
- protected internal override void OnBattleActorReady(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneActor actor)
- {
- layer.AddTimeDelayMS(Config.CheckIntervalMS, (t) =>
- {
- if (Enable)
- {
- }
- });
- layer.AddTimePeriodicMS(Config.CheckIntervalMS, (t) =>
- {
- if (Enable)
- {
- sendChatRequest();
- }
- });
- }
- private static string[] chats = new string[]
- {
- "游戏很好玩!",
- "有个同名电视剧吧",
- "良心作品",
- "好样的,加油。。。",
- "加个朋友吧|<q {\"index\":5}></q>|",
- "你说什么|<q {\"index\":15}></q>|"
- };
- private static Random random = new Random();
- private void sendChatRequest()
- {
- JsonObject json = new JsonObject();
- json.Add("acceptRoleId", "");
- json.Add("s2c_color", 3723689983);
- json.Add("s2c_isAtAll", 0);
- json.Add("s2c_level", player.level);
- json.Add("s2c_name",player.name);
- json.Add("s2c_pro",player.pro);
- json.Add("s2c_titleMsg", "");
- json.Add("s2c_vip", player.vip);
- json.Add("s2c_zoneId", player.zoneId);
- string msg = null;
- if (random.Next(100) < 30)
- {
- msg = "|<q {\"index\":" + random.Next(35) + "}></q>||<q {\"index\":" + random.Next(35) + "}></q>||<q {\"index\":" + random.Next(35) + "}></q>|";
- }
- else
- {
- msg = chats[random.Next(chats.Length)];
- }
- //client.GameSocket.chatHandler.sendChatRequest(1, msg, json.ToString(),"",
- // (err, rsp) =>
- // { });
- }
- [Desc("聊天测试配置")]
- [Expandable]
- public class Config : ConfigBase
- {
- [Desc("聊天测试检测间隔")]
- public static int CheckIntervalMS = 30000;
- public override string ToString()
- {
- return "聊天配置";
- }
- public override void popG2DPropertyDialog()
- {
- CommonFroms.G2D.G2DPropertyDialog<ChatFunc.Config>.Show("修改配置", this);
- }
- }
- }
- }
|