Better messages, radio, osu impl. started, trivia fix, questions fixed

This commit is contained in:
Master Kwoth 2016-02-05 15:33:22 +01:00
parent 810a83611e
commit e14cb34c43
7 changed files with 124 additions and 70 deletions

View File

@ -88,12 +88,13 @@ namespace NadekoBot.Classes.Music {
MusicModule.musicPlayers.TryRemove(_e.Server, out throwAwayValue);
}
public void SetVolume(int value) {
public int SetVolume(int value) {
if (value < 0)
value = 0;
if (value > 150)
value = 150;
this.Volume = value/100f;
return value;
}
internal bool TogglePause() => IsPaused = !IsPaused;

View File

@ -38,9 +38,11 @@ namespace NadekoBot.Classes.Music {
public float Volume => MusicControls?.Volume ?? 1.0f;
public bool RadioLink { get; private set; }
public MusicControls MusicControls;
public StreamRequest(CommandEventArgs e, string query, MusicControls mc) {
public StreamRequest(CommandEventArgs e, string query, MusicControls mc, bool radio = false) {
if (e == null)
throw new ArgumentNullException(nameof(e));
if (query == null)
@ -48,6 +50,7 @@ namespace NadekoBot.Classes.Music {
this.MusicControls = mc;
this.Server = e.Server;
this.Query = query;
this.RadioLink = radio;
Task.Run(() => ResolveStreamLink());
mc.SongQueue.Add(this);
}
@ -55,8 +58,13 @@ namespace NadekoBot.Classes.Music {
private async void ResolveStreamLink() {
string uri = null;
try {
if (SoundCloud.Default.IsSoundCloudLink(Query)) {
if (RadioLink) {
uri = Query;
Title = $"Radio Stream - <{Query}>";
}
else if (SoundCloud.Default.IsSoundCloudLink(Query)) {
if (OnResolving != null)
OnResolving();
var svideo = await SoundCloud.Default.GetVideoAsync(Query);
Title = svideo.FullName + " - SoundCloud";
uri = svideo.StreamLink;

View File

@ -45,8 +45,6 @@ namespace NadekoBot.Commands {
.Do(async e=> {
if (runningTrivias.ContainsKey(e.Server)) {
runningTrivias[e.Server].StopGame();
TriviaGame throwaway;
runningTrivias.TryRemove(e.Server, out throwaway);
} else
await e.Send("No trivia is running on this server.");
});

View File

@ -20,7 +20,7 @@ namespace NadekoBot.Modules {
private string firestr = "🔥 ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็ด้้้้้็็็็็้้้้้็็็็็้้้้้้้้็็็็็้้้้้็็็็็้้้้ 🔥";
public Conversations() : base() {
commands.Add(new CopyCommand());
if(NadekoBot.ParseActive)
if (NadekoBot.ParseActive)
commands.Add(new RequestsCommand());
else
Console.WriteLine("Requests don't work, parse not valid.");
@ -82,11 +82,11 @@ namespace NadekoBot.Modules {
return;
}
if (randServerSW.ElapsedMilliseconds / 1000 < 1800) {
await e.Send("You have to wait " + (1800 - randServerSW.ElapsedMilliseconds / 1000) + " more seconds to use this function.");
if (randServerSW.Elapsed.Seconds < 1800) {
await e.Send("You have to wait " + (1800 - randServerSW.Elapsed.Seconds) + " more seconds to use this function.");
return;
}
randServerSW.Reset();
randServerSW.Restart();
while (true) {
var server = client.Servers.OrderBy(x => rng.Next()).FirstOrDefault();
if (server == null)
@ -198,7 +198,13 @@ namespace NadekoBot.Modules {
string[] pats = new string[] { "http://i.imgur.com/IiQwK12.gif",
"http://i.imgur.com/JCXj8yD.gif",
"http://i.imgur.com/qqBl2bm.gif",
"http://i.imgur.com/eOJlnwP.gif" };
"http://i.imgur.com/eOJlnwP.gif",
"https://45.media.tumblr.com/229ec0458891c4dcd847545c81e760a5/tumblr_mpfy232F4j1rxrpjzo1_r2_500.gif",
"https://media.giphy.com/media/KZQlfylo73AMU/giphy.gif",
"https://media.giphy.com/media/12hvLuZ7uzvCvK/giphy.gif",
"http://gallery1.anivide.com/_full/65030_1382582341.gif",
"https://49.media.tumblr.com/8e8a099c4eba22abd3ec0f70fd087cce/tumblr_nxovj9oY861ur1mffo1_500.gif ",
};
await e.Send($"{e.Message.MentionedUsers.First().Mention} {pats[new Random().Next(0, pats.Length)]}");
});
@ -313,7 +319,7 @@ namespace NadekoBot.Modules {
.Description("Useless. Writes calling @X to chat.\n**Usage**: @NadekoBot call @X ")
.Parameter("who", ParameterType.Required)
.Do(async e => {
await e.Send("Calling " + e.Args[0].Replace("@everyone","[everyone]") + "...");
await e.Send("Calling " + e.Args[0].Replace("@everyone", "[everyone]") + "...");
});
cgb.CreateCommand("hide")
.Description("Hides nadeko in plain sight!11!!")
@ -359,7 +365,7 @@ namespace NadekoBot.Modules {
.Do(async e => {
string[] strings = { "ba", "la", "ha" };
string construct = "@a";
int cnt = rng.Next(4,7);
int cnt = rng.Next(4, 7);
while (cnt-- > 0) {
construct += strings[rng.Next(0, strings.Length)];
}

View File

@ -98,7 +98,8 @@ namespace NadekoBot.Modules {
await e.Send("Volume number invalid.");
return;
}
player.SetVolume(volume);
volume = player.SetVolume(volume);
await e.Send($":musical_note:Volume set to {volume}50%");
});
cgb.CreateCommand("min").Alias("mute")
@ -164,13 +165,29 @@ namespace NadekoBot.Modules {
.Description("Queues up to 25 songs from a youtube playlist specified by a link, or keywords.")
.Parameter("playlist", ParameterType.Unparsed)
.Do(async e => {
if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send(":anger: You need to be in the voice channel on this server.");
return;
}
var ids = await Searches.GetVideoIDs(await Searches.GetPlaylistIdByKeyword(e.GetArg("playlist")));
//todo TEMPORARY SOLUTION, USE RESOLVE QUEUE IN THE FUTURE
await e.Send($"Attempting to queue {ids.Count} songs".SnPl(ids.Count));
var msg = await e.Send($":musical_note: Attempting to queue {ids.Count} songs".SnPl(ids.Count));
foreach (var id in ids) {
Task.Run(async () => await QueueSong(e, id, true)).ConfigureAwait(false);
await Task.Delay(150);
}
msg?.Edit(":musical_note:Playlist queue complete.");
});
cgb.CreateCommand("radio").Alias("ra")
.Description("Queues a direct radio stream from a link.")
.Parameter("radio_link", ParameterType.Required)
.Do(async e => {
if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send(":anger: You need to be in the voice channel on this server.");
return;
}
await QueueSong(e, e.GetArg("radio_link"), radio: true);
});
cgb.CreateCommand("debug")
@ -183,7 +200,7 @@ namespace NadekoBot.Modules {
});
}
private async Task QueueSong(CommandEventArgs e, string query, bool silent = false) {
private async Task QueueSong(CommandEventArgs e, string query, bool silent = false, bool radio = false) {
if (e.User.VoiceChannel?.Server != e.Server) {
await e.Send(":anger: You need to be in the voice channel on this server.");
return;
@ -201,7 +218,7 @@ namespace NadekoBot.Modules {
if (player.SongQueue.Count >= 25) return;
try {
var sr = await Task.Run(() => new StreamRequest(e, query, player));
var sr = await Task.Run(() => new StreamRequest(e, query, player, radio));
if (sr == null)
throw new NullReferenceException("StreamRequest is null.");

View File

@ -136,6 +136,7 @@ namespace NadekoBot.Modules {
await e.Send("http://i.imgur.com/MZkY1md.jpg");
});
cgb.CreateCommand("lmgtfy")
.Alias("~lmgtfy")
.Description("Google something for an idiot.")
.Parameter("ffs", ParameterType.Unparsed)
.Do(async e => {
@ -152,6 +153,7 @@ namespace NadekoBot.Modules {
await e.Send(":anger: Please enter a card name to search for.");
return;
}
await e.Channel.SendIsTyping();
var res = await GetResponseAsync($"https://omgvamp-hearthstone-v1.p.mashape.com/cards/search/{Uri.EscapeUriString(arg)}",
new Tuple<string, string>[] {
new Tuple<string, string>("X-Mashape-Key", NadekoBot.creds.MashapeKey),
@ -181,6 +183,32 @@ namespace NadekoBot.Modules {
await e.Send($":anger: Error {ex}");
}
});
cgb.CreateCommand("~osu")
.Description("desc")
.Parameter("arg", ParameterType.Required)
.Do(async e => {
var arg = e.GetArg("arg");
//make request to osu
//print useful data
});
cgb.CreateCommand("~osubind")
.Description("Bind discord user to osu name\n**Usage**: ~osubind @MyDiscordName My osu name")
.Parameter("user_name", ParameterType.Required)
.Parameter("osu_name", ParameterType.Unparsed)
.Do(async e => {
var userName = e.GetArg("user_name");
var osuName = e.GetArg("osu_name");
var usr = e.Server.FindUsers(userName).FirstOrDefault();
if (usr == null) {
await e.Send("Cannot find that discord user.");
return;
}
//query for a username
//if exists save bind pair to parse.com
//if not valid error
});
});
}

View File

@ -553,8 +553,8 @@
},
{
"Category": "Acronym Soup",
"Question": " DBN;doing business",
"Answer": "not"
"Question": " DBN",
"Answer": "doing business not"
},
{
"Category": "Acronym Soup",
@ -823,7 +823,7 @@
},
{
"Category": "Acronym Soup",
"Question": " RTS ;read the screen",
"Question": " RTS",
"Answer": "real time strategy"
},
{
@ -1053,12 +1053,12 @@
"Answer": "elephant"
},
{
"Category": "Animal Trivia: ---------- may travel great distances on their migrations. The Arctic tern travels from the top of the world, the Arctic - to the bottom, the Antarctic. Round trip in a single year",
"Question": " 25,000 miles in all.",
"Category": "Animal Trivia: ",
"Question": "---------- may travel great distances on their migrations. The Arctic tern travels from the top of the world, the Arctic - to the bottom, the Antarctic. Round trip in a single year: 25,000 miles in all.",
"Answer": "birds"
},
{
"Category": "Animal Trivia: A camel can shut its nostrils during a ----------;desert sandstormanimal trivia",
"Category": "Animal Trivia",
"Question": " a camel with one hump is a dromedary, while a camel with two humps is a ----------",
"Answer": "bactrian"
},
@ -1084,7 +1084,7 @@
},
{
"Category": "Animal Trivia",
"Question": " A mole can dig a tunnel ---------- feet long in one night.;three hundred",
"Question": " A mole can dig a tunnel ---------- feet long in one night.",
"Answer": "300"
},
{
@ -1144,7 +1144,7 @@
},
{
"Category": "Animal Trivia",
"Question": " If they are well treated, camels in captivity can live to the age of ----------;fifty",
"Question": " If they are well treated, camels in captivity can live to the age of -------",
"Answer": "50"
},
{
@ -1159,7 +1159,7 @@
},
{
"Category": "Animal Trivia",
"Question": " Javelinas are free-ranging, yet territorial animals that travel in small herds. One of the reasons they travel in numbers is so they can huddle to stay warm - they don't handle cold well and can ----------;to death quickly.",
"Question": " Javelinas are free-ranging, yet territorial animals that travel in small herds. One of the reasons they travel in numbers is so they can huddle to stay warm - they don't handle cold well and can ---------- to death quickly.",
"Answer": "freeze"
},
{
@ -1224,17 +1224,17 @@
},
{
"Category": "Animal Trivia",
"Question": " The electric eel lives in the Amazon River and its tributaries in South America. The rivers churn up a lot of mud and the eels cannot see well in them. Two less powerful electric fish are the electric catfish and ray. Electric rays live in warm ocean water, and they can give off a charge of sufficient force to stun a human. The biggest electric ray, the Atlantic torpedo ray, can weigh ---------- pounds.;two hundred",
"Question": " The electric eel lives in the Amazon River and its tributaries in South America. The rivers churn up a lot of mud and the eels cannot see well in them. Two less powerful electric fish are the electric catfish and ray. Electric rays live in warm ocean water, and they can give off a charge of sufficient force to stun a human. The biggest electric ray, the Atlantic torpedo ray, can weigh ---------- pounds.",
"Answer": "200"
},
{
"Category": "Animal Trivia",
"Question": " The fastest animal on four legs is the ----------;, which races at speeds up to 70 miles per hour in short distances. it can accelerate to 45 miles per hour in two seconds.",
"Question": " The fastest animal on four legs is the ----------, which races at speeds up to 70 miles per hour in short distances. it can accelerate to 45 miles per hour in two seconds.",
"Answer": "cheetah"
},
{
"Category": "Animal Trivia",
"Question": " The female condor lays a single egg once every ----------;two years",
"Question": " The female condor lays a single egg once every ---------- ",
"Answer": "2 years"
},
{
@ -1254,7 +1254,7 @@
},
{
"Category": "Animal Trivia",
"Question": " The largest species of seahorse measures ----------;eight inches",
"Question": " The largest species of seahorse measures ----------",
"Answer": "8 inches"
},
{
@ -1269,7 +1269,7 @@
},
{
"Category": "Animal Trivia",
"Question": " The life expectancy of the average mockingbird is ----------;ten years",
"Question": " The life expectancy of the average mockingbird is ----------",
"Answer": "10 years"
},
{
@ -1430,16 +1430,12 @@
"Question": "As what was Louis XIV also known",
"Answer": "sun king"
},
{
"Question": "As what was sony's video recorder known;beta-max;beta max",
"Answer": "beta"
},
{
"Question": "Ashord/V. Simpson)",
"Answer": "whitney houston"
},
{
"Question": "At what theme park are the Looney Toons associated with;Six Flags",
"Question": "At what theme park are the Looney Toons associated with",
"Answer": "6 flags"
},
{
@ -3420,7 +3416,7 @@
},
{
"Category": "Trivia ",
"Question": " Chemically pure gold contains how many karats;twenty four",
"Question": " Chemically pure gold contains how many karats",
"Answer": "24"
},
{
@ -3445,12 +3441,12 @@
},
{
"Category": "Trivia ",
"Question": " How many faces has an icosahedron;twenty",
"Question": " How many faces has an icosahedron",
"Answer": "20"
},
{
"Category": "Trivia ",
"Question": " How many gold medals did Jesse Owens win in the 1936 Berlin Olympics;four",
"Question": " How many gold medals did Jesse Owens win in the 1936 Berlin Olympics",
"Answer": "4"
},
{
@ -4088,7 +4084,7 @@
"Answer": "tabulating machine company"
},
{
"Question": "Four European countries keep Greenwich Mean Time. The UK and Ireland are two, name either of the others;iceland",
"Question": "Four European countries keep Greenwich Mean Time. The UK, Iceland, and Ireland are three, name either of the others",
"Answer": "Portugal"
},
{
@ -4116,7 +4112,7 @@
"Answer": "a day at the races"
},
{
"Question": "From which plant family do vanilla pods come;orchid",
"Question": "From which plant family do vanilla pods come",
"Answer": "orchidaceae"
},
{
@ -4301,15 +4297,15 @@
"Answer": "3 days"
},
{
"Question": "How many blades are there on a kayak paddle;two",
"Question": "How many blades are there on a kayak paddle",
"Answer": "2"
},
{
"Question": "How many bonus points in Scrabble if all seven tiles played at once;fifty",
"Question": "How many bonus points in Scrabble if all seven tiles played at once",
"Answer": "50"
},
{
"Question": "How many cards are there in each suit of a standard deck;thirteen",
"Question": "How many cards are there in each suit of a standard deck",
"Answer": "13"
},
{
@ -4321,15 +4317,15 @@
"Answer": "ten"
},
{
"Question": "How many cigars did Sir Winston Churchill ration himself to a day ;fifteen",
"Question": "How many cigars did Sir Winston Churchill ration himself to a day ",
"Answer": "15"
},
{
"Question": "How many consecutive years was the ed sullivan show on tv;twenty three",
"Question": "How many consecutive years was the ed sullivan show on tv",
"Answer": "23"
},
{
"Question": "How many days were the american hostages held in Iran;four hundred & forty four",
"Question": "How many days were the american hostages held in Iran",
"Answer": "444"
},
{
@ -4345,11 +4341,11 @@
"Answer": "seven"
},
{
"Question": "How many member states are there in the United Arab Emirates;seven",
"Question": "How many member states are there in the United Arab Emirates",
"Answer": "7"
},
{
"Question": "How many miles are there in a league;three",
"Question": "How many miles are there in a league",
"Answer": "3"
},
{
@ -4361,7 +4357,7 @@
"Answer": "ten"
},
{
"Question": "How many sheets of paper are there in a ream;five hundred",
"Question": "How many sheets of paper are there in a ream",
"Answer": "500"
},
{
@ -4829,7 +4825,7 @@
"Answer": "ivan"
},
{
"Question": "In 1849 Edgar Allen Poe dies in Baltimore at---------- . ;forty",
"Question": "In 1849 Edgar Allen Poe dies in Baltimore at---------- . ",
"Answer": "40"
},
{
@ -5041,7 +5037,7 @@
"Answer": "broccoli"
},
{
"Question": "In 1909 Comte de Lambert of France sets airplane altitude record of ---------- m. ;three hundred",
"Question": "In 1909 Comte de Lambert of France sets airplane altitude record of ---------- m.",
"Answer": "300"
},
{
@ -5613,7 +5609,7 @@
"Answer": "sierra leone"
},
{
"Question": "In 1962 E. E. Cummings poet, dies at---------- . ;sixty seven",
"Question": "In 1962 E. E. Cummings poet, dies at---------- .",
"Answer": "67"
},
{
@ -5893,7 +5889,7 @@
"Answer": "cyndi lauper"
},
{
"Question": "In 1985 Walt Disney World's ---------- -millonth guest. ;two hundred",
"Question": "In 1985 Walt Disney World's ---------- -millonth guest. ",
"Answer": "200"
},
{
@ -8267,7 +8263,7 @@
"Answer": "bones or cartilage"
},
{
"Question": "To what does the original term' cutty sark ' refer;short shift",
"Question": "To what does the original term' cutty sark ' refer",
"Answer": "chemise"
},
{
@ -9789,7 +9785,7 @@
},
{
"Category": "Useless Facts",
"Question": " A Dutch study indicated that 50 percent of the adult Dutch population have never flown in an airplane, and ---------------- percent admitted a fear of flying.;twenty eight",
"Question": " A Dutch study indicated that 50 percent of the adult Dutch population have never flown in an airplane, and ---------------- percent admitted a fear of flying.",
"Answer": "28"
},
{
@ -9799,12 +9795,12 @@
},
{
"Category": "Useless Facts",
"Question": " According to a recent survey, --------- percent of people who play the car radio while driving also sing along with it.;seventy five",
"Question": " According to a recent survey, --------- percent of people who play the car radio while driving also sing along with it.",
"Answer": "75"
},
{
"Category": "Useless Facts",
"Question": " An American Animal Hospital Association survey revealed that -------------- percent of dog owners sign letters or cards from themselves and their dogs.;sixty two",
"Question": " An American Animal Hospital Association survey revealed that -------------- percent of dog owners sign letters or cards from themselves and their dogs.",
"Answer": "62"
},
{
@ -10084,7 +10080,7 @@
},
{
"Category": "Useless Trivia",
"Question": " By ---------- years old, Americans have watched more than nine years of television.;sixty five",
"Question": " By ---------- years old, Americans have watched more than nine years of television.",
"Answer": "65"
},
{
@ -10896,7 +10892,7 @@
"Answer": "january river"
},
{
"Question": "What does 3 d mean;three dimensional",
"Question": "What does 3 d mean",
"Answer": "3 dimensional"
},
{
@ -12410,7 +12406,7 @@
"Answer": "gum arabic"
},
{
"Question": "What is the sum of 2y + 32y + 56y;ninety y",
"Question": "What is the sum of 2y + 32y + 56y",
"Answer": "90y"
},
{
@ -12762,7 +12758,7 @@
"Answer": "liver"
},
{
"Question": "What organ will most often suffer permanent damage if you have amoebic dysentery;the liver",
"Question": "What organ will most often suffer permanent damage if you have amoebic dysentery",
"Answer": "liver"
},
{
@ -12798,7 +12794,7 @@
"Answer": "treaty of versailles"
},
{
"Question": "What peninsula does Mexico occupy;yucatan peninsula",
"Question": "What peninsula does Mexico occupy",
"Answer": "yucatan"
},
{
@ -12822,7 +12818,7 @@
"Answer": "the dam busters"
},
{
"Question": "What plane did Aerospatiale of France & the British Aircraft Corp. develop;the concord",
"Question": "What plane did Aerospatiale of France & the British Aircraft Corp. develop",
"Answer": "concord"
},
{
@ -12939,7 +12935,7 @@
"Answer": "even numbers"
},
{
"Question": "What serious umderwater ailment was named after a Victorian notion of chic posture;the bends",
"Question": "What serious umderwater ailment was named after a Victorian notion of chic posture",
"Answer": "bends"
},
{
@ -13007,7 +13003,7 @@
"Answer": "salvador dali"
},
{
"Question": "What Spanish islands are Gomera, Hierro & Lanzarote a part of;canary islands",
"Question": "What Spanish islands are Gomera, Hierro & Lanzarote a part of",
"Answer": "canary"
},
{
@ -13103,7 +13099,7 @@
"Answer": "japan & china"
},
{
"Question": "What type of animal was selected to test the first electric toothbrush;the dog",
"Question": "What type of animal was selected to test the first electric toothbrush",
"Answer": "dog"
},
{
@ -13640,7 +13636,7 @@
"Answer": "juliet"
},
{
"Question": "What's the longest river in the U S;mississippi river",
"Question": "What's the longest river in the U S",
"Answer": "mississippi"
},
{
@ -15147,7 +15143,7 @@
"Answer": "stevie wonder"
},
{
"Question": "Who sought to create the great society;lyndon johnson",
"Question": "Who sought to create the great society",
"Answer": "johnson"
},
{
@ -15567,7 +15563,7 @@
"Answer": "Alfred Hitchcock"
},
{
"Question": "Who wrote the Father Brown crime stories;gk chesterton",
"Question": "Who wrote the Father Brown crime stories",
"Answer": "chesterton"
},
{