feat: complete Ancestor quote bot with production-ready Docker support

This commit is contained in:
unfunny
2026-09-13 14:14:38 -04:00
parent f2016da05a
commit fe7351a7dc
1145 changed files with 30890 additions and 97684 deletions

View File

@@ -1,31 +1,36 @@
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
/*
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import { isEventTypeSame, M_TEXT, REFERENCE_RELATION } from "../@types/extensible_events.js";
import { M_POLL_END } from "../@types/polls.js";
import { ExtensibleEvent } from "./ExtensibleEvent.js";
import { InvalidEventError } from "./InvalidEventError.js";
import { MessageEvent } from "./MessageEvent.js";
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PollEndEvent = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _extensible_events = require("../@types/extensible_events");
var _polls = require("../@types/polls");
var _ExtensibleEvent = require("./ExtensibleEvent");
var _InvalidEventError = require("./InvalidEventError");
var _MessageEvent = require("./MessageEvent");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } /*
Copyright 2022 - 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* Represents a poll end/closure event.
*/
export class PollEndEvent extends ExtensibleEvent {
class PollEndEvent extends _ExtensibleEvent.ExtensibleEvent {
/**
* Creates a new PollEndEvent from a pure format. Note that the event is *not*
* parsed here: it will be treated as a literal m.poll.response primary typed event.
@@ -36,30 +41,30 @@ export class PollEndEvent extends ExtensibleEvent {
/**
* The poll start event ID referenced by the response.
*/
_defineProperty(this, "pollEventId", void 0);
(0, _defineProperty2.default)(this, "pollEventId", void 0);
/**
* The closing message for the event.
*/
_defineProperty(this, "closingMessage", void 0);
(0, _defineProperty2.default)(this, "closingMessage", void 0);
const rel = this.wireContent["m.relates_to"];
if (!REFERENCE_RELATION.matches(rel?.rel_type) || typeof rel?.event_id !== "string") {
throw new InvalidEventError("Relationship must be a reference to an event");
if (!_extensible_events.REFERENCE_RELATION.matches(rel === null || rel === void 0 ? void 0 : rel.rel_type) || typeof (rel === null || rel === void 0 ? void 0 : rel.event_id) !== "string") {
throw new _InvalidEventError.InvalidEventError("Relationship must be a reference to an event");
}
this.pollEventId = rel.event_id;
this.closingMessage = new MessageEvent(this.wireFormat);
this.closingMessage = new _MessageEvent.MessageEvent(this.wireFormat);
}
isEquivalentTo(primaryEventType) {
return isEventTypeSame(primaryEventType, M_POLL_END);
return (0, _extensible_events.isEventTypeSame)(primaryEventType, _polls.M_POLL_END);
}
serialize() {
return {
type: M_POLL_END.name,
type: _polls.M_POLL_END.name,
content: _objectSpread({
"m.relates_to": {
rel_type: REFERENCE_RELATION.name,
rel_type: _extensible_events.REFERENCE_RELATION.name,
event_id: this.pollEventId
},
[M_POLL_END.name]: {}
[_polls.M_POLL_END.name]: {}
}, this.closingMessage.serialize().content)
};
}
@@ -72,16 +77,17 @@ export class PollEndEvent extends ExtensibleEvent {
*/
static from(pollEventId, message) {
return new PollEndEvent({
type: M_POLL_END.name,
type: _polls.M_POLL_END.name,
content: {
"m.relates_to": {
rel_type: REFERENCE_RELATION.name,
rel_type: _extensible_events.REFERENCE_RELATION.name,
event_id: pollEventId
},
[M_POLL_END.name]: {},
[M_TEXT.name]: message
[_polls.M_POLL_END.name]: {},
[_extensible_events.M_TEXT.name]: message
}
});
}
}
exports.PollEndEvent = PollEndEvent;
//# sourceMappingURL=PollEndEvent.js.map