using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telegram.Bot.Types.Enums;
namespace TelegramBotBase.Markdown
{
public static class Generator
{
public static ParseMode OutputMode { get; set; } = ParseMode.Markdown;
///
/// Generates a link with title in Markdown or HTML
///
///
///
///
///
public static String Link(this String url, String title = null, String tooltip = null)
{
switch (OutputMode)
{
case ParseMode.Markdown:
return "[" + (title ?? url) + "](" + url + " " + (tooltip ?? "") + ")";
case ParseMode.Html:
return $"{title ?? ""}";
}
return url;
}
///
/// Returns a Link to the User, title is optional.
///
///
///
///
public static String MentionUser(this long userId, String title = null)
{
return Link("tg://user?id=" + userId.ToString(), title);
}
///
/// Returns a bold link in Markdown or HTML
///
///
///
public static String Bold(this String text)
{
switch (OutputMode)
{
case ParseMode.Markdown:
return "**" + text + "**";
case ParseMode.Html:
return "" + text + "";
}
return text;
}
///
/// Returns a italic link in Markdown or HTML
///
///
///
public static String Italic(this String text)
{
switch (OutputMode)
{
case ParseMode.Markdown:
return "__" + text + "__";
case ParseMode.Html:
return "" + text + "";
}
return text;
}
///
/// Returns a monospace link in Markdown or HTML
///
///
///
public static String Monospace(this String text)
{
switch (OutputMode)
{
case ParseMode.Markdown:
return "`" + text + "`";
case ParseMode.Html:
return "" + text + "";
}
return text;
}
///
/// Returns a multi monospace link in Markdown or HTML
///
///
///
public static String MultiMonospace(this String text)
{
switch (OutputMode)
{
case ParseMode.Markdown:
return "```" + text + "```";
case ParseMode.Html:
return "" + text + "
";
}
return text;
}
}
}