Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -e
SERVER=$1
CLIENT=$2
SINCE="2021-04-01"
BEFORE="$(date "+%Y-%m-%d")"
TMP=$(mktemp)
trap "rm -f $TMP" 0 2 3 15
export const Items: {[itemid: string]: ItemData} = {
abomasite: {
name: "Abomasite",
spritenum: 575,
megaStone: "Abomasnow-Mega",
megaEvolves: "Abomasnow",
itemUser: ["Abomasnow"],
onTakeItem(item, source) {
if (item.megaEvolves === source.baseSpecies.baseSpecies) return false;
return true;
canPM(targetUser: User) {
// hotpatching
const user = this.user;
if (typeof user.settings.blockPMs !== 'object') {
user.settings.blockPMs = {all: user.settings.blockPMs};
}
if (typeof targetUser.settings.blockPMs !== 'object') {
targetUser.settings.blockPMs = {all: targetUser.settings.blockPMs};
}
const targetBlocked = targetUser.settings.blockPMs;
const FS = require('../../.lib-dist/fs').FS;
const HELP_PATH = 'logs/modlog/modlog_help.txt';
const TICKET_PATH = 'logs/modlog/modlog_help-rooms.txt';
let helpBuffer = [];
let ticketBuffer = [];
class dummyModlogStream {
constructor(ticket) {
this.ticket = ticket;
async renameroom(target, room, user, connection, cmd) {
if (!this.can('rangeban')) return false;
let startTime = Date.now();
let args = target.split(',');
let oldRoom = args[0];
oldRoom = Rooms.get(oldRoom);
if (!oldRoom) oldRoom = room;
let newRoom = args[1];
if (!oldRoom || !newRoom) return this.errorReply('Missing a needed arg - use /renameroom oldRoom, newRoom.');
user.send(`|pm|~|${user}|Starting rename of ${oldRoom} to ${newRoom}.`)
import {FS} from '../lib/fs';
const Groups = new Map<string | ID, Auth>();
export abstract class Auth extends Map<ID, GroupSymbol> {
save: () => void;
constructor() {
super();
this.save = () => null;
}
import {FS} from '../lib/fs';
import {Rooms} from './rooms';
let ChatRoomData: AnyObject[] = [];
try {
ChatRoomData = JSON.parse(FS('config/chatrooms.json').readSync());
} catch (e) {}
function loadAuth() {
for (const room of Rooms.rooms.values()) {

Making permissions customizable.

idea 1) create an object in the room object to hold command keys and perms Formatted: {commandkey: permission} in User#can, check if there's a room, then check the permission for the room, and then leverage user.authAtLeast. Issues with this approach: This will only work with commands passing a room to User#can, which actually helps with behavior, but will require a list of commands to work with it.

idea 2) Split all command-customizable room settings into different objects, eg room.info for RFAQs, events, etc,

PS TODO:
TODO SOON:
- room.chatRoomData refactor (needs PR / conflict resolution)
- reorder what functions are where in chatlog LogViewer and LogSearcher
- chat plugin review (?)
- youtube to use Net library
- question workshop stuff (/trivia edit, /trivia review [cat], /trivia search in QW subrooms)
- [17:32:27] cutsu: mia pi is it possible for you to add "inter" font to it (youtube) (not hard)
- ZarelToday at 2:51 AM: one thing I want to do soon is refactor getFullResponse into getStream (mostly done)
async getFullResponse(opts?: AnyObject, chunk?: string, timeout?: number): Promise<{
statusCode: number | undefined, statusMessage: string | undefined,
headers: http.IncomingHttpHeaders | undefined, stream: Streams.ReadStream,
} | null> {
if (Config.noURIRequests) return null;
return new Promise(resolve => {
const protocol = url.parse(this.uri).protocol as string;
const net = protocol.includes('https:') ? https : http;
const req = net.get(opts? opts : this.uri, response => {
response.setEncoding('utf-8');