simplesandman / twitchbot Goto Github PK
View Code? Open in Web Editor NEWCustom C# chat bot for Twitch TV
Custom C# chat bot for Twitch TV
Write unit tests so new features/fixes can formally tested
Help reduce database calls by storing the list in memory
Get the video ID for m.
YouTube links
Ex: https://m.youtube.com/watch?v=x3FYVYN2n1Q
Get list of quotes in order of index from database and refer to the order given in memory. Use something like: !quote 1
to grab the first quote even thought the database index could be at 1002.
When grabbing the range of indexes, display that for the user so they know what is valid to grab.
Also, when displaying the quote, show the index assigned to it and get the user who quoted it.
Make sure any offending users aren't able to use the bot
!addtimeout @[username]
without a time parameter to make a user permanently timed out from the botAllow commands to be used in any case
message.Equals("!cmds") // old
message.Equals("!cmds", StringComparison.CurrentCultureIgnoreCase) // new
message.StartsWith("!8ball ") // old
message.StartsWith("!8ball ", StringComparison.CurrentCultureIgnoreCase) // new
This should be a command that allows the broadcaster to generate a link to allow people to watch multiple streamers at the same time. This link uses a separate service like multitwitch.tv to provide the feed on a separate tab.
The purpose of this command will allow multiple streamers to "co-stream"
Example: http://multitwitch.tv/broadcaster/username2/username3/username4
Here are the commands for this feature:
!addmultitwitch [username2] [username3] [username4]
(broadcaster only)
!resetmultitwitch
(broadcaster only)
!multitwitch
(general chat)
Let interested users know when the broadcaster is streaming a certain game that they prefer.
Channel owner makes a list of games they play and users can select which ones to be notified.
Reset the bot moderator list with something like !resetlistmod
Need to remove uniqueness because of this scenario:
Let's say we have two broadcasters A & B. Broadcaster A decided to change their name to Broadcaster C, but doesn't log back into the bot. After X amount of time passes, Broadcaster B changes their name to Broadcaster A. Now the new broadcaster A can't be added to this table because the old broadcaster A never logged back into the bot to notify the database of the name change.
As a chat moderator, I can't be allowed to play because I can't be timed out
Implement a countdown system a moderator and above would use to display when something is going to happen. At the moment, only hold one countdown at a time until command is well tested.
Make a countdown:
!makecountdown "Happy New Year's" "1-1-2016 12:00:00 AM"
Display the countdown:
!displaycountdown
Countdown to Happy New Year's: 28 days, 7 hours, 33 minutes, and 42 seconds
Allows consistency throughout the project
Need to find a different solution to this system.
Make sure it only runs when a delay message is in the queue.
Handle output text for Spotify when it's not playing anything.
Either "Last Song Played" or "Not Playing Anything"
This is in case if the user tries to get around the bot by changing their name
Based on the game set on Twitch, show the associated gamertag(s)
Need quotation handling like !requestsong "[artist] - [title]"
Replace the existing partyMember
column with an FK from PartyUp
to PartyUpRequests
This will allow continuity and more accurate party member names
Help reduce database calls by storing the list in memory
Make a Blackjack mini game with user's current funds
If at any point the chat gets out-of-control with the bot, you can have it not take in any of their commands
Display the 3 highest ranking followers underneath a streamer
When 24 hours of streaming has been reached, the clock starts at 0:00:00 again.
This will allow users to set an end date and time for reminders if a re-occurring event only lasts for X amount of time
Let user gamble away all of their currency
Stop pluralizing tables and column names unless it's needed
Each time either !updatetitle
or !updategame
is used, make an option to tweet the changes made to the channel.
Make a boolean so it can be shared to both update commands inside the main function.
bool autoTweetChanges = true;
Any time the game is updated (via !updategame
), automatically refreshes the reminders to accommodate that particular game
Make command look like this !utctime
Don't allow moderators (bot or channel) to give each other currency via !deposit
and !bonusall
Use _modInstance.Moderators
list to check alongside _twitchChatterListInstance.ChattersByType
Make a set timer to remind the chat that the chat bot is running and can be used.
Use thread coding similar to PingSender
so it can run in the background.
Maybe add to the README.md how to configure the Client ID and Secret for testing
Help explain a command in-chat
Example Input: !usage sr
Example Output: The song request command is "!sr [artist] - [title]". It allows users to request songs to the broadcaster so they are aware what the viewers want to listen to.
Example: return NotFound("Warning: Chat bot cannot find [insert subject here]");
But be sure to include any Console.WriteLine("");
to immediately tell the user it has been loaded
This could narrow down why the app crashes unexpectedly without any logs explaining why
During the chat message scan in the main forever loop, check if any twitch clips are based on the broadcaster currently streaming or not. This is to prevent any promotion other than the streamer.
Allow channel moderators to post any clips (since trust is assumed)
Until the "NEW" Twitch API has clips, use this:
GET https://api.twitch.tv/kraken/clips/<slug>
Reference: https://dev.twitch.tv/docs/v5/reference/clips/#get-clip
Display the people under the current broadcaster who have the most amount of streamer currency
Rewrite command with this code:
StatusResponse status = spotify.GetStatus();
if (status != null)
{
irc.sendPublicChatMessage("Current Song: " + status.Track.TrackResource.Name
+ " || Artist: " + status.Track.ArtistResource.Name
+ " || Album: " + status.Track.AlbumResource.Name);
}
else
irc.sendPublicChatMessage("The broadcaster is not playing a song at the moment");
This will handle the situation where Spotify is not playing anything
In chat, get current song info like !currentsong
StatusResponse status = spotify.GetStatus();
if (status == null) return;
if (message.Contains("!currentsong"))
spotifyCtrl.ShowUpdatedTrack(status.Track, false);
Will create a separate branch and update this task list accordingly
CREATE SCHEMA Cmd;
GO
-- Pre-defined commands made by developer(s)
CREATE TABLE Cmd.PermissionLevel
(
Id INT IDENTITY(1, 1) NOT NULL
, PermissionName VARCHAR(20) NOT NULL
, CONSTRAINT PK_Cmd_PermissionLevel
PRIMARY KEY (Id)
);
CREATE TABLE Cmd.Method
(
Id INT IDENTITY(1, 1) NOT NULL
, MethodName VARCHAR(10) NOT NULL
, CONSTRAINT PK_Cmd_Method
PRIMARY KEY (Id)
);
CREATE TABLE Cmd.PredefinedCommand
(
Id INT IDENTITY(1, 1) NOT NULL
, Command VARCHAR(30) NOT NULL
, MethodId INT NOT NULL
FOREIGN KEY REFERENCES Cmd.Method (Id)
, CONSTRAINT PK_Cmd_PredefinedCommand
PRIMARY KEY CLUSTERED (Id)
);
CREATE TABLE Cmd.UserSetPredefinedCommand
(
Id INT IDENTITY(1, 1) NOT NULL
, MethodId INT NOT NULL
FOREIGN KEY REFERENCES Cmd.Method (Id)
, BroadcasterId INT NOT NULL
FOREIGN KEY REFERENCES dbo.Broadcaster (Id)
, PermissionId INT NOT NULL
FOREIGN KEY REFERENCES Cmd.PermissionLevel (Id)
, CONSTRAINT PK_Cmd_UserSetPredefinedCommand
PRIMARY KEY (Id)
);
-- Custom commands
CREATE TABLE Cmd.CustomCommand
(
Id INT IDENTITY(1, 1) NOT NULL
, Command NVARCHAR(30) NOT NULL
, Message NVARCHAR(500) NOT NULL
, BroadcasterId INT NOT NULL
FOREIGN KEY REFERENCES dbo.Broadcaster (Id)
, PermissionId INT NOT NULL
FOREIGN KEY REFERENCES Cmd.PermissionLevel (Id)
, CONSTRAINT PK_Cmd_CustomCommand
PRIMARY KEY (Id)
);
public enum PermissionLevel
{
Viewer,
VIP,
Subscriber,
Moderator,
Broadcaster
}
public sealed class ChatCommand
{
private readonly string _name;
public readonly CommandName Value;
public ChatCommand(string name, CommandName value)
{
_name = name;
Value = value
}
public override string ToString()
{
return _name;
}
public enum CommandName
{
Quote = 1,
FollowSince = 2,
FollowAge = 3,
Rank = 4,
// add more
}
public static readonly ChatCommand Quote = new ChatCommand("!quote", Value.Quote);
public static readonly ChatCommand FollowSince = new ChatCommand("!followsince", Value.FollowSince );
public static readonly ChatCommand FollowAge = new ChatCommand("!followage", Value.FollowAge );
public static readonly ChatCommand Rank = new ChatCommand("!rank", Value.Rank );
// add more
}
Look into this StackOverflow answer as a reference for the sealed class ChatCommand
if
block in TwitchBotApplication.cs
to use custom commands with user-set permissions...will write more later
Add manual check if chatter listener doesn't have the user requesting this info.
Reference to CmdFollowSince()
TwitchChatter chatter = _twitchChatterListInstance.TwitchFollowers.FirstOrDefault(c => c.Username.Equals(username));
if (chatter == null)
{
// get chatter info manually
RootUserJSON rootUserJSON = await _twitchInfo.GetUsersByLoginName(username);
using (HttpResponseMessage message = await _twitchInfo.CheckFollowerStatus(rootUserJSON.Users.First().Id))
{
string body = await message.Content.ReadAsStringAsync();
FollowerJSON response = JsonConvert.DeserializeObject<FollowerJSON>(body);
if (!string.IsNullOrEmpty(response.CreatedAt))
chatter = new TwitchChatter { Username = username, CreatedAt = Convert.ToDateTime(response.CreatedAt) };
}
}
// mainly used if chatter was originally null
if (chatter != null)
{
DateTime startedFollowing = Convert.ToDateTime(chatter.CreatedAt);
_irc.SendPublicChatMessage($"@{username} has been following since {startedFollowing.ToLongDateString()}");
}
else
{
_irc.SendPublicChatMessage($"{username} is not following {_botConfig.Broadcaster.ToLower()}");
}
As a moderator, I shouldn't be able to give myself stream currency while giving it to others
When an error comes up from using the Twitch Bot's API, make sure to log it into the database to help with troubleshooting
When a user tries to request a song, make sure the requested artist matches what the broadcaster approves.
Remove table as this can cause un-needed headache to keep up with two different moderator lists. Make sure all features using this table simply use the chat list
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.