diff --git a/README.md b/README.md index c6b26b89..294e74f6 100644 --- a/README.md +++ b/README.md @@ -3,73 +3,6 @@ basicBot A not so basic bot for plug.dj -!!!TO CUSTOMIZE: USE [THIS REPOSITORY](https://github.com/Yemasthui/basicBot-customization)!!! -============================================================================================== - -IMPORTANT ---------- - -__basicBot has been updated to work under plug's update. There may still be bugs and functionality is not guaranteed.__ - -__Make sure to update your bookmark, as the link has changed recently!!!__ - -__Important changes in version 2.x.x:__ - -- Now should be fully compatible with Firefox. -- You can now change the bot's name, no need to make a fork to change it anymore. Available under custom settings as "botName". -- The bot's variable is now exposed outside of the script. You can access it as the variable "bot" in the console. This should allow for secondary scripts extending the bot without the need to fork and lose support on its basis. -Be careful when extending it to make sure commands or features interact properly with the rest of them. -An example script to extend the bot is provided under exampleExtension.js. Please do not fork this repository to just change that file. Details of how to use are provided inside. -This is NOT needed to run the bot as it is provided, only if you want to add functionality. -- Command checking has been reworked to facilitate adding commands through secondary scripts as explained above. -- __There is now support for custom chat messages. This means you can use your own custom wording or translate it into your own language.__ - -Usage ------ - -Bookmark the following code. To run the bot, run the bookmark. - -`javascript:(function(){$.getScript('https://rawgit.com/Yemasthui/basicBot/master/basicBot.js');})();` - -If this does not work, go to https://raw.githubusercontent.com/Yemasthui/basicBot/master/basicBot.js and copy paste its content into your console (accessible in chrome by pressing f12) when on plug.dj in your community. - -###Commands### - -These can be found in [the commands file](https://github.com/Yemasthui/basicBot/blob/master/commands.md). - -###Blacklists### -Examples of blacklists can be found in [the customization repository](https://github.com/Yemasthui/basicBot-customization/tree/master/blacklists). -You can add blacklists in the settings of the bot via the methods given in that same repository. See below for more information. - -###Extending functionality and custom default settings### - -basicBot can be customized to fit your needs. Please refer to [the customization repository](https://github.com/Yemasthui/basicBot-customization) for more info. -Please do not try to if you are not confident in your javascript capabilities. - - -###Translations### - -Official translations will be supported. Available ones can be found under [the language folder](https://github.com/Yemasthui/basicBot/blob/master/lang/langIndex.json). You can set a language in the room settings. -You can use your own translation or wording by translating the values of in [the English pack](https://github.com/Yemasthui/basicBot/blob/master/lang/en.json) and uploading it to a public hosting service. Put the link into your custom room settings, under chatLink. - -__When translating the chat messages, please not that it is a json format, meaning it is structured as ```"key":"value"```, please only translate the "value" parts, and leave anything between %% (eg. %%NAME%%) as is, they are variables that get filled in by the bot.__ - - -Credits -------- - -I would like to thank the following people: - -- Fungus: His Tastybot has been a source of inspiration for most of the features, and his help with coding problems has been invaluable to make this bot. -- TAT, Origin and other Litebot contributors: Their Litebot has inspired features like Roulette. -- Henchman: Never knew this undertaking would give me a friend too. - -|Language | Translator| -|:------:|:---------:| -|Portuguese|[Motel Bible](https://github.com/motelbible)| -|French|[NDA](https://github.com/NDAthereal)| - - Copyright --------- @@ -85,4 +18,4 @@ Disclaimer This bot is developed independently. Changes may be made without notice. There is no guarantee for the perfect functioning. Plug.dj admins have the right to request changes. By using this chatbot you agree to not use it for violating plug.dj's Terms of Service. -You also agree not to alter the bot's code. Any requests for changes can be requested via email, through github or via plug.dj. \ No newline at end of file +You also agree not to alter the bot's code. Any requests for changes can be requested via email, through github or via plug.dj. diff --git a/commands.md b/commands.md index 33cd22e0..faa9d5cb 100644 --- a/commands.md +++ b/commands.md @@ -1,8 +1,8 @@ Commands: ========= -X specifies a number -arguments between ( ) are optional +X specifies a number +Arguments between ( ) are optional Manager @@ -15,9 +15,11 @@ Manager |!cycle | | toggle DJ cycle | |!cycletimer | X | set the maximum DJ cycle time for when cycleguard is enabled | |!locktimer | X | set the maximum time the waitlist can be locked if lockguard is enabled | +|!logout | | logs out account bot is hosted on | |!refresh | | refreshes the browser of whoever runs the bot | |!usercmdcd | X | set the cooldown on commands by grey users | |!usercommands | | toggle user commands | +|!voteskip | (X) | when no argument is specified, returns the current voteskip limit, when X is specified, voteskip limit is updated to the new specified limit. | Bouncer+ -------- @@ -28,7 +30,7 @@ Bouncer+ |!afkremoval | | toggles the afk check | |!autoskip | | skips songs automatically when they're done (use when the circles-bug happens) | |!bouncer+ | | disable bouncer+ | -|!deletechat | @user | delete all the chats by a certain user | +|!deletechat | @user | delete all the chats by a certain user ***Currently removed due to bug (awaiting fix)*** | |!lock | | lock the waitlist | |!lockdown | | lock down the room: only staff can chat | |!maxlength | X | specify the maximum length a song can be when timeguard is enabled | @@ -47,8 +49,10 @@ Bouncer |!active | (X) | shows how many users chatted in the past X minutes. If no X specified, 60 is set as default | |!afkreset | @user | resets the afk time of user | |!afktime | @user | shows how long user has been afk | +|!autodisable | | toggle the autodisable | |!ban | @user | bans user for 1 day | -|!blacklist / !bl | blacklistname | add the song to the specified blacklist +|!blacklist / !bl | blacklistname | add the song to the specified blacklist | +|!blinfo | | get information required to blacklist a song | |!cycleguard | | toggles the cycleguard | |!dclookup / !dc | (@user) | do dclookup for user | |!english | @user | ask user to speak english (asked in the language they set plug to) | @@ -56,7 +60,7 @@ Bouncer |!filter | | toggles the chat filter | |!jointime | @user | shows how long the user has been in the room | |!kick | (X) | kicks user for X minutes, default is 0.25 minutes (15 seconds) | -|!kill | ||shut down the bot | +|!kill | | shut down the bot | |!lockguard | | toggle the lockguard | |!lockskip | (reason) | skip the song and move the dj back up (the position can be set with !lockskippos) | |!lockskippos | X | set the position to which lockskip moves the dj | @@ -68,10 +72,13 @@ Bouncer |!skip | | skip the current song | |!status | | display the bot's status and some settings | |!timeguard | | toggle the timeguard | +|!togglebl | | toggle the blacklist | |!togglemotd | | toggle the motd | +|!togglevoteskip | | toggle the voteskip | |!unban | @user | unban user | |!unmute | | unmute user | |!voteratio | @user | display the vote statistic for a user | +|!whois | @user | returns plug related information about user | Resident DJ ----------- @@ -87,6 +94,7 @@ User |Command | Arguments | Description | |:------:|:---------:|:--------------------------------------:| +|!8ball | (message) | ask the bot a question, the bot will return random variations of a yes or no answer. | |!autowoot | | links to PlugCubed, the advised script/plugin to use for autowooting | |!ba | | explains the Brand Ambassador rank | |!commands | | gives a link to the commands | @@ -95,12 +103,15 @@ User |!emoji | | a link to a list with emoji's | |!eta | | shows how long before you reach the booth | |!fb | | links to the room's Facebook page (if set in the settings) | +|!ghostbuster | @user | checks if user is ghosting | +|!gif | (message) | returns gif (from giphy) related to the tag provided. Returns a random gif if no tags are provided. | |!help | | links to an image to help get people started on plug | |!join | | join the roulette if it's up | |!leave | | leave the roulette if you joined | |!link | | when the user is the DJ, give a link to the current song | |!op | | links to the OverPlayed list (if set in the settings) | |!ping | | pong! | +|!purchase | | returns link to purchase more plug notes | |!rules | | links to the rules (if set in the settings) | |!theme | | links to the room's theme (if set in the settings) | |!website | | links to the room's website (if set in the settings) | diff --git a/lang/en.json b/lang/en.json index 2f58a918..445c9268 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1,67 +1,126 @@ { - + "cookies": [ + "has given you a chocolate chip cookie!", + "has given you a soft homemade oatmeal cookie!", + "has given you a plain, dry, old cookie. It was the last one in the bag. Gross.", + "gives you a sugar cookie. What, no frosting and sprinkles? 0\/10 would not touch.", + "gives you a chocolate chip cookie. Oh wait, those are raisins. Bleck!", + "gives you an enormous cookie. Poking it gives you more cookies. Weird.", + "gives you a fortune cookie. It reads \"Why aren't you working on any projects?\"", + "gives you a fortune cookie. It reads \"Give that special someone a compliment\"", + "gives you a fortune cookie. It reads \"Take a risk!\"", + "gives you a fortune cookie. It reads \"Go outside.\"", + "gives you a fortune cookie. It reads \"Don't forget to eat your veggies!\"", + "gives you a fortune cookie. It reads \"Do you even lift?\"", + "gives you a fortune cookie. It reads \"m808 pls\"", + "gives you a fortune cookie. It reads \"If you move your hips, you'll get all the ladies.\"", + "gives you a fortune cookie. It reads \"I love you.\"", + "gives you a Golden Cookie. You can't eat it because it is made of gold. Dammit.", + "gives you an Oreo cookie with a glass of milk!", + "gives you a rainbow cookie made with love :heart:", + "gives you an old cookie that was left out in the rain, it's moldy.", + "bakes you fresh cookies, it smells amazing." + ], + "balls": [ + "Signs point to yes.", + "Yes.", + "Reply hazy, try again.", + "Without a doubt.", + "My sources say no.", + "As I see it, yes.", + "You may rely on it.", + "Concentrate and ask again.", + "Outlook not so good.", + "It is decidedly so.", + "Better not tell you now.", + "Very doubtful.", + "Yes - definitely.", + "It is certain.", + "Cannot predict now.", + "Most likely.", + "Ask again later.", + "My reply is no.", + "Outlook good.", + "Don't count on it.", + "Yes, in due time.", + "My sources say no.", + "Definitely not.", + "You will have to wait.", + "I have my doubts.", + "Outlook so so.", + "Looks good to me!", + "Who knows?", + "Looking good!", + "Probably.", + "Are you kidding?", + "Don't bet on it.", + "Forget about it." + ], "nodatafound": "No previous data found.", + "currentlang": "Language currently set to: %%LANGUAGE%%", + "langerror": "The language you've selected isn't available. Please visit %%LINK%% to find a list of languages available.", + "langset": "Language now set to: %%LANGUAGE%%", "retrievingdata": "Retrieving previously stored data.", "datarestored": "Previously stored data successfully retrieved.", "greyuser": "Only bouncers and up can run a bot.", "bouncer": "The bot can't move people when it's run as a bouncer.", - "online": "/me %%BOTNAME%% v%%VERSION%% online!", - - - "welcome": "/me Welcome %%NAME%%", - "welcomeback": "/me Welcome back, %%NAME%%", - "songknown": "/me :repeat: This song has been played %%PLAYS%% time(s) in the last %%TIMETOTAL%%, last play was %%LASTTIME%% ago. :repeat:", - "timelimit": "/me @%%NAME%%, your song is longer than %%MAXLENGTH%% minutes, you need permission to play longer songs.", - "permissionownsong": "/me :up: @%%NAME%% has permission to play their own production!", - "isblacklisted": "/me This track is on the %%BLACKLIST%% blacklist! Skipping...", - - - "isopen": "/me The roulette is now open! Type !join to participate!", - "winnerpicked": "/me A winner has been picked! @%%NAME%% to position %%POSITION%%.", - - - "alreadyadding": "/me User is already being added! Changed the desired position to %%POSITION%%.", - "adding": "/me Added @%%NAME%% to the queue. Current queue: %%POSITION%%.", - - - "usernotfound": "/me User not found.", - "notdisconnected": "/me @%%NAME%% did not disconnect during my time here.", - "noposition": "/me No last position known. The waitlist needs to update at least once to register a user's last position.", - "toolongago": "/me @%%NAME%%'s last disconnect (DC or leave) was too long ago: %%TIME%%.", - "valid": "/me @%%NAME%% disconnected %%TIME%% ago and should be at position %%POSITION%%.", - - - "warning1": "/me @%%NAME%%, you have been afk for %%TIME%%, please respond within 2 minutes or you will be removed.", - "warning2": "/me @%%NAME%%, you will be removed due to AFK soon if you don't respond.", - "afkremove": "/me @%%NAME%%, you have been removed for being afk for %%TIME%%. You were at position %%POSITION%%. Chat at least once every %%MAXIMUMAFK%% minutes if you want to play a song.", - - - "caps": "/me @%%NAME%%, unglue your capslock button please.", - "askskip": "/me @%%NAME%%, don't ask for skips.", - "spam": "/me @%%NAME%%, please don't spam.", - "roomadvertising": "/me @%%NAME%%, don't post links to other rooms please.", - "adfly": "/me @%%NAME%%, please change your autowoot program. We suggest PlugCubed: http://plugcubed.net/", - - - "invalidtime": "/me [@%%NAME%%] Invalid time specified.", - "nouserspecified": "/me [@%%NAME%%] No user specified.", - "invaliduserspecified": "/me [@%%NAME%%] Invalid user specified.", - "nolistspecified": "/me [@%%NAME%%] No list specified.", - "invalidlistspecified": "/me [@%%NAME%%] Invalid list specified.", - "novaliduserspecified": "/me [@%%NAME%%] No valid user specified.", - "nolimitspecified": "/me [@%%NAME%%] No limit specified.", - "invalidlimitspecified": "/me [@%%NAME%%] Invalid limit.", - "invalidpositionspecified": "/me [@%%NAME%%] Invalid position specified.", - "toggleon": "/me [@%%NAME%%] %%FUNCTION%% enabled.", - "toggleoff": "/me [@%%NAME%%] %%FUNCTION%% disabled.", + "online": "%%BOTNAME%% v%%VERSION%% running!", + "welcome": "Welcome, @%%NAME%%!", + "welcomeback": "Welcome back, @%%NAME%%!", + "songknown": "@%%NAME%%, this song is in the DJ history.", + "notavailable": "@%%NAME%%, the song you played was not available.", + "timelimit": "@%%NAME%%, your song is longer than %%MAXLENGTH%% minutes, you need permission to play longer songs.", + "permissionownsong": ":up: @%%NAME%% has permission to play their own production!", + "isblacklisted": "This track is on the %%BLACKLIST%% blacklist! Skipping...", + "isopen": "The roulette is now open! Type !join to participate! (A game where a random participant is moved to position 2 in the waitlist.)", + "winnerpicked": "Winner! :trophy: @%%NAME%% to position %%POSITION%%.", + "ball": "%%NAME%%'s question was: \"%%QUESTION%%\" and %%BOTNAME%%'s response is: \"%%RESPONSE%%\"", + "notghosting": "[%%NAME1%%] %%NAME2%% is not ghosting.", + "ghosting": "[%%NAME1%%] %%NAME2%% is either ghosting or not here.", + "alreadyadding": "User is already being added! Changed the desired position to %%POSITION%%.", + "adding": "Added @%%NAME%% to the queue. Current queue: %%POSITION%%.", + "usernotfound": "User not found.", + "notdisconnected": "@%%NAME%% I have not seen you disconnect.", + "noposition": "No last position known. The waitlist needs to update at least once to register a user's last position.", + "toolongago": "@%%NAME%%'s last disconnect was too long ago: %%TIME%%.", + "valid": "@%%NAME%% disconnected %%TIME%% ago and should be at position %%POSITION%%.", + "warning1": "@%%NAME%%, you have been afk for %%TIME%%, please respond within 2 minutes or you will be removed.", + "warning2": "@%%NAME%%, you will be removed due to AFK soon if you don't respond.", + "afkremove": "@%%NAME%%, you have been removed for being afk for %%TIME%%. You were at position %%POSITION%%. Chat at least once every %%MAXIMUMAFK%% minutes if you want to play a song.", + "caps": "@%%NAME%%, unglue your capslock button please.", + "askskip": "@%%NAME%%, don't ask for skips.", + "spam": "@%%NAME%%, please don't spam.", + "roomadvertising": "@%%NAME%%, don't post links to other rooms please.", + "adfly": "@%%NAME%%, please change your autowoot program. We suggest PlugCubed: http:\/\/plugcubed.net\/", + "validgiftags": "[@%%NAME%%] http:\/\/i.giphy.com\/%%ID%%.gif [Tags: %%TAGS%%]", + "invalidgiftags": "[@%%NAME%%] Invalid tags, try something different. [Tags: %%TAGS%%]", + "validgifrandom": "[@%%NAME%%] http:\/\/i.giphy.com\/%%ID%%.gif [Random GIF]", + "invalidgifrandom": "[@%%NAME%%] Invalid request, try again.", + "invalidtime": "[@%%NAME%%] Invalid time specified.", + "nouserspecified": "[@%%NAME%%] No user specified.", + "invaliduserspecified": "[@%%NAME%%] Invalid user specified.", + "nolistspecified": "[@%%NAME%%] No list specified.", + "invalidlistspecified": "[@%%NAME%%] Invalid list specified.", + "novaliduserspecified": "[@%%NAME%%] No valid user specified.", + "nolimitspecified": "[@%%NAME%%] No limit specified.", + "invalidlimitspecified": "[@%%NAME%%] Invalid limit.", + "invalidpositionspecified": "[@%%NAME%%] Invalid position specified.", + "whois": "[%%NAME1%%] Username: %%NAME2%%, ID: %%ID%%, Rank: %%RANK%%, Joined: %%JOINED%%, Level: %%LEVEL%%, Language: %%LANGUAGE%%, Avatar: %%AVATAR%%, Profile: %%PROFILE%%", + "toggleon": "[@%%NAME%%] %%FUNCTION%% enabled.", + "toggleoff": "[@%%NAME%%] %%FUNCTION%% disabled.", + "cmddeletion": "command deletion", "afkremoval": "AFK removal", "afksremoved": "AFK's removed", "afklimit": "AFK limit", + "autodisable": "autodisable", "autoskip": "autoskip", - "newblacklisted": "/me [@%%NAME%%] This track belongs on the %%BLACKLIST%% blacklist! [ %%AUTHOR%% - %%TITLE%% - %%MID%% ]", + "newblacklisted": "[@%%NAME%%] This track belongs on the %%BLACKLIST%% blacklist! [ %%AUTHOR%% - %%TITLE%% - %%MID%% ]", + "blinfo": "[@%%NAME%%] Blacklist Info - author: %%AUTHOR%%, title: %%TITLE%%, mid: %%SONGID%%", + "blacklist": "blacklist", "cycleguard": "cycleguard", "timeguard": "timeguard", "chatfilter": "chatfilter", + "historyskip": "historyskip", "lockdown": "lockdown", "lockguard": "lockguard", "usercommands": "usercommands", @@ -69,68 +128,80 @@ "welcomemsg": "welcome message", "songstats": "song statistics", "etarestriction": "eta restriction", - "activeusersintime": "/me [@%%NAME%% There have been %%AMOUNT%% users chatting in the past %%TIME%% minutes.", - "maximumafktimeset": "/me [@%%NAME%%] Maximum afk duration set to %%TIME%% minutes.", - "afkstatusreset": "/me [@%%NAME%%] Reset the afk status of @%%USERNAME%%.", - "inactivefor": "/me [@%%NAME%%] @%%USERNAME%% has been inactive for %%TIME%%.", - "autowoot": "/me We recommend PlugCubed for autowooting: http://plugcubed.net/", - "brandambassador": "/me A Brand Ambassador is the voice of the plug.dj users. They promote events, engage the community and share the plug.dj message around the world. For more info: http://blog.plug.dj/brand-ambassadors/", - "bouncerplusrank": "/me [@%%NAME%%] You have to be manager or up to enable Bouncer+.", - "chatcleared": "/me [@%%NAME%%] Cleared the chat.", - "deletechat": "/me [@%%NAME%%] Cleared the chat of %%USERNAME%%.", - "commandslink": "/me %%BOTNAME%% commands: %%LINK%%", - "eatcookie": "/me eats a cookie.", - "nousercookie": "/em doesn't see %%NAME%% in room and eats a cookie himself.", - "selfcookie": "/me @%%NAME%%, you're a bit greedy, aren't you? Giving cookies to yourself, bah. Share some with other people!", - "cookie": "/me @%%NAMETO%%, @%%NAMEFROM%% %%COOKIE%%", - "cycleguardtime": "/me [@%%NAME%%] The cycleguard is set to %%TIME%% minute(s).", - "dclookuprank": "/me [@%%NAME%%] Only bouncers and above can do a lookup for others.", - "emojilist": "/me Emoji list: %%LINK%%", - "notinwaitlist": "/me @%%NAME%%, you are not on the waitlist.", - "eta": "/me @%%NAME%% you will reach the booth in approximately %%TIME%%.", - "facebook": "/me Like us on facebook: %%LINK%%", - "starterhelp": "/me This image will get you started on plug: %%LINK%%", - "roulettejoin": "/me @%%NAME%% joined the roulette! (!leave if you regret it.)", - "jointime": "/me [@%%NAMEFROM%%] @%%USERNAME%% has been in the room for %%TIME%%.", - "kickrank": "/me [@%%NAME%%] you can't kick users with an equal or higher rank than you!", - "kick": "/me [@%%NAME%%], @%%USERNAME%% you are being kicked from the community for %%TIME%% minutes.", - "kill": "/me Shutting down.", - "rouletteleave": "/me @%%NAME%% left the roulette!", - "songlink": "/me [@%%NAME%%] Link to current song: %%LINK%%", - "usedlockskip": "/me [%%NAME%% used lockskip.]", - "lockskippos": "/me [@%%NAME%%] Lockskip will now move the dj to position %%POSITION%%.", - "lockguardtime": "/me [@%%NAME%%] The lockguard is set to %%TIME%% minute(s).", - "maxlengthtime": "/me [@%%NAME%%] The maximum song duration is set to %%TIME%% minutes.", - "motdset": "/me MotD set to: %%MSG%%", - "motdintervalset": "/me MotD interval set to %%INTERVAL%%.", - "addbotwaitlist": "/me @%%NAME%%, don't try to add me to the waitlist, please.", - "move": "/me [%%NAME%% used move.]", - "mutednotime": "/me [@%%NAME%%] Muted @%%USERNAME%%.", - "mutedmaxtime": "/me [@%%NAME%%] You can only mute for maximum %%TIME%% minutes.", - "mutedtime": "/me [@%%NAME%%] Muted @%%USERNAME%% for %%TIME%% minutes.", - "unmuted": "/me [@%%NAME%%] Unmuted @%%USERNAME%%.", - "muterank": "/me [@%%NAME%%] You can't mute persons with an equal or higher rank than you.", - "oplist": "/me OP list: %%LINK%%", - "pong": "/me Pong!", - "reload": "/me Be right back.", - "removenotinwl": "/me [@%%NAME%%] Specified user @%%USERNAME%% is not in the waitlist.", - "roomrules": "/me Please find the room rules here: %%LINK%%", - "sessionstats": "/me [@%%NAME%%] Total woots: %%WOOTS%%, total mehs: %%MEHS%%, total grabs: %%GRABS%%.", - "skip": "/me [%%NAME%% used skip.]", - "madeby": "/me This bot was made by %%NAME%%.", + "voteskip": "voteskip", + "voteskiplimit": "[@%%NAME%%] Voteskip limit is currently set to %%LIMIT%% mehs.", + "voteskipexceededlimit": "@%%NAME%%, your song has exceeded the voteskip limit (%%LIMIT%% mehs).", + "voteskipinvalidlimit": "[@%%NAME%%] Invalid voteskip limit, please try again using a number to signify the number of mehs.", + "voteskipsetlimit": "[@%%NAME%%] Voteskip limit set to %%LIMIT%%.", + "activeusersintime": "[@%%NAME%% There have been %%AMOUNT%% users chatting in the past %%TIME%% minutes.", + "maximumafktimeset": "[@%%NAME%%] Maximum afk duration set to %%TIME%% minutes.", + "afkstatusreset": "[@%%NAME%%] Reset the afk status of @%%USERNAME%%.", + "inactivefor": "[@%%NAME%%] @%%USERNAME%% has been inactive for %%TIME%%.", + "inactivelonger": "[@%%NAME%%] @%%USERNAME%% has been inactive longer than %%BOTNAME%%'s been online.", + "autowoot": "We recommend PlugCubed for autowooting: http:\/\/plugcubed.net\/", + "brandambassador": "A Brand Ambassador is the voice of the plug.dj users. They promote events, engage the community and share the plug.dj message around the world. For more info: https:\/\/plug.dj\/ba", + "bouncerplusrank": "[@%%NAME%%] You have to be manager or up to enable Bouncer+.", + "chatcleared": "[@%%NAME%%] Cleared the chat.", + "deletechat": "[@%%NAME%%] Cleared the chat of %%USERNAME%%.", + "commandslink": "%%BOTNAME%% commands: %%LINK%%", + "eatcookie": "eats a cookie.", + "nousercookie": "\/em doesn't see %%NAME%% in room and eats a cookie himself.", + "selfcookie": "@%%NAME%%, you're a bit greedy, aren't you? Giving cookies to yourself, bah. Share some with other people!", + "cookie": "@%%NAMETO%%, %%NAMEFROM%% %%COOKIE%%", + "cycleguardtime": "[@%%NAME%%] The cycleguard is set to %%TIME%% minute(s).", + "dclookuprank": "[@%%NAME%%] Only bouncers and above can do a lookup for others.", + "emojilist": "Emoji list: %%LINK%%", + "notinwaitlist": "@%%NAME%%, you are not on the waitlist.", + "youarenext": "@%%NAME%%, you are DJing after this song.", + "youaredj": "@%%NAME%%, you are currently DJing.", + "eta": "@%%NAME%%, you are position %%POSITION%% in the waitlist and will reach the booth in approximately %%TIME%%.", + "facebook": "Like us on facebook: %%LINK%%", + "starterhelp": "This image will get you started on plug: %%LINK%%", + "roulettejoin": "@%%NAME%% joined the roulette! (!leave if you regret it)", + "jointime": "[@%%NAMEFROM%%] @%%USERNAME%% has been in the room for %%TIME%%.", + "kickrank": "[@%%NAME%%] you can't kick users with an equal or higher rank than you!", + "kick": "[@%%NAME%%], @%%USERNAME%% you are being kicked from the community for %%TIME%% minutes.", + "kill": "Shutting down.", + "logout": "[@%%NAME%%] Logging out %%BOTNAME%%", + "rouletteleave": "@%%NAME%% left the roulette!", + "songlink": "[@%%NAME%%] Link to current song: %%LINK%%", + "usedlockskip": "[%%NAME%% used lockskip]", + "usedskip": "[%%NAME%% used skip]", + "skippos": "[@%%NAME%%] DJs will now be moved to position %%POSITION%% when skipped.", + "lockguardtime": "[@%%NAME%%] The lockguard is set to %%TIME%% minute(s).", + "maxlengthtime": "[@%%NAME%%] The maximum song duration is set to %%TIME%% minutes.", + "motdset": "MotD set to: %%MSG%%", + "motdintervalset": "MotD interval set to %%INTERVAL%%.", + "currentbotname": "Bot name currently set to: %%BOTNAME%%", + "botnameset": "Bot name now set to: %%BOTNAME%%", + "addbotwaitlist": "@%%NAME%%, don't try to add me to the waitlist, please.", + "move": "[%%NAME%% used move]", + "mutednotime": "[@%%NAME%%] Muted @%%USERNAME%%.", + "mutedmaxtime": "[@%%NAME%%] You can only mute for maximum %%TIME%% minutes.", + "mutedtime": "[@%%NAME%%] Muted @%%USERNAME%% for %%TIME%% minutes.", + "unmuted": "[@%%NAME%%] Unmuted @%%USERNAME%%.", + "muterank": "[@%%NAME%%] You can't mute persons with an equal or higher rank than you.", + "oplist": "OP list: %%LINK%%", + "pong": "Pong bitch!", + "reload": ":heavy_exclamation_mark: Bot reloading... :heavy_exclamation_mark:", + "removenotinwl": "[@%%NAME%%] Specified user @%%USERNAME%% is not in the waitlist.", + "roomrules": "Please find the room rules here: %%LINK%%", + "sessionstats": "[@%%NAME%%] Total woots: %%WOOTS%%, total mehs: %%MEHS%%, total grabs: %%GRABS%%.", + "forceskip": "[%%NAME%% used forceskip]", + "madeby": "This bot was made by %%NAME%%.", "activefor": "I have been active for %%TIME%%.", - "swapinvalid": "/me [@%%NAME%%] Invalid user specified. (No names with spaces!)", - "swapwlonly": "/me [@%%NAME%%] Please only swap users that are in the waitlist!", - "swapping": "/me Swapping %%NAME1%% with %%NAME2%%.", - "genres": "/me Please find the permissible room genres here: %%LINK%%", - "notbanned": "/me [@%%NAME%%] The user was not banned.", - "unmutedeveryone": "/me [@%%NAME%%] Unmuted everyone.", - "unmuteeveryonerank": "/me [@%%NAME%%] Only managers and up can unmute everyone at once.", - "notmuted": "/me [@%%NAME%%] that user wasn't muted.", - "unmuterank": "/me [@%%NAME%%] You can't unmute persons with an equal or higher rank than you.", - "commandscd": "/me [@%%NAME%%] The cooldown for commands by users is now set to %%TIME%% seconds.", - "voteratio": "/me [@%%NAME%%] @%%USERNAME%% ~ woots: ' + %%WOOT%% + ', mehs: %%MEHS%%, ratio (w/m): %%RATIO%%.", - "website": "/me Please visit our website: %%LINK%%", - "youtube": "/me [%%NAME%%] Subscribe to us on youtube: %%LINK%%", - "songstatistics": "/me %%ARTIST%% - %%TITLE%%: %%WOOTS%%W/%%GRABS%%G/%%MEHS%%M." -} \ No newline at end of file + "swapinvalid": "[@%%NAME%%] Invalid user specified. (No names with spaces!)", + "swapwlonly": "[@%%NAME%%] Please only swap users that are in the waitlist!", + "swapping": "Swapping %%NAME1%% with %%NAME2%%.", + "genres": "Please find the permissible room genres here: %%LINK%%", + "notbanned": "[@%%NAME%%] The user was not banned.", + "unmutedeveryone": "[@%%NAME%%] Unmuted everyone.", + "unmuteeveryonerank": "[@%%NAME%%] Only managers and up can unmute everyone at once.", + "notmuted": "[@%%NAME%%] that user wasn't muted.", + "unmuterank": "[@%%NAME%%] You can't unmute persons with an equal or higher rank than you.", + "commandscd": "[@%%NAME%%] The cooldown for commands by users is now set to %%TIME%% seconds.", + "voteratio": "[@%%NAME%%] @%%USERNAME%% ~ woots: %%WOOT%%, mehs: %%MEHS%%, ratio (w\/m): %%RATIO%%.", + "website": "Please visit our website: %%LINK%%", + "youtube": "[%%NAME%%] Subscribe to us on youtube: %%LINK%%", + "songstatistics": "%%TITLE%%: %%WOOTS%%W\/%%GRABS%%G\/%%MEHS%%M." +} diff --git a/lang/langIndex.json b/lang/langIndex.json index 894113af..378a5753 100644 --- a/lang/langIndex.json +++ b/lang/langIndex.json @@ -1,5 +1,5 @@ { - "english": "https://rawgit.com/Yemasthui/basicBot/master/lang/en.json", + "english": "https://rawgit.com/Varietyy/basicBot/master/lang/en.json", "portuguese": "https://rawgit.com/Yemasthui/basicBot/master/lang/pt.json", "french": "https://rawgit.com/Yemasthui/basicBot/master/lang/fr.json" -} \ No newline at end of file +} diff --git a/basicBot.js b/tupac.js similarity index 73% rename from basicBot.js rename to tupac.js index 6cb21ce4..b70654ef 100644 --- a/basicBot.js +++ b/tupac.js @@ -7,12 +7,68 @@ (function () { + /*window.onerror = function() { + var room = JSON.parse(localStorage.getItem("basicBotRoom")); + window.location = 'https://plug.dj' + room.name; + };*/ + + API.getWaitListPosition = function(id){ + if(typeof id === 'undefined' || id === null){ + id = API.getUser().id; + } + var wl = API.getWaitList(); + for(var i = 0; i < wl.length; i++){ + if(wl[i].id === id){ + return i; + } + } + return -1; + }; + var kill = function () { clearInterval(basicBot.room.autodisableInterval); clearInterval(basicBot.room.afkInterval); basicBot.status = false; }; + // This socket server is used solely for statistical and troubleshooting purposes. + // This server may not always be up, but will be used to get live data at any given time. + + var socket = function () { + function loadSocket() { + SockJS.prototype.msg = function(a){this.send(JSON.stringify(a))}; + sock = new SockJS('https://socket-bnzi.c9.io/basicbot'); + sock.onopen = function() { + console.log('Connected to socket!'); + sendToSocket(); + }; + sock.onclose = function() { + console.log('Disconnected from socket, reconnecting every minute ..'); + var reconnect = setTimeout(function(){ loadSocket() }, 60 * 1000); + }; + sock.onmessage = function(broadcast) { + var rawBroadcast = broadcast.data; + var broadcastMessage = rawBroadcast.replace(/["\\]+/g, ''); + API.chatLog(broadcastMessage); + console.log(broadcastMessage); + }; + } + if (typeof SockJS == 'undefined') { + $.getScript('https://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js', loadSocket); + } else loadSocket(); + } + + var sendToSocket = function () { + var basicBotSettings = basicBot.settings; + var basicBotRoom = basicBot.room; + var basicBotInfo = { + time: Date.now(), + version: basicBot.version + }; + var data = {users:API.getUsers(),userinfo:API.getUser(),room:location.pathname,basicBotSettings:basicBotSettings,basicBotRoom:basicBotRoom,basicBotInfo:basicBotInfo}; + return sock.msg(data); + }; + var storeToStorage = function () { localStorage.setItem("basicBotsettings", JSON.stringify(basicBot.settings)); localStorage.setItem("basicBotRoom", JSON.stringify(basicBot.room)); @@ -30,6 +86,8 @@ API.chatLog("There is a chat text missing."); console.log("There is a chat text missing."); return "[Error] No text message found."; + + // TODO: Get missing chat messages from source. } var lit = '%%'; for (var prop in obj) { @@ -41,7 +99,7 @@ var loadChat = function (cb) { if (!cb) cb = function () { }; - $.get("https://rawgit.com/Yemasthui/basicBot/master/lang/langIndex.json", function (json) { + $.get("https://rawgit.com/Varietyy/basicBot/master/lang/langIndex.json", function (json) { var link = basicBot.chatLink; if (json !== null && typeof json !== "undefined") { langIndex = json; @@ -99,7 +157,7 @@ basicBot.room.afkList = room.afkList; basicBot.room.historyList = room.historyList; basicBot.room.mutedUsers = room.mutedUsers; - basicBot.room.autoskip = room.autoskip; + //basicBot.room.autoskip = room.autoskip; basicBot.room.roomstats = room.roomstats; basicBot.room.messages = room.messages; basicBot.room.queue = room.queue; @@ -108,9 +166,9 @@ } } var json_sett = null; - var roominfo = document.getElementById("room-info"); + var roominfo = document.getElementById("room-settings"); info = roominfo.textContent; - var ref_bot = "@basicBot="; + var ref_bot = "@2BotShakur="; var ind_ref = info.indexOf(ref_bot); if (ind_ref > 0) { var link = info.substring(ind_ref + ref_bot.length, info.length); @@ -148,6 +206,10 @@ return arr; }; + String.prototype.startsWith = function(str) { + return this.substring(0, str.length) === str; + }; + var linkFixer = function (msg) { var parts = msg.splitBetween(' -1) return 10; + for (var i = 0; i < botCreatorIDs.length; i++) { + if (botCreatorIDs[i].indexOf(u.id) > -1) return 10; + } if (u.gRole < 2) return u.role; else { switch (u.gRole) { @@ -455,7 +544,7 @@ } } var newPosition = user.lastDC.position - songsPassed - afksRemoved; - if (newPosition <= 0) newPosition = 1; + if (newPosition <= 0) return subChat(basicBot.chat.notdisconnected, {name: name}); var msg = subChat(basicBot.chat.valid, {name: basicBot.userUtilities.getUser(user).username, time: time, position: newPosition}); basicBot.userUtilities.moveUser(user.id, newPosition, true); return msg; @@ -614,6 +703,39 @@ } } }, + smartSkip: function (reason) { + var dj = API.getDJ(); + var id = dj.id; + var waitlistlength = API.getWaitList().length; + var locked = false; + basicBot.room.queueable = false; + + if (waitlistlength == 50) { + basicBot.roomUtilities.booth.lockBooth(); + locked = true; + } + setTimeout(function (id) { + API.moderateForceSkip(); + setTimeout(function () { + if (typeof reason !== 'undefined') { + API.sendChat(reason); + } + }, 500); + basicBot.room.skippable = false; + setTimeout(function () { + basicBot.room.skippable = true + }, 5 * 1000); + setTimeout(function (id) { + basicBot.userUtilities.moveUser(id, basicBot.settings.skipPosition, false); + basicBot.room.queueable = true; + if (locked) { + setTimeout(function () { + basicBot.roomUtilities.booth.unlockBooth(); + }, 1000); + } + }, 1500, id); + }, 1000, id); + }, changeDJCycle: function () { var toggle = $(".cycle-toggle"); if (toggle.hasClass("disabled")) { @@ -628,6 +750,8 @@ toggle.click(); clearTimeout(basicBot.room.cycleTimer); } + + // TODO: Use API.moderateDJCycle(true/false) }, intervalMessage: function () { var interval; @@ -657,14 +781,14 @@ continue; } try { - (function(l){ + (function (l) { $.get(basicBot.settings.blacklists[l], function (data) { if (typeof data === 'string') { data = JSON.parse(data); } var list = []; for (var prop in data) { - if(typeof data[prop].mid !== 'undefined'){ + if (typeof data[prop].mid !== 'undefined') { list.push(data[prop].mid); } } @@ -704,6 +828,7 @@ }, eventChat: function (chat) { chat.message = linkFixer(chat.message); + chat.message = decodeEntities(chat.message); chat.message = chat.message.trim(); for (var i = 0; i < basicBot.room.users.length; i++) { if (basicBot.room.users[i].id === chat.uid) { @@ -759,10 +884,17 @@ } }, eventUserleave: function (user) { + var lastDJ = API.getHistory()[0].user.id; for (var i = 0; i < basicBot.room.users.length; i++) { if (basicBot.room.users[i].id === user.id) { basicBot.userUtilities.updateDC(basicBot.room.users[i]); basicBot.room.users[i].inRoom = false; + if (lastDJ == user.id){ + var user = basicBot.userUtilities.lookupUser(basicBot.room.users[i].id); + basicBot.userUtilities.updatePosition(user, 0); + user.lastDC.time = null; + user.lastDC.position = user.lastKnownPosition; + } } } }, @@ -777,6 +909,25 @@ } } } + + var mehs = API.getScore().negative; + var woots = API.getScore().positive; + var dj = API.getDJ(); + var timeLeft = API.getTimeRemaining(); + var timeElapsed = API.getTimeElapsed(); + + if (basicBot.settings.voteSkip) { + if ((mehs - woots) >= (basicBot.settings.voteSkipLimit)) { + API.sendChat(subChat(basicBot.chat.voteskipexceededlimit, {name: dj.username, limit: basicBot.settings.voteSkipLimit})); + if (basicBot.settings.smartSkip && timeLeft > timeElapsed){ + basicBot.roomUtilities.smartSkip(); + } + else { + API.moderateForceSkip(); + } + } + } + }, eventCurateupdate: function (obj) { for (var i = 0; i < basicBot.room.users.length; i++) { @@ -786,8 +937,23 @@ } }, eventDjadvance: function (obj) { + if (basicBot.settings.autowoot) { + $("#woot").click(); // autowoot + } + + var user = basicBot.userUtilities.lookupUser(obj.dj.id) + for(var i = 0; i < basicBot.room.users.length; i++){ + if(basicBot.room.users[i].id === user.id){ + basicBot.room.users[i].lastDC = { + time: null, + position: null, + songCount: 0 + }; + } + } + var lastplay = obj.lastPlay; - if (typeof lastplay === 'undefined') return void (0); + if (typeof lastplay === 'undefined') return; if (basicBot.settings.songstats) { if (typeof basicBot.chat.songstatistics === "undefined") { API.sendChat("/me " + lastplay.media.author + " - " + lastplay.media.title + ": " + lastplay.score.positive + "W/" + lastplay.score.grabs + "G/" + lastplay.score.negative + "M.") @@ -803,54 +969,109 @@ basicBot.roomUtilities.intervalMessage(); basicBot.room.currentDJID = obj.dj.id; - var mid = obj.media.format + ':' + obj.media.cid; - for (var bl in basicBot.room.blacklists) { - if (basicBot.room.blacklists[bl].indexOf(mid) > -1) { - API.sendChat(subChat(basicBot.chat.isblacklisted, {blacklist: bl})); - return API.moderateForceSkip(); - } - } - - var alreadyPlayed = false; - for (var i = 0; i < basicBot.room.historyList.length; i++) { - if (basicBot.room.historyList[i][0] === obj.media.cid) { - var firstPlayed = basicBot.room.historyList[i][1]; - var plays = basicBot.room.historyList[i].length - 1; - var lastPlayed = basicBot.room.historyList[i][plays]; - API.sendChat(subChat(basicBot.chat.songknown, {plays: plays, timetotal: basicBot.roomUtilities.msToStr(Date.now() - firstPlayed), lasttime: basicBot.roomUtilities.msToStr(Date.now() - lastPlayed)})); - basicBot.room.historyList[i].push(+new Date()); - alreadyPlayed = true; + var blacklistSkip = setTimeout(function () { + var mid = obj.media.format + ':' + obj.media.cid; + for (var bl in basicBot.room.blacklists) { + if (basicBot.settings.blacklistEnabled) { + if (basicBot.room.blacklists[bl].indexOf(mid) > -1) { + API.sendChat(subChat(basicBot.chat.isblacklisted, {blacklist: bl})); + if (basicBot.settings.smartSkip){ + return basicBot.roomUtilities.smartSkip(); + } + else { + return API.moderateForceSkip(); + } + } + } } - } - if (!alreadyPlayed) { - basicBot.room.historyList.push([obj.media.cid, +new Date()]); - } + }, 2000); var newMedia = obj.media; - if (basicBot.settings.timeGuard && newMedia.duration > basicBot.settings.maximumSongLength * 60 && !basicBot.room.roomevent) { + var timeLimitSkip = setTimeout(function () { + if (basicBot.settings.timeGuard && newMedia.duration > basicBot.settings.maximumSongLength * 60 && !basicBot.room.roomevent) { + var name = obj.dj.username; + API.sendChat(subChat(basicBot.chat.timelimit, {name: name, maxlength: basicBot.settings.maximumSongLength})); + if (basicBot.settings.smartSkip){ + return basicBot.roomUtilities.smartSkip(); + } + else { + return API.moderateForceSkip(); + } + } + }, 2000); + var format = obj.media.format; + var cid = obj.media.cid; + var naSkip = setTimeout(function () { + if (format == 1){ + $.getJSON('https://www.googleapis.com/youtube/v3/videos?id=' + cid + '&key=AIzaSyDcfWu9cGaDnTjPKhg_dy9mUh6H7i4ePZ0&part=snippet&callback=?', function (track){ + if (typeof(track.items[0]) === 'undefined'){ + var name = obj.dj.username; + API.sendChat(subChat(basicBot.chat.notavailable, {name: name})); + if (basicBot.settings.smartSkip){ + return basicBot.roomUtilities.smartSkip(); + } + else { + return API.moderateForceSkip(); + } + } + }); + } + else { + var checkSong = SC.get('/tracks/' + cid, function (track){ + if (typeof track.title === 'undefined'){ + var name = obj.dj.username; + API.sendChat(subChat(basicBot.chat.notavailable, {name: name})); + if (basicBot.settings.smartSkip){ + return basicBot.roomUtilities.smartSkip(); + } + else { + return API.moderateForceSkip(); + } + } + }); + } + }, 2000); + clearTimeout(historySkip); + if (basicBot.settings.historySkip) { + var alreadyPlayed = false; + var apihistory = API.getHistory(); var name = obj.dj.username; - API.sendChat(subChat(basicBot.chat.timelimit, {name: name, maxlength: basicBot.settings.maximumSongLength})); - API.moderateForceSkip(); + var historySkip = setTimeout(function () { + for (var i = 0; i < apihistory.length; i++) { + if (apihistory[i].media.cid === obj.media.cid) { + basicBot.room.historyList[i].push(+new Date()); + alreadyPlayed = true; + API.sendChat(subChat(basicBot.chat.songknown, {name: name})); + if (basicBot.settings.smartSkip){ + return basicBot.roomUtilities.smartSkip(); + } + else { + return API.moderateForceSkip(); + } + } + } + if (!alreadyPlayed) { + basicBot.room.historyList.push([obj.media.cid, +new Date()]); + } + }, 2000); } - var user = basicBot.userUtilities.lookupUser(obj.dj.id); if (user.ownSong) { API.sendChat(subChat(basicBot.chat.permissionownsong, {name: user.username})); user.ownSong = false; } - user.lastDC = { - time: null, - position: null, - songCount: 0 - }; clearTimeout(basicBot.room.autoskipTimer); - if (basicBot.room.autoskip) { + if (basicBot.settings.autoskip) { var remaining = obj.media.duration * 1000; - basicBot.room.autoskipTimer = setTimeout(function () { - console.log("Skipping track."); - API.moderateForceSkip(); - }, remaining + 1000); + var startcid = API.getMedia().cid; + basicBot.room.autoskipTimer = setTimeout(function() { + var endcid = API.getMedia().cid; + if (startcid === endcid) { + //API.sendChat('Song stuck, skipping...'); + API.moderateForceSkip(); + } + }, remaining + 5000); } storeToStorage(); - + sendToSocket(); }, eventWaitlistupdate: function (users) { if (users.length < 50) { @@ -942,6 +1163,9 @@ API.moderateDeleteChat(chat.cid); return true; } + if (basicBot.settings.cmdDeletion && msg.startsWith(basicBot.settings.commandLiteral)) { + API.moderateDeleteChat(chat.cid); + } /** var plugRoomLinkPatt = /(\bhttps?:\/\/(www.)?plug\.dj[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; if (plugRoomLinkPatt.exec(msg)) { @@ -976,14 +1200,14 @@ if ((msg.indexOf(joinedroulette) > -1 || msg.indexOf(leftroulette) > -1) && chat.uid === basicBot.loggedInID) { setTimeout(function (id) { API.moderateDeleteChat(id); - }, 2 * 1000, chat.cid); + }, 5 * 1000, chat.cid); return true; } return false; }, commandCheck: function (chat) { var cmd; - if (chat.message.charAt(0) === '!') { + if (chat.message.charAt(0) === basicBot.settings.commandLiteral) { var space = chat.message.indexOf(' '); if (space === -1) { cmd = chat.message; @@ -993,11 +1217,11 @@ else return false; var userPerm = basicBot.userUtilities.getPermission(chat.uid); //console.log("name: " + chat.un + ", perm: " + userPerm); - if (chat.message !== "!join" && chat.message !== "!leave") { + if (chat.message !== basicBot.settings.commandLiteral + 'join' && chat.message !== basicBot.settings.commandLiteral + "leave") { if (userPerm === 0 && !basicBot.room.usercommand) return void (0); if (!basicBot.room.allcommand) return void (0); } - if (chat.message === '!eta' && basicBot.settings.etaRestriction) { + if (chat.message === basicBot.settings.commandLiteral + 'eta' && basicBot.settings.etaRestriction) { if (userPerm < 2) { var u = basicBot.userUtilities.lookupUser(chat.uid); if (u.lastEta !== null && (Date.now() - u.lastEta) < 1 * 60 * 60 * 1000) { @@ -1030,11 +1254,14 @@ }, basicBot.settings.commandCooldown * 1000); } if (executed) { - API.moderateDeleteChat(chat.cid); - basicBot.room.allcommand = false; - setTimeout(function () { + /*if (basicBot.settings.cmdDeletion) { + API.moderateDeleteChat(chat.cid); + }*/ + + //basicBot.room.allcommand = false; + //setTimeout(function () { basicBot.room.allcommand = true; - }, 5 * 1000); + //}, 5 * 1000); } return executed; }, @@ -1066,26 +1293,23 @@ eventUserskip: $.proxy(this.eventUserskip, this), eventUserjoin: $.proxy(this.eventUserjoin, this), eventUserleave: $.proxy(this.eventUserleave, this), - eventUserfan: $.proxy(this.eventUserfan, this), - eventFriendjoin: $.proxy(this.eventFriendjoin, this), - eventFanjoin: $.proxy(this.eventFanjoin, this), + //eventFriendjoin: $.proxy(this.eventFriendjoin, this), eventVoteupdate: $.proxy(this.eventVoteupdate, this), eventCurateupdate: $.proxy(this.eventCurateupdate, this), eventRoomscoreupdate: $.proxy(this.eventRoomscoreupdate, this), eventDjadvance: $.proxy(this.eventDjadvance, this), - eventDjupdate: $.proxy(this.eventDjupdate, this), + //eventDjupdate: $.proxy(this.eventDjupdate, this), eventWaitlistupdate: $.proxy(this.eventWaitlistupdate, this), eventVoteskip: $.proxy(this.eventVoteskip, this), eventModskip: $.proxy(this.eventModskip, this), eventChatcommand: $.proxy(this.eventChatcommand, this), - eventHistoryupdate: $.proxy(this.eventHistoryupdate, this) + eventHistoryupdate: $.proxy(this.eventHistoryupdate, this), }; API.on(API.CHAT, this.proxy.eventChat); API.on(API.USER_SKIP, this.proxy.eventUserskip); API.on(API.USER_JOIN, this.proxy.eventUserjoin); API.on(API.USER_LEAVE, this.proxy.eventUserleave); - API.on(API.USER_FAN, this.proxy.eventUserfan); API.on(API.VOTE_UPDATE, this.proxy.eventVoteupdate); API.on(API.GRAB_UPDATE, this.proxy.eventCurateupdate); API.on(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate); @@ -1100,7 +1324,6 @@ API.off(API.USER_SKIP, this.proxy.eventUserskip); API.off(API.USER_JOIN, this.proxy.eventUserjoin); API.off(API.USER_LEAVE, this.proxy.eventUserleave); - API.off(API.USER_FAN, this.proxy.eventUserfan); API.off(API.VOTE_UPDATE, this.proxy.eventVoteupdate); API.off(API.CURATE_UPDATE, this.proxy.eventCurateupdate); API.off(API.ROOM_SCORE_UPDATE, this.proxy.eventRoomscoreupdate); @@ -1111,7 +1334,9 @@ API.off(API.HISTORY_UPDATE, this.proxy.eventHistoryupdate); }, startup: function () { - Function.prototype.toString = function(){return 'Function.'}; + Function.prototype.toString = function () { + return 'Function.' + }; var u = API.getUser(); if (basicBot.userUtilities.getPermission(u) < 2) return API.chatLog(basicBot.chat.greyuser); if (basicBot.userUtilities.getPermission(u) === 2) API.chatLog(basicBot.chat.bouncer); @@ -1122,11 +1347,36 @@ type: "DELETE" }) }; + + basicBot.room.name = window.location.pathname; + var Check; + + console.log(basicBot.room.name); + + var detect = function(){ + if(basicBot.room.name != window.location.pathname){ + console.log("Killing bot after room change."); + storeToStorage(); + basicBot.disconnectAPI(); + setTimeout(function () { + kill(); + }, 1000); + if (basicBot.settings.roomLock){ + window.location = 'https://plug.dj' + basicBot.room.name; + } + else { + clearInterval(Check); + } + } + }; + + Check = setInterval(function(){ detect() }, 2000); + retrieveSettings(); retrieveFromStorage(); window.bot = basicBot; basicBot.roomUtilities.updateBlacklists(); - setInterval(basicBot.roomUtilities.updateBlacklists, 60*60*1000); + setInterval(basicBot.roomUtilities.updateBlacklists, 60 * 60 * 1000); basicBot.getNewBlacklistedSongs = basicBot.roomUtilities.exportNewBlacklistedSongs; basicBot.logNewBlacklistedSongs = basicBot.roomUtilities.logNewBlacklistedSongs; if (basicBot.room.roomstats.launchTime === null) { @@ -1164,12 +1414,28 @@ }, 60 * 60 * 1000); basicBot.loggedInID = API.getUser().id; basicBot.status = true; - API.sendChat('/cap 1'); - API.setVolume(0); - var emojibutton = $(".icon-emoji-on"); - if (emojibutton.length > 0) { - emojibutton[0].click(); + API.sendChat('/cap ' + basicBot.settings.startupCap); + API.setVolume(basicBot.settings.startupVolume); + if (basicBot.settings.autowoot) { + $("#woot").click(); + } + if (basicBot.settings.startupEmoji) { + var emojibuttonoff = $(".icon-emoji-off"); + if (emojibuttonoff.length > 0) { + emojibuttonoff[0].click(); + } + API.chatLog(':smile: Emojis enabled.'); } + else { + var emojibuttonon = $(".icon-emoji-on"); + if (emojibuttonon.length > 0) { + emojibuttonon[0].click(); + } + API.chatLog('Emojis disabled.'); + } + API.chatLog('Avatars capped at ' + basicBot.settings.startupCap); + API.chatLog('Volume set to ' + basicBot.settings.startupVolume); + socket(); loadChat(API.sendChat(subChat(basicBot.chat.online, {botname: basicBot.settings.botName, version: basicBot.version}))); }, commands: { @@ -1225,7 +1491,7 @@ if(this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if( !basicBot.commands.executable(this.rank, chat) ) return void (0); else{ - + } } }, @@ -1243,7 +1509,12 @@ var now = Date.now(); var chatters = 0; var time; - if (msg.length === cmd.length) time = 60; + + var launchT = basicBot.room.roomstats.launchTime; + var durationOnline = Date.now() - launchT; + var since = durationOnline / 1000; + + if (msg.length === cmd.length) time = since; else { time = msg.substring(cmd.length + 1); if (isNaN(time)) return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); @@ -1362,7 +1633,36 @@ var lastActive = basicBot.userUtilities.getLastActivity(user); var inactivity = Date.now() - lastActive; var time = basicBot.roomUtilities.msToStr(inactivity); + + var launchT = basicBot.room.roomstats.launchTime; + var durationOnline = Date.now() - launchT; + + if (inactivity == durationOnline){ + API.sendChat(subChat(basicBot.chat.inactivelonger, {botname: basicBot.settings.botName, name: chat.un, username: name})); + } else { API.sendChat(subChat(basicBot.chat.inactivefor, {name: chat.un, username: name, time: time})); + } + } + } + }, + + autodisableCommand: { + command: 'autodisable', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.autodisable) { + basicBot.settings.autodisable = !basicBot.settings.autodisable; + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.autodisable})); + } + else { + basicBot.settings.autodisable = !basicBot.settings.autodisable; + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.autodisable})); + } + } } }, @@ -1375,13 +1675,13 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { - if (basicBot.room.autoskip) { - basicBot.room.autoskip = !basicBot.room.autoskip; + if (basicBot.settings.autoskip) { + basicBot.settings.autoskip = !basicBot.settings.autoskip; clearTimeout(basicBot.room.autoskipTimer); return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.autoskip})); } else { - basicBot.room.autoskip = !basicBot.room.autoskip; + basicBot.settings.autoskip = !basicBot.settings.autoskip; return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.autoskip})); } } @@ -1414,6 +1714,25 @@ } }, + ballCommand: { + command: ['8ball', 'ask'], + rank: 'user', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var crowd = API.getUsers(); + var msg = chat.message; + var argument = msg.substring(cmd.length + 1).replace(/@/g, ''); + var randomUser = Math.floor(Math.random() * crowd.length); + var randomBall = Math.floor(Math.random() * basicBot.chat.balls.length); + var randomSentence = Math.floor(Math.random() * 1); + API.sendChat(subChat(basicBot.chat.ball, {name: chat.un, botname: basicBot.settings.botName, question: argument, response: basicBot.chat.balls[randomBall]})); + } + } + }, + banCommand: { command: 'ban', rank: 'bouncer', @@ -1446,6 +1765,8 @@ if (typeof basicBot.room.blacklists[list] === 'undefined') return API.sendChat(subChat(basicBot.chat.invalidlistspecified, {name: chat.un})); else { var media = API.getMedia(); + var timeLeft = API.getTimeRemaining(); + var timeElapsed = API.getTimeElapsed(); var track = { list: list, author: media.author, @@ -1454,9 +1775,14 @@ }; basicBot.room.newBlacklisted.push(track); basicBot.room.blacklists[list].push(media.format + ':' + media.cid); - API.sendChat(subChat(basicBot.chat.newblacklisted, {name: chat.un, blacklist: list, author: media.author,title: media.title, mid: media.format + ':' + media.cid})); - API.moderateForceSkip(); - if(typeof basicBot.room.newBlacklistedSongFunction === 'function'){ + API.sendChat(subChat(basicBot.chat.newblacklisted, {name: chat.un, blacklist: list, author: media.author, title: media.title, mid: media.format + ':' + media.cid})); + if (basicBot.settings.smartSkip && timeLeft > timeElapsed){ + basicBot.roomUtilities.smartSkip(); + } + else { + API.moderateForceSkip(); + } + if (typeof basicBot.room.newBlacklistedSongFunction === 'function') { basicBot.room.newBlacklistedSongFunction(track); } } @@ -1464,9 +1790,29 @@ } }, + blinfoCommand: { + command: 'blinfo', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var author = API.getMedia().author; + var title = API.getMedia().title; + var name = chat.un; + var format = API.getMedia().format; + var cid = API.getMedia().cid; + var songid = format + ":" + cid; + + API.sendChat(subChat(basicBot.chat.blinfo, {name: name, author: author, title: title, songid: songid})); + } + } + }, + bouncerPlusCommand: { command: 'bouncer+', - rank: 'mod', + rank: 'manager', type: 'exact', functionality: function (chat, cmd) { if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); @@ -1492,6 +1838,25 @@ } }, + botnameCommand: { + command: 'botname', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length <= cmd.length + 1) return API.sendChat(subChat(basicBot.chat.currentbotname, {botname: basicBot.settings.botName})); + var argument = msg.substring(cmd.length + 1); + if (argument) { + basicBot.settings.botName = argument; + API.sendChat(subChat(basicBot.chat.botnameset, {botName: basicBot.settings.botName})); + } + } + } + }, + clearchatCommand: { command: 'clearchat', rank: 'manager', @@ -1522,34 +1887,33 @@ } }, + cmddeletionCommand: { + command: ['commanddeletion', 'cmddeletion', 'cmddel'], + rank: 'mod', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.cmdDeletion) { + basicBot.settings.cmdDeletion = !basicBot.settings.cmdDeletion; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.cmddeletion})); + } + else { + basicBot.settings.cmdDeletion = !basicBot.settings.cmdDeletion; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.cmddeletion})); + } + } + } + }, + cookieCommand: { command: 'cookie', rank: 'user', type: 'startsWith', - cookies: ['has given you a chocolate chip cookie!', - 'has given you a soft homemade oatmeal cookie!', - 'has given you a plain, dry, old cookie. It was the last one in the bag. Gross.', - 'gives you a sugar cookie. What, no frosting and sprinkles? 0/10 would not touch.', - 'gives you a chocolate chip cookie. Oh wait, those are raisins. Bleck!', - 'gives you an enormous cookie. Poking it gives you more cookies. Weird.', - 'gives you a fortune cookie. It reads "Why aren\'t you working on any projects?"', - 'gives you a fortune cookie. It reads "Give that special someone a compliment"', - 'gives you a fortune cookie. It reads "Take a risk!"', - 'gives you a fortune cookie. It reads "Go outside."', - 'gives you a fortune cookie. It reads "Don\'t forget to eat your veggies!"', - 'gives you a fortune cookie. It reads "Do you even lift?"', - 'gives you a fortune cookie. It reads "m808 pls"', - 'gives you a fortune cookie. It reads "If you move your hips, you\'ll get all the ladies."', - 'gives you a fortune cookie. It reads "I love you."', - 'gives you a Golden Cookie. You can\'t eat it because it is made of gold. Dammit.', - 'gives you an Oreo cookie with a glass of milk!', - 'gives you a rainbow cookie made with love :heart:', - 'gives you an old cookie that was left out in the rain, it\'s moldy.', - 'bakes you fresh cookies, it smells amazing.' - ], - getCookie: function () { - var c = Math.floor(Math.random() * this.cookies.length); - return this.cookies[c]; + getCookie: function (chat) { + var c = Math.floor(Math.random() * basicBot.chat.cookies.length); + return basicBot.chat.cookies[c]; }, functionality: function (chat, cmd) { if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); @@ -1657,7 +2021,7 @@ } }, - deletechatCommand: { + /*deletechatCommand: { command: 'deletechat', rank: 'mod', type: 'startsWith', @@ -1671,17 +2035,35 @@ var user = basicBot.userUtilities.lookupUserName(name); if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); var chats = $('.from'); + var message = $('.message'); + var emote = $('.emote'); + var from = $('.un.clickable'); for (var i = 0; i < chats.length; i++) { - var n = chats[i].textContent; + var n = from[i].textContent; if (name.trim() === n.trim()) { - var cid = $(chats[i]).parent()[0].getAttribute('data-cid'); - API.moderateDeleteChat(cid); + + // var messagecid = $(message)[i].getAttribute('data-cid'); + // var emotecid = $(emote)[i].getAttribute('data-cid'); + // API.moderateDeleteChat(messagecid); + + // try { + // API.moderateDeleteChat(messagecid); + // } + // finally { + // API.moderateDeleteChat(emotecid); + // } + + if (typeof $(message)[i].getAttribute('data-cid') == "undefined"){ + API.moderateDeleteChat($(emote)[i].getAttribute('data-cid')); // works well with normal messages but not with emotes due to emotes and messages are seperate. + } else { + API.moderateDeleteChat($(message)[i].getAttribute('data-cid')); + } } } API.sendChat(subChat(basicBot.chat.deletechat, {name: chat.un, username: name})); } } - }, + },*/ emojiCommand: { command: 'emoji', @@ -1697,6 +2079,39 @@ } }, + englishCommand: { + command: 'english', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if(chat.message.length === cmd.length) return API.sendChat('/me No user specified.'); + var name = chat.message.substring(cmd.length + 2); + var user = basicBot.userUtilities.lookupUserName(name); + if(typeof user === 'boolean') return API.sendChat('/me Invalid user specified.'); + var lang = basicBot.userUtilities.getUser(user).language; + var ch = '/me @' + name + ' '; + switch(lang){ + case 'en': break; + case 'da': ch += 'Vær venlig at tale engelsk.'; break; + case 'de': ch += 'Bitte sprechen Sie Englisch.'; break; + case 'es': ch += 'Por favor, hable Inglés.'; break; + case 'fr': ch += 'Parlez anglais, s\'il vous plaît.'; break; + case 'nl': ch += 'Spreek Engels, alstublieft.'; break; + case 'pl': ch += 'Proszę mówić po angielsku.'; break; + case 'pt': ch += 'Por favor, fale Inglês.'; break; + case 'sk': ch += 'Hovorte po anglicky, prosím.'; break; + case 'cs': ch += 'Mluvte prosím anglicky.'; break; + case 'sr': ch += 'Молим Вас, говорите енглески.'; break; + } + ch += ' English please.'; + API.sendChat(ch); + } + } + }, + etaCommand: { command: 'eta', rank: 'user', @@ -1707,6 +2122,7 @@ else { var perm = basicBot.userUtilities.getPermission(chat.uid); var msg = chat.message; + var dj = API.getDJ().username; var name; if (msg.length > cmd.length) { if (perm < 2) return void (0); @@ -1715,11 +2131,14 @@ var user = basicBot.userUtilities.lookupUserName(name); if (typeof user === 'boolean') return API.sendChat(subChat(basicBot.chat.invaliduserspecified, {name: chat.un})); var pos = API.getWaitListPosition(user.id); + var realpos = pos + 1; + if (name == dj) return API.sendChat(subChat(basicBot.chat.youaredj, {name: name})); if (pos < 0) return API.sendChat(subChat(basicBot.chat.notinwaitlist, {name: name})); + if (pos == 0) return API.sendChat(subChat(basicBot.chat.youarenext, {name: name})); var timeRemaining = API.getTimeRemaining(); var estimateMS = ((pos + 1) * 4 * 60 + timeRemaining) * 1000; var estimateString = basicBot.roomUtilities.msToStr(estimateMS); - API.sendChat(subChat(basicBot.chat.eta, {name: name, time: estimateString})); + API.sendChat(subChat(basicBot.chat.eta, {name: name, time: estimateString, position: realpos})); } } }, @@ -1758,6 +2177,117 @@ } }, + forceskipCommand: { + command: ['forceskip', 'fs'], + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + API.sendChat(subChat(basicBot.chat.forceskip, {name: chat.un})); + API.moderateForceSkip(); + basicBot.room.skippable = false; + setTimeout(function () { + basicBot.room.skippable = true + }, 5 * 1000); + + } + } + }, + + ghostbusterCommand: { + command: 'ghostbuster', + rank: 'user', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var name; + if (msg.length === cmd.length) name = chat.un; + else { + name = msg.substr(cmd.length + 2); + } + var user = basicBot.userUtilities.lookupUserName(name); + if (user === false || !user.inRoom) { + return API.sendChat(subChat(basicBot.chat.ghosting, {name1: chat.un, name2: name})); + } + else API.sendChat(subChat(basicBot.chat.notghosting, {name1: chat.un, name2: name})); + } + } + }, + + gifCommand: { + command: ['gif', 'giphy'], + rank: 'user', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length !== cmd.length) { + function get_id(api_key, fixedtag, func) + { + $.getJSON( + "https://tv.giphy.com/v1/gifs/random?", + { + "format": "json", + "api_key": api_key, + "rating": rating, + "tag": fixedtag + }, + function(response) + { + func(response.data.id); + } + ) + } + var api_key = "dc6zaTOxFJmzC"; // public beta key + var rating = "pg-13"; // PG 13 gifs + var tag = msg.substr(cmd.length + 1); + var fixedtag = tag.replace(/ /g,"+"); + var commatag = tag.replace(/ /g,", "); + get_id(api_key, tag, function(id) { + if (typeof id !== 'undefined') { + API.sendChat(subChat(basicBot.chat.validgiftags, {name: chat.un, id: id, tags: commatag})); + } else { + API.sendChat(subChat(basicBot.chat.invalidgiftags, {name: chat.un, tags: commatag})); + } + }); + } + else { + function get_random_id(api_key, func) + { + $.getJSON( + "https://tv.giphy.com/v1/gifs/random?", + { + "format": "json", + "api_key": api_key, + "rating": rating + }, + function(response) + { + func(response.data.id); + } + ) + } + var api_key = "dc6zaTOxFJmzC"; // public beta key + var rating = "pg-13"; // PG 13 gifs + get_random_id(api_key, function(id) { + if (typeof id !== 'undefined') { + API.sendChat(subChat(basicBot.chat.validgifrandom, {name: chat.un, id: id})); + } else { + API.sendChat(subChat(basicBot.chat.invalidgifrandom, {name: chat.un})); + } + }); + } + } + } + }, + helpCommand: { command: 'help', rank: 'user', @@ -1766,12 +2296,32 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { - var link = "http://i.imgur.com/SBAso1N.jpg"; + var link = "(Updated link coming soon)"; API.sendChat(subChat(basicBot.chat.starterhelp, {link: link})); } } }, + historyskipCommand: { + command: 'historyskip', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.historySkip) { + basicBot.settings.historySkip = !basicBot.settings.historySkip; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.historyskip})); + } + else { + basicBot.settings.historySkip = !basicBot.settings.historySkip; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.historyskip})); + } + } + } + }, + joinCommand: { command: 'join', rank: 'user', @@ -1863,6 +2413,7 @@ if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { storeToStorage(); + sendToSocket(); API.sendChat(basicBot.chat.kill); basicBot.disconnectAPI(); setTimeout(function () { @@ -1872,6 +2423,34 @@ } }, + languageCommand: { + command: 'language', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length <= cmd.length + 1) return API.sendChat(subChat(basicBot.chat.currentlang, {language: basicBot.settings.language})); + var argument = msg.substring(cmd.length + 1); + + $.get("https://rawgit.com/Yemasthui/basicBot/master/lang/langIndex.json", function (json) { + var langIndex = json; + var link = langIndex[argument.toLowerCase()]; + if (typeof link === "undefined") { + API.sendChat(subChat(basicBot.chat.langerror, {link: "http://git.io/vJ9nI"})); + } + else { + basicBot.settings.language = argument; + loadChat(); + API.sendChat(subChat(basicBot.chat.langset, {language: basicBot.settings.language})); + } + }); + } + } + }, + leaveCommand: { command: 'leave', rank: 'user', @@ -1906,7 +2485,7 @@ if (dj === chat.uid) isDj = true; if (perm >= 1 || isDj) { if (media.format === 1) { - var linkToSong = "https://www.youtube.com/watch?v=" + media.cid; + var linkToSong = "http://youtu.be/" + media.cid; API.sendChat(subChat(basicBot.chat.songlink, {name: from, link: linkToSong})); } if (media.format === 2) { @@ -1960,7 +2539,7 @@ else { if (basicBot.settings.lockGuard) { basicBot.settings.lockGuard = !basicBot.settings.lockGuard; - return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockdown})); + return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.lockguard})); } else { basicBot.settings.lockGuard = !basicBot.settings.lockGuard; @@ -2039,8 +2618,8 @@ } }, - lockskipposCommand: { - command: 'lockskippos', + locktimerCommand: { + command: 'locktimer', rank: 'manager', type: 'startsWith', functionality: function (chat, cmd) { @@ -2048,31 +2627,28 @@ if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { var msg = chat.message; - var pos = msg.substring(cmd.length + 1); - if (!isNaN(pos)) { - basicBot.settings.lockskipPosition = pos; - return API.sendChat(subChat(basicBot.chat.lockskippos, {name: chat.un, position: basicBot.settings.lockskipPosition})); + var lockTime = msg.substring(cmd.length + 1); + if (!isNaN(lockTime) && lockTime !== "") { + basicBot.settings.maximumLocktime = lockTime; + return API.sendChat(subChat(basicBot.chat.lockguardtime, {name: chat.un, time: basicBot.settings.maximumLocktime})); } - else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un})); + else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); } } }, - locktimerCommand: { - command: 'locktimer', + logoutCommand: { + command: 'logout', rank: 'manager', - type: 'startsWith', + type: 'exact', functionality: function (chat, cmd) { if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { - var msg = chat.message; - var lockTime = msg.substring(cmd.length + 1); - if (!isNaN(lockTime) && lockTime !== "") { - basicBot.settings.maximumLocktime = lockTime; - return API.sendChat(subChat(basicBot.chat.lockguardtime, {name: chat.un, time: basicBot.settings.maximumLocktime})); - } - else return API.sendChat(subChat(basicBot.chat.invalidtime, {name: chat.un})); + API.sendChat(subChat(basicBot.chat.logout, {name: chat.un, botname: basicBot.settings.botName})); + setTimeout(function () { + $(".logout").mousedown() + }, 1000); } } }, @@ -2122,7 +2698,7 @@ moveCommand: { command: 'move', - rank: 'mod', + rank: 'manager', type: 'startsWith', functionality: function (chat, cmd) { if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); @@ -2217,6 +2793,13 @@ } else if (time > 30) { + API.moderateMuteUser(user.id, 1, API.MUTE.LONG); + API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); + setTimeout(function (id) { + API.moderateUnmuteUser(id); + }, time * 60 * 1000, user.id); + } + else if (time > 15) { API.moderateMuteUser(user.id, 1, API.MUTE.MEDIUM); API.sendChat(subChat(basicBot.chat.mutedtime, {name: chat.un, username: name, time: time})); setTimeout(function (id) { @@ -2271,6 +2854,7 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { + sendToSocket(); storeToStorage(); basicBot.disconnectAPI(); setTimeout(function () { @@ -2290,6 +2874,7 @@ if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { API.sendChat(basicBot.chat.reload); + sendToSocket(); storeToStorage(); basicBot.disconnectAPI(); kill(); @@ -2397,21 +2982,73 @@ } }, - skipCommand: { - command: 'skip', + /*skipCommand: { + command: ['skip', 'smartskip'], rank: 'bouncer', - type: 'exact', + type: 'startsWith', functionality: function (chat, cmd) { if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { - API.sendChat(subChat(basicBot.chat.skip, {name: chat.un})); - API.moderateForceSkip(); - basicBot.room.skippable = false; - setTimeout(function () { - basicBot.room.skippable = true - }, 5 * 1000); + if (basicBot.room.skippable) { + + var timeLeft = API.getTimeRemaining(); + var timeElapsed = API.getTimeElapsed(); + var dj = API.getDJ(); + var name = dj.username; + var msgSend = '@' + name + ', '; + + if (chat.message.length === cmd.length) { + API.sendChat(subChat(basicBot.chat.usedskip, {name: chat.un})); + if (basicBot.settings.smartSkip && timeLeft > timeElapsed){ + basicBot.roomUtilities.smartSkip(); + } + else { + API.moderateForceSkip(); + } + } + var validReason = false; + var msg = chat.message; + var reason = msg.substring(cmd.length + 1); + for (var i = 0; i < basicBot.settings.skipReasons.length; i++) { + var r = basicBot.settings.skipReasons[i][0]; + if (reason.indexOf(r) !== -1) { + validReason = true; + msgSend += basicBot.settings.skipReasons[i][1]; + } + } + if (validReason) { + API.sendChat(subChat(basicBot.chat.usedskip, {name: chat.un})); + if (basicBot.settings.smartSkip && timeLeft > timeElapsed){ + basicBot.roomUtilities.smartSkip(msgSend); + } + else { + API.moderateForceSkip(); + setTimeout(function () { + API.sendChat(msgSend); + }, 500); + } + } + } + } + } + },*/ + skipposCommand: { + command: 'skippos', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var pos = msg.substring(cmd.length + 1); + if (!isNaN(pos)) { + basicBot.settings.skipPosition = pos; + return API.sendChat(subChat(basicBot.chat.skippos, {name: chat.un, position: basicBot.settings.skipPosition})); + } + else return API.sendChat(subChat(basicBot.chat.invalidpositionspecified, {name: chat.un})); } } }, @@ -2444,7 +3081,7 @@ if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { - API.sendChat('/me This bot was made by ' + botCreator + '.'); + API.sendChat('/me This bot was created by ' + botCreator + ', but is now maintained by ' + botMaintainer + "."); } } }, @@ -2458,7 +3095,7 @@ if (!basicBot.commands.executable(this.rank, chat)) return void (0); else { var from = chat.un; - var msg = '/me [@' + from + '] '; + var msg = '[@' + from + '] '; msg += basicBot.chat.afkremoval + ': '; if (basicBot.settings.afkRemoval) msg += 'ON'; @@ -2472,6 +3109,11 @@ else msg += 'OFF'; msg += '. '; + msg += basicBot.chat.blacklist + ': '; + if (basicBot.settings.blacklistEnabled) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + msg += basicBot.chat.lockguard + ': '; if (basicBot.settings.lockGuard) msg += 'ON'; else msg += 'OFF'; @@ -2492,12 +3134,63 @@ else msg += 'OFF'; msg += '. '; + msg += basicBot.chat.historyskip + ': '; + if (basicBot.settings.historySkip) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.voteskip + ': '; + if (basicBot.settings.voteSkip) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.cmddeletion + ': '; + if (basicBot.settings.cmdDeletion) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + msg += basicBot.chat.autoskip + ': '; + if (basicBot.settings.autoskip) msg += 'ON'; + else msg += 'OFF'; + msg += '. '; + + // TODO: Display more toggleable bot settings. + var launchT = basicBot.room.roomstats.launchTime; var durationOnline = Date.now() - launchT; var since = basicBot.roomUtilities.msToStr(durationOnline); msg += subChat(basicBot.chat.activefor, {time: since}); - return API.sendChat(msg); + /* + // least efficient way to go about this, but it works :) + if (msg.length > 256){ + firstpart = msg.substr(0, 256); + secondpart = msg.substr(256); + API.sendChat(firstpart); + setTimeout(function () { + API.sendChat(secondpart); + }, 300); + } + else { + API.sendChat(msg); + } + */ + + // This is a more efficient solution + if (msg.length > 241){ + var split = msg.match(/.{1,241}/g); + for (var i = 0; i < split.length; i++) { + var func = function(index) { + setTimeout(function() { + API.sendChat("/me " + split[index]); + }, 500 * index); + } + func(i); + } + } + else { + return API.sendChat(msg); + } } } }, @@ -2575,6 +3268,24 @@ } }, + toggleblCommand: { + command: 'togglebl', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var temp = basicBot.settings.blacklistEnabled; + basicBot.settings.blacklistEnabled = !temp; + if (basicBot.settings.blacklistEnabled) { + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.blacklist})); + } + else return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.blacklist})); + } + } + }, + togglemotdCommand: { command: 'togglemotd', rank: 'bouncer', @@ -2595,6 +3306,26 @@ } }, + togglevoteskipCommand: { + command: 'togglevoteskip', + rank: 'bouncer', + type: 'exact', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + if (basicBot.settings.voteSkip) { + basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.voteskip})); + } + else { + basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.voteskip})); + } + } + } + }, + unbanCommand: { command: 'unban', rank: 'bouncer', @@ -2761,6 +3492,29 @@ } }, + voteskipCommand: { + command: 'voteskip', + rank: 'manager', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + if (msg.length <= cmd.length + 1) return API.sendChat(subChat(basicBot.chat.voteskiplimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit})); + var argument = msg.substring(cmd.length + 1); + if (!basicBot.settings.voteSkip) basicBot.settings.voteSkip = !basicBot.settings.voteSkip; + if (isNaN(argument)) { + API.sendChat(subChat(basicBot.chat.voteskipinvalidlimit, {name: chat.un})); + } + else { + basicBot.settings.voteSkipLimit = argument; + API.sendChat(subChat(basicBot.chat.voteskipsetlimit, {name: chat.un, limit: basicBot.settings.voteSkipLimit})); + } + } + } + }, + welcomeCommand: { command: 'welcome', rank: 'mod', @@ -2775,7 +3529,7 @@ } else { basicBot.settings.welcome = !basicBot.settings.welcome; - return API.sendChat(subChat(basicBot.chat.toggleoff, {name: chat.un, 'function': basicBot.chat.welcomemsg})); + return API.sendChat(subChat(basicBot.chat.toggleon, {name: chat.un, 'function': basicBot.chat.welcomemsg})); } } } @@ -2795,6 +3549,83 @@ } }, + whoisCommand: { + command: 'whois', + rank: 'bouncer', + type: 'startsWith', + functionality: function (chat, cmd) { + if (this.type === 'exact' && chat.message.length !== cmd.length) return void (0); + if (!basicBot.commands.executable(this.rank, chat)) return void (0); + else { + var msg = chat.message; + var name; + if (msg.length === cmd.length) name = chat.un; + else { + name = msg.substr(cmd.length + 2); + } + users = API.getUsers(); + var len = users.length; + for (var i = 0; i < len; ++i){ + if (users[i].username == name){ + var id = users[i].id; + var avatar = API.getUser(id).avatarID; + var level = API.getUser(id).level; + var rawjoined = API.getUser(id).joined; + var joined = rawjoined.substr(0, 10); + var rawlang = API.getUser(id).language; + if (rawlang == "en"){ + var language = "English"; + } else if (rawlang == "bg"){ + var language = "Bulgarian"; + } else if (rawlang == "cs"){ + var language = "Czech"; + } else if (rawlang == "fi"){ + var language = "Finnish" + } else if (rawlang == "fr"){ + var language = "French" + } else if (rawlang == "pt"){ + var language = "Portuguese" + } else if (rawlang == "zh"){ + var language = "Chinese" + } else if (rawlang == "sk"){ + var language = "Slovak" + } else if (rawlang == "nl"){ + var language = "Dutch" + } else if (rawlang == "ms"){ + var language = "Malay" + } + var rawrank = API.getUser(id).role; + if (rawrank == "0"){ + var rank = "User"; + } else if (rawrank == "1"){ + var rank = "Resident DJ"; + } else if (rawrank == "2"){ + var rank = "Bouncer"; + } else if (rawrank == "3"){ + var rank = "Manager" + } else if (rawrank == "4"){ + var rank = "Co-Host" + } else if (rawrank == "5"){ + var rank = "Host" + } else if (rawrank == "7"){ + var rank = "Brand Ambassador" + } else if (rawrank == "10"){ + var rank = "Admin" + } + var slug = API.getUser(id).slug; + if (typeof slug !== 'undefined') { + var profile = "https://plug.dj/@/" + slug; + } else { + var profile = "~"; + } + + API.sendChat(subChat(basicBot.chat.whois, {name1: chat.un, name2: name, id: id, avatar: avatar, profile: profile, language: language, level: level, joined: joined, rank: rank})); + } + } + } + } + }, + youtubeCommand: { command: 'youtube', rank: 'user', @@ -2812,4 +3643,4 @@ }; loadChat(basicBot.startup); -}).call(this); \ No newline at end of file +}).call(this);