34 lines
789 B
Python
34 lines
789 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
_runtime_store: dict[str, Any] | None = None
|
||
|
|
|
||
|
|
|
||
|
|
def set_irc_runtime(store: dict[str, Any]) -> None:
|
||
|
|
global _runtime_store
|
||
|
|
_runtime_store = store
|
||
|
|
|
||
|
|
|
||
|
|
def get_irc_runtime() -> dict[str, Any] | None:
|
||
|
|
return _runtime_store
|
||
|
|
|
||
|
|
|
||
|
|
def clear_irc_runtime() -> None:
|
||
|
|
global _runtime_store
|
||
|
|
_runtime_store = None
|
||
|
|
|
||
|
|
|
||
|
|
def record_irc_outbound_activity(target: str, text: str, metadata: dict[str, Any] | None = None) -> None:
|
||
|
|
store = _runtime_store
|
||
|
|
if store is None:
|
||
|
|
return
|
||
|
|
entries: list[dict[str, Any]] = store.setdefault("outbound_activity", [])
|
||
|
|
entry: dict[str, Any] = {
|
||
|
|
"target": target,
|
||
|
|
"text": text,
|
||
|
|
}
|
||
|
|
if metadata:
|
||
|
|
entry["metadata"] = metadata
|
||
|
|
entries.append(entry)
|