fonts mostly work
This commit is contained in:
parent
32704407f0
commit
6b8e7aab59
|
@ -106,36 +106,5 @@ namespace dotbot.Commands
|
|||
await ReplyAsync(@"¯\\\_(ツ)\_/¯");
|
||||
}
|
||||
|
||||
|
||||
[Command("noice")]
|
||||
public async Task Noice()
|
||||
{
|
||||
await ReplyAsync(@"
|
||||
:ok_hand: :joy:
|
||||
:ok_hand::joy:
|
||||
:joy:
|
||||
:joy::ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:ok_hand:
|
||||
:ok_hand: :joy:
|
||||
:ok_hand: :joy:
|
||||
:ok_hand: :joy:
|
||||
:ok_hand: :joy:
|
||||
:ok_hand::joy:
|
||||
:joy:
|
||||
:joy::ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:joy: :ok_hand:
|
||||
:ok_hand:");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
using dotbot.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace dotbot.Commands
|
||||
{
|
||||
[Group("poll")]
|
||||
public class Polls : ModuleBase<SocketCommandContext>
|
||||
{
|
||||
private Dictionary<ulong, Poll> _polls;
|
||||
private IConfigurationRoot _config;
|
||||
|
||||
public Polls(PollService polls, IConfigurationRoot config)
|
||||
{
|
||||
_polls = polls.currentPolls;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
[Command]
|
||||
[Priority(0)]
|
||||
[Summary("create a new poll")]
|
||||
public async Task CreatePoll()
|
||||
{
|
||||
var pollId = Context.Channel.Id;
|
||||
if (_polls.ContainsKey(pollId))
|
||||
{
|
||||
await ReplyAsync($"add some more options or start the poll with `{_config["prefix"]}poll start`");
|
||||
}
|
||||
else
|
||||
{
|
||||
_polls[pollId] = new Poll
|
||||
{
|
||||
Owner = Context.User,
|
||||
IsOpen = false,
|
||||
};
|
||||
await ReplyAsync($"you started a new poll. respond with some options and then start the poll with `{_config["prefix"]}poll start`");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Command("start")]
|
||||
[Priority(1)]
|
||||
[Summary("starts a poll!")]
|
||||
public async Task StartPoll()
|
||||
{
|
||||
var pollId = Context.Channel.Id;
|
||||
if (_polls.ContainsKey(pollId) && Context.User == _polls[pollId].Owner)
|
||||
{
|
||||
foreach (var o in _polls[pollId].Options)
|
||||
{
|
||||
var opt = await ReplyAsync($"{o.Text}");
|
||||
await opt.AddReactionAsync(Emote.Parse(":thumbsup:"));
|
||||
}
|
||||
_polls[pollId].IsOpen = true;
|
||||
}
|
||||
else await ReplyAsync($"no poll ready to start");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
using Discord.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace dotbot.Commands
|
||||
{
|
||||
public class UnicodeFonts : ModuleBase<SocketCommandContext>
|
||||
{
|
||||
public class UnicodeFont
|
||||
{
|
||||
public string Uppers { get; set; }
|
||||
public string Lowers { get; set; }
|
||||
public string Nums { get; set; }
|
||||
}
|
||||
|
||||
public static Dictionary<string, UnicodeFont> Fonts;
|
||||
|
||||
public UnicodeFonts()
|
||||
{
|
||||
Fonts = new Dictionary<string, UnicodeFont>
|
||||
{
|
||||
["full"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
Lowers = "abcdefghijklmnopqrstuvwxyz",
|
||||
Nums = "0123456789",
|
||||
},
|
||||
["mono"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "𝙰𝙱𝙲𝙳𝙴𝙵𝙶𝙷𝙸𝙹𝙺𝙻𝙼𝙽𝙾𝙿𝚀𝚁𝚂𝚃𝚄𝚅𝚆𝚇𝚈𝚉",
|
||||
Lowers = "𝚊𝚋𝚌𝚍𝚎𝚏𝚐𝚑𝚒𝚓𝚔𝚕𝚖𝚗𝚘𝚙𝚚𝚛𝚜𝚝𝚞𝚟𝚠𝚡𝚢𝚣",
|
||||
Nums = "𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿",
|
||||
},
|
||||
["flipped"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇn𐌡ʍxʎz",
|
||||
Lowers = "ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz",
|
||||
Nums = "0123456789",
|
||||
},
|
||||
["reversed"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "AdↃbƎꟻGHIJK⅃MᴎOꟼpᴙꙄTUVWXYZ",
|
||||
Lowers = "AdↄbɘꟻgHijklmᴎoqpᴙꙅTUvwxYz",
|
||||
Nums = "0߁23456789",
|
||||
},
|
||||
["cyrillic"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "αв¢∂єƒﻭнιנкℓмησρ۹яѕтυνωχуչ",
|
||||
Lowers = "αв¢∂єƒﻭнιנкℓмησρ۹яѕтυνωχуչ",
|
||||
Nums = "0123456789",
|
||||
},
|
||||
["slashed"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "ȺɃȻĐɆFǤĦƗɈꝀŁMNØⱣꝖɌSŦᵾVWXɎƵ",
|
||||
Lowers = "Ⱥƀȼđɇfǥħɨɉꝁłmnøᵽꝗɍsŧᵾvwxɏƶ",
|
||||
Nums = "01ƻ3456789",
|
||||
},
|
||||
["script"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "𝓐𝓑𝓒𝓓𝓔𝓕𝓖𝓗𝓘𝓙𝓚𝓛𝓜𝓝𝓞𝓟𝓠𝓡𝓢𝓣𝓤𝓥𝓦𝓧𝓨𝓩",
|
||||
Lowers = "𝓪𝓫𝓬𝓭𝓮𝓯𝓰𝓱𝓲𝓳𝓴𝓵𝓶𝓷𝓸𝓹𝓺𝓻𝓼𝓽𝓾𝓿𝔀𝔁𝔂𝔃",
|
||||
Nums = "𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗",
|
||||
},
|
||||
["gothic"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "𝕬𝕭𝕮𝕯𝕰𝕱𝕲𝕳𝕴𝕵𝕶𝕷𝕸𝕹𝕺𝕻𝕼𝕽𝕾𝕿𝖀𝖁𝖂𝖃𝖄𝖅",
|
||||
Lowers = "𝖆𝖇𝖈𝖉𝖊𝖋𝖌𝖍𝖎𝖏𝖐𝖑𝖒𝖓𝖔𝖕𝖖𝖗𝖘𝖙𝖚𝖛𝖜𝖝𝖞𝖟",
|
||||
Nums = "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡",
|
||||
},
|
||||
["vaporwave"] = new UnicodeFont
|
||||
{
|
||||
Uppers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
Lowers = "abcdefghijklmnopqrstuvwxyz",
|
||||
Nums = "0123456789",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
[Command("block")]
|
||||
[Summary("block text!")]
|
||||
public async Task BlockText([Remainder] string text)
|
||||
{
|
||||
var Nums = new string[] { ":zero:", ":one:", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:" };
|
||||
var res = new StringBuilder();
|
||||
foreach (var c in text.ToCharArray())
|
||||
{
|
||||
res.Append(Char.IsDigit(c) ? $"{Nums[c - '0']} " : Char.IsLetter(c) ? $":regional_indicator_{c.ToString().ToLower()}: " : "");
|
||||
}
|
||||
await ReplyAsync(res.ToString());
|
||||
}
|
||||
|
||||
|
||||
[Command("fonts")]
|
||||
[Alias("fontlist")]
|
||||
public async Task ListFonts()
|
||||
{
|
||||
await base.ReplyAsync($"here are the available unicode fonts:```{string.Join(", ", Fonts.Keys)}```");
|
||||
}
|
||||
|
||||
|
||||
public static string ConvertFont(string fontName, string message)
|
||||
{
|
||||
var res = new StringBuilder();
|
||||
foreach (var c in message.ToCharArray())
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case char n when (c >= '0' && c <= '9'):
|
||||
res.Append($"{Fonts[fontName].Nums[n - '0']} ");
|
||||
break;
|
||||
case char n when (c >= 'a' && c <= 'z'):
|
||||
res.Append($"{Fonts[fontName].Lowers[n - 'a']} ");
|
||||
break;
|
||||
case char n when (c >= 'A' && c <= 'Z'):
|
||||
res.Append($"{Fonts[fontName].Uppers[n - 'z']} ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -113,7 +113,7 @@ namespace dotbot.Commands
|
|||
public class Wind
|
||||
{
|
||||
public double speed { get; set; }
|
||||
public int deg { get; set; }
|
||||
public double deg { get; set; }
|
||||
}
|
||||
public Wind wind { get; set; }
|
||||
public class Sys
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
// <auto-generated />
|
||||
using dotbot.Core;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using System;
|
||||
|
||||
namespace dotbot.Migrations
|
||||
{
|
||||
[DbContext(typeof(DotbotDb))]
|
||||
[Migration("20171210011038_WindDegDouble")]
|
||||
partial class WindDegDouble
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "2.0.1-rtm-125");
|
||||
|
||||
modelBuilder.Entity("dotbot.Core.Definition", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Def");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Defs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("dotbot.Core.Email", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("EmailAddress");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Emails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("dotbot.Core.Image", b =>
|
||||
{
|
||||
b.Property<string>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("FilePath");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Images");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("dotbot.Core.UserLocation", b =>
|
||||
{
|
||||
b.Property<ulong>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("City");
|
||||
|
||||
b.Property<int>("CityId");
|
||||
|
||||
b.Property<double>("Lat");
|
||||
|
||||
b.Property<double>("Lng");
|
||||
|
||||
b.Property<string>("TimeZone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("UserLocations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace dotbot.Migrations
|
||||
{
|
||||
public partial class WindDegDouble : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ namespace dotbot
|
|||
.AddSingleton<StartupService>()
|
||||
.AddSingleton<CleverBotCacheService>()
|
||||
.AddSingleton<DotbotDb>()
|
||||
.AddSingleton<PollService>()
|
||||
.AddSingleton<Random>()
|
||||
.AddSingleton(_config);
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ using System;
|
|||
using System.Threading.Tasks;
|
||||
using dotbot.Core;
|
||||
using System.Linq;
|
||||
using dotbot.Commands;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace dotbot.Services
|
||||
{
|
||||
|
@ -15,19 +17,22 @@ namespace dotbot.Services
|
|||
private readonly CommandService _commands;
|
||||
private readonly IConfigurationRoot _config;
|
||||
private readonly IServiceProvider _provider;
|
||||
private Dictionary<ulong, Poll> _polls;
|
||||
|
||||
public CommandHandlerService(
|
||||
DiscordSocketClient discord,
|
||||
CommandService commands,
|
||||
IConfigurationRoot config,
|
||||
IServiceProvider provider,
|
||||
DotbotDb db
|
||||
DotbotDb db,
|
||||
PollService polls
|
||||
) {
|
||||
_discord = discord;
|
||||
_commands = commands;
|
||||
_config = config;
|
||||
_provider = provider;
|
||||
_db = db;
|
||||
_polls = polls.currentPolls;
|
||||
|
||||
_discord.MessageReceived += OnMessageReceivedAsync;
|
||||
}
|
||||
|
@ -47,26 +52,41 @@ namespace dotbot.Services
|
|||
var result = await _commands.ExecuteAsync(context, argPos, _provider); // Execute the command
|
||||
if (result.IsSuccess) return;
|
||||
|
||||
if (!result.IsSuccess && result.ToString() != "UnknownCommand: Unknown command.")
|
||||
await context.Channel.SendMessageAsync(result.ToString());
|
||||
|
||||
if (msg.HasStringPrefix(_config["prefix"], ref argPos))
|
||||
{
|
||||
var key = msg.Content.Substring(_config["prefix"].Length);
|
||||
{ // check for other conditions
|
||||
var key = msg.Content.Substring(_config["prefix"].Length).Split(' ').First();
|
||||
|
||||
if (_db.Defs.Any(d => d.Id == key))
|
||||
{
|
||||
{ // get def
|
||||
await context.Channel.SendMessageAsync($"**{key}**: {_db.Defs.Find(key).Def}");
|
||||
return;
|
||||
}
|
||||
if (_db.Images.Any(i => i.Id == key))
|
||||
{
|
||||
else if (_db.Images.Any(i => i.Id == key))
|
||||
{ // get img
|
||||
await context.Channel.TriggerTypingAsync();
|
||||
await context.Message.DeleteAsync();
|
||||
var img = _db.Images.Find(key);
|
||||
await context.Channel.SendFileAsync($"UploadedImages/{img.FilePath}", $"{img.Id} by {context.User.Mention}");
|
||||
return;
|
||||
}
|
||||
else if (UnicodeFonts.Fonts.Any(f => f.Key == key))
|
||||
{ // convert font
|
||||
Console.WriteLine(key);
|
||||
var msgtext = msg.Content.Substring(msg.Content.IndexOf(" "));
|
||||
Console.WriteLine(msgtext);
|
||||
await context.Channel.SendMessageAsync(UnicodeFonts.ConvertFont(key, msgtext));
|
||||
}
|
||||
}
|
||||
|
||||
if (!result.IsSuccess && result.ToString() != "UnknownCommand: Unknown command.")
|
||||
await context.Channel.SendMessageAsync(result.ToString());
|
||||
}
|
||||
else
|
||||
{ // add poll options
|
||||
var id = context.Channel.Id;
|
||||
if (_polls.ContainsKey(id) && _polls[id].Owner == context.User && !_polls[id].IsOpen)
|
||||
{
|
||||
_polls[id].Options.Add(new PollOption { Text = msg.Content });
|
||||
await context.Channel.SendMessageAsync($"{msg.Content} added!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
using Discord;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace dotbot.Services
|
||||
{
|
||||
public class PollService
|
||||
{
|
||||
public Dictionary<ulong, Poll> currentPolls;
|
||||
|
||||
public PollService()
|
||||
{
|
||||
currentPolls = new Dictionary<ulong, Poll>();
|
||||
}
|
||||
}
|
||||
|
||||
public class Poll
|
||||
{
|
||||
public List<PollOption> Options { get; set; }
|
||||
public bool IsOpen { get; set; }
|
||||
public IUser Owner { get; set; }
|
||||
|
||||
public PollOption GetWinner => Options.OrderBy(o => o.Votes).Last();
|
||||
|
||||
}
|
||||
|
||||
public class PollOption
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public int Votes { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue