Bläddra i källkod

Decreased message buffer to reduce lag and memory usage.

Changed github credentials to Token based.
Removed auth as it is not needed.
tags/3.0.3
Teknikode 4 år sedan
förälder
incheckning
ef8b14906d
3 ändrade filer med 11 tillägg och 35 borttagningar
  1. 1
    1
      Interface/ViewModels/MainViewModel.cs
  2. 8
    27
      Modules/Github/Github.cs
  3. 2
    7
      Modules/Github/Module.config

+ 1
- 1
Interface/ViewModels/MainViewModel.cs Visa fil

@@ -450,7 +450,7 @@ namespace Interface.ViewModels
}
BufferLock.EnterWriteLock();
BufferInfo buffer = BufferList.Find(buf => buf.Server == server && buf.Location == location);
if (buffer.Buffer.Count >= 1000)
if (buffer.Buffer.Count >= 500)
{
buffer.Buffer.RemoveAt(0);
}

+ 8
- 27
Modules/Github/Github.cs Visa fil

@@ -32,21 +32,12 @@ namespace Combot.Modules.Plugins
try
{
string username = (command.Arguments.ContainsKey("Username")) ? command.Arguments["Username"] : command.Nick.Nickname;
GitHubClient github = new GitHubClient(new ProductHeaderValue("CombotIRCBot"));
if (GetOptionValue("Username").ToString() != string.Empty && GetOptionValue("Password").ToString() != string.Empty)
GitHubClient github = new GitHubClient(new ProductHeaderValue("Combot-IRC-Bot"));
if (GetOptionValue("Token").ToString() != string.Empty)
{
github.Credentials = new Credentials(GetOptionValue("Username").ToString(), GetOptionValue("Password").ToString());
NewAuthorization newAuth = new NewAuthorization();
newAuth.Note = "Get Git Information";
try
{
Authorization auth = await github.Authorization.Create(newAuth);
}
catch (Octokit.AuthorizationException ex)
{
OnError(ex.Message);
return;
}
string token = GetOptionValue("Token").ToString();
Credentials creds = new Credentials(token);
github.Credentials = creds;
}
SearchUsersResult foundUser = await github.Search.SearchUsers(new SearchUsersRequest(username));
if (foundUser.TotalCount > 0)
@@ -97,20 +88,10 @@ namespace Combot.Modules.Plugins
try
{
GitHubClient github = new GitHubClient(new ProductHeaderValue("CombotIRCBot"));
if (GetOptionValue("Username").ToString() != string.Empty && GetOptionValue("Password").ToString() != string.Empty)
if (GetOptionValue("Token").ToString() != string.Empty)
{
github.Credentials = new Credentials(GetOptionValue("Username").ToString(), GetOptionValue("Password").ToString());
NewAuthorization newAuth = new NewAuthorization();
newAuth.Note = "Get Git Information";
try
{
Authorization auth = await github.Authorization.Create(newAuth);
}
catch (Octokit.AuthorizationException ex)
{
OnError(ex.Message);
return;
}
string token = GetOptionValue("Token").ToString();
github.Credentials = new Credentials(token);
}
SearchRepositoryResult foundRepo = await github.Search.SearchRepo(new SearchRepositoriesRequest(command.Arguments["Repository"]));
if (foundRepo.TotalCount > 0)

+ 2
- 7
Modules/Github/Module.config Visa fil

@@ -101,13 +101,8 @@
],
"Options": [
{
"Name": "Username",
"Description": "The bot's github username",
"Value": ""
},
{
"Name": "Password",
"Description": "The bot's github password",
"Name": "Token",
"Description": "The bot's github access token.",
"Value": ""
}
]

Laddar…
Avbryt
Spara