-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also move HttpClient to have a single shared static instance
- Loading branch information
1 parent
a1959b5
commit b11fa82
Showing
9 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Xml; | ||
using DSharpPlus.CommandsNext; | ||
using DSharpPlus.CommandsNext.Attributes; | ||
using HtmlAgilityPack; | ||
|
||
namespace MedicBot.Commands; | ||
|
||
public class MiscCommands : BaseCommandModule | ||
{ | ||
[Command("selçuk")] | ||
[Aliases("selcuk", "selcuksports")] | ||
public async Task SelcukSport(CommandContext ctx) | ||
{ | ||
await ctx.RespondAsync(await MiscManager.GetSelcukSportsUrlAsync()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace MedicBot; | ||
|
||
[ApiController] | ||
public class MiscController : ControllerBase | ||
{ | ||
[HttpGet("selcuksports")] | ||
[Authorize(Policy = "CombinedPolicy")] | ||
public async Task<IActionResult> SelcukSports() | ||
{ | ||
var url = await MiscManager.GetSelcukSportsUrlAsync(); | ||
return Redirect(url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using HtmlAgilityPack; | ||
|
||
namespace MedicBot; | ||
|
||
public class MiscManager | ||
{ | ||
public static async Task<string> GetSelcukSportsUrlAsync() | ||
{ | ||
var selcukUrl = "https://selcuksportshd78.biz"; | ||
await using var stream = await Program.Client.GetStreamAsync(selcukUrl); | ||
using var streamReader = new StreamReader(stream); | ||
var responseString = await streamReader.ReadToEndAsync(); | ||
var doc = new HtmlDocument(); | ||
doc.LoadHtml(responseString); | ||
var root = doc.DocumentNode ?? throw new FormatException("Could not find root node, probably error in HTML parsing."); | ||
var selcukStreamUrl = root.SelectSingleNode("//div/div/a[1]").Attributes["href"].Value; | ||
return selcukStreamUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters