/// <summary> /// 创建 <see cref="Session"/> 实例 /// </summary> /// <param name="settings">指定 <see cref="Session"/> 实例所使用的设置</param> /// <param name="number">指定 <see cref="Session"/> 实例的机器人号码</param> public Session(SessionSettings settings, long number) { Settings = settings ?? throw new ArgumentNullException(nameof(settings)); BotNumber = number; CurrentUser = new CurrentUser(this); ApiEventHandler = new ApiEventHandler(this); ApiManager = new ApiManager(this); }
/// <inheritdoc/> public async ValueTask DisposeAsync() { await ApiEventHandler.DisposeAsync(); if (SessionKey != null && IsVerified) { await ReleaseAsync(); } }
public MessageListener(ILogger <MessageListener> logger, IConfiguration configuration, IChatAppCommandHandler chatAppCommandHandler, IChatAppEventHandler chatAppEventHandler) { _serviceBusConnectionString = configuration["ServiceBusConnectionString"]; _serviceBusQueueName = configuration["ServiceBusQueueName"]; _eventHandler = chatAppEventHandler; _commandHandler = chatAppCommandHandler; _apiEventHandler = new ApiEventHandler(); _logger = logger; }
private IEnumerator Post(ApiEventHandler callback, string action, Dictionary <string, string> pars = null) { WWWForm wwwForm = new WWWForm(); foreach (string key in pars.Keys) { wwwForm.AddField(key, pars[key]); } wwwForm.AddField("api_id", apiId); wwwForm.AddField("api_key", GetApiKey()); if (token.Length > 0) { wwwForm.AddField("token", token); } WWW www = new WWW(apiUrl + action, wwwForm); yield return(www); callback(www.text); }
private IEnumerator Get(ApiEventHandler callback, string action, Dictionary <string, string> pars = null) { string url = apiUrl + action; if (pars != null && pars.Count > 0) { url += "/"; foreach (string key in pars.Keys) { url += key + "=" + pars[key] + "&"; } url = url + "api_id=" + apiId + "&api_key=" + GetApiKey(); if (token.Length > 0) { url += "&token=" + token; } } WWW www = new WWW(url); yield return(www); callback(www.text); }
public void RegisterApi(string apiname, ApiEventHandler fun) { apidic.Add(apiname, fun); }