Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var https=require("https");
- var dat_em={
- host: "epicmafia.com",
- path: "/lobby",
- headers: {
- // you can find these set as cookies, just copy/paste
- "cookie": "never.give.away.this.key=[[KEY_HERE]];__cfduid=[[CFD_HERE]]"
- }
- };
- var dat_discord={
- method: "POST",
- host: "discordapp.com",
- // you'll need a new webhook if you want the discord announcements
- // i think if you just leave this alone it'll fail gracefully
- path: "/api/webhooks/???/???",
- headers: {
- "content-type": "application/json"
- }
- }
- var set_ft=[];
- const SETUPS=[
- { // standard 12p closed
- type: "/double_points",
- pool: [1378565, 1390329, 1407228, 1414719, 1415080, 1415276, 1419237]
- },
- { // standard 6p closed
- type: "/double_points",
- pool: [1415092, 1415456]
- },
- { // unique closed
- type: "/lobby_sticky",
- pool: [1376390, 1376423, 1378029, 1393178, 1413309, 1414936, 1415608, 1416161, 1418987]
- },
- { // unique open
- type: "/lobby_sticky",
- pool: [356450, 564946, 676322, 929891, 1351981, 1372345, 1376463, 1386893, 1391372, 1415574]
- }
- ];
- const BANNERS=[
- [ // funky friday
- "http://i.imgur.com/8lM5Vs3.png#chris"
- ],
- [ // weekly
- "http://i.imgur.com/xYj9Xzc.png#chris",
- "http://i.imgur.com/xPJoyMv.png#chris",
- "http://i.imgur.com/pXpcBGs.jpg#ckrox",
- "http://i.imgur.com/5NDtjZO.png#ben"
- ]
- ];
- const BIO_BODY="\n\nSandbox games are *not* moderated, but community guidelines still apply\nhttps://epicmafia.com/lobby/rules#siterulecategory_21\n\n";
- const BIO_TAG=[
- "Feeling chilly? \u26c4",
- "Have a wonderful day! \u2764",
- "Honesty is the best policy",
- "Lightkeeper is a mafia role",
- "Mods can't save you.",
- "Please don't feed the weebs",
- "Rise and shine! \u26c5",
- "Welcome to the jungle"
- ];
- const BIO_LINK=[
- "Check out the latest so-called updates\nhttps://epicmafia.com/topic/85248",
- "What's new?\nhttps://epicmafia.com/topic/85248",
- "Come spam with us!\nhttps://discord.gg/yFHM4yF",
- "Need someone to talk to?\nhttps://discord.gg/yFHM4yF",
- "Love cool setups? Post some here\nhttps://epicmafia.com/topic/85150",
- "Get your setup featured today!\nhttps://epicmafia.com/topic/85150",
- "Is graphic design your passion?\nhttps://epicmafia.com/topic/85149",
- "Submit your lobby banner today!\nhttps://epicmafia.com/topic/85149"
- ];
- const JABBER=[
- ":pushpin: Reminder to submit your setups here!\nhttps://epicmafia.com/topic/85150",
- ":pushpin: Try something different, why don't you?\nhttps://epicmafia.com/topic/85150",
- ":pushpin: We could really use some more early morning setups!\nhttps://epicmafia.com/topic/85150",
- ":frame_photo: Is graphic design your passion? It doesn't matter, I'm desperate for banners.\nhttps://epicmafia.com/topic/85149",
- ":frame_photo: Get your sloppy doodles featured today!\nhttps://epicmafia.com/topic/85149",
- ":frame_photo: Why are you holding out on me? Come on.\nhttps://epicmafia.com/topic/85149",
- ":grey_question: Do these messages suck? Too bad.",
- ":grey_question: Did you know Tatsumaki is gay?",
- ":grey_question: Remember, you can post community- and mafia-related suggestions in their respective forums!",
- ":grey_question: I'm running out of quirky messages, please donate!",
- ":grey_question: VIP and above can add emojis, in case you didn't know.",
- ":grey_question: These messages appear once every 6 hours, which means they'll annoy you on four different occasions every day!"
- ];
- https.get(dat_em, function(response) {
- var body="";
- response.on("data", function(data) {
- body+=data;
- });
- response.on("end", function() {
- set_ft=JSON.parse(
- body.match(/"double_setups":(\[.+?\])/)[1]
- ).concat(
- JSON.parse(
- body.match(/"stickied_setups":(\[.+?\])/)[1]
- )
- );
- for(var i=0; i<set_ft.length; i++) {
- set_ft[i]=set_ft[i].id;
- }
- console.log("Loaded featured: %s", set_ft.join(", "));
- rotate_setups(0, false);
- });
- });
- function random(list) {
- return list[Math.floor(Math.random()*list.length)];
- }
- function discord_chat(message) {
- https.request(dat_discord).end(
- JSON.stringify({
- content: message
- })
- );
- }
- function rotate_setups(i, done) {
- var setup=done ? random(SETUPS[i].pool) : set_ft[i];
- dat_em.method="PUT";
- dat_em.path="/setup/"+setup+SETUPS[i].type;
- https.get(dat_em, function(response) {
- response.destroy();
- console.log("%s: feature %s:%s (%s)", Date.now(), setup, done, response.statusCode);
- if(!done) {
- rotate_setups(i, true);
- }
- else {
- set_ft[i]=setup;
- if(++i < SETUPS.length) {
- rotate_setups(i, false);
- }
- }
- });
- }
- function init_jabber() {
- discord_chat(random(JABBER));
- }
- function init_rotate() {
- discord_chat(":recycle: Stickied setups have been rotated!");
- rotate_setups(0, false);
- }
- function init_newday(init) {
- var day=(new Date()).getDay();
- dat_em.method="PUT";
- dat_em.path="/lobby/5/announcement?announcement="+encodeURIComponent(
- random(BIO_TAG)+BIO_BODY+random(BIO_LINK)
- );
- https.get(dat_em);
- if(init) {
- discord_chat(":fox: Sandbot is online");
- }
- else if(day===5) {
- discord_chat(":pizza: Have a funky friday, nerds!");
- }
- else {
- discord_chat(":sunflower: Good morning!");
- }
- if(day===5 || day===6) {
- dat_em.method="PUT";
- dat_em.path="/lobby/5/banner?banner="+encodeURIComponent(
- random(BANNERS[day-5])
- );
- https.get(dat_em);
- }
- }
- init_newday(true);
- setTimeout(function() {
- init_newday();
- setInterval(init_jabber, 21600000);
- setInterval(init_rotate, 43200000);
- setInterval(init_newday, 86400000);
- }, Date.now() % 86400000);
Advertisement
Add Comment
Please, Sign In to add comment