forked from hkc/mastoposter
Compare commits
No commits in common. "37c1052b390e63750b37c753b7e357d214366a75" and "3e82b5c979cfc46a69e83b9cfa96febab53803c3" have entirely different histories.
37c1052b39
...
3e82b5c979
|
@ -32,20 +32,12 @@ user = auto
|
||||||
# address bar while you have that list open)
|
# address bar while you have that list open)
|
||||||
list = 1
|
list = 1
|
||||||
|
|
||||||
# Allow replies to be boosted as well
|
|
||||||
# By default replies will be ignores unless it's a reply to your post
|
|
||||||
# replies_to_other_accounts_should_not_be_skipped = yes
|
|
||||||
|
|
||||||
# Should we automatically reconnect to the streaming socket?
|
# Should we automatically reconnect to the streaming socket?
|
||||||
# That option exists because it's not really a big deal when crossposter runs
|
# That option exists because it's not really a big deal when crossposter runs
|
||||||
# as a service and restarts automatically by the service manager.
|
# as a service and restarts automatically by the service manager.
|
||||||
auto-reconnect = yes
|
auto-reconnect = yes
|
||||||
reconnect-delay = 1.0
|
reconnect-delay = 1.0
|
||||||
|
|
||||||
# Change websocket connection opening timeout.
|
|
||||||
# It may be useful when initial server connection may take a long time.
|
|
||||||
connect-timeout = 60.0
|
|
||||||
|
|
||||||
# Number of retries in case request fails. Applies globally
|
# Number of retries in case request fails. Applies globally
|
||||||
# Can be changed on per-module basis
|
# Can be changed on per-module basis
|
||||||
http-retries = 5
|
http-retries = 5
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from asyncio import gather
|
from asyncio import gather
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
|
@ -64,7 +64,6 @@ async def listen(
|
||||||
source: Callable[..., AsyncGenerator[Status, None]],
|
source: Callable[..., AsyncGenerator[Status, None]],
|
||||||
drains: List[FilteredIntegration],
|
drains: List[FilteredIntegration],
|
||||||
user: str,
|
user: str,
|
||||||
replies_to_other_accounts_should_not_be_skipped: bool = False,
|
|
||||||
/,
|
/,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
|
@ -94,7 +93,7 @@ async def listen(
|
||||||
if (
|
if (
|
||||||
status.in_reply_to_account_id is not None
|
status.in_reply_to_account_id is not None
|
||||||
and status.in_reply_to_account_id != user
|
and status.in_reply_to_account_id != user
|
||||||
) and not replies_to_other_accounts_should_not_be_skipped:
|
):
|
||||||
logger.info(
|
logger.info(
|
||||||
"Skipping post %s because it's a reply to another person",
|
"Skipping post %s because it's a reply to another person",
|
||||||
status.uri,
|
status.uri,
|
||||||
|
@ -148,14 +147,8 @@ def main():
|
||||||
modules,
|
modules,
|
||||||
user_id,
|
user_id,
|
||||||
url=url,
|
url=url,
|
||||||
replies_to_other_accounts_should_not_be_skipped=conf[
|
|
||||||
"main"
|
|
||||||
].getboolean(
|
|
||||||
"replies_to_other_accounts_should_not_be_skipped", False
|
|
||||||
),
|
|
||||||
reconnect=conf["main"].getboolean("auto_reconnect", False),
|
reconnect=conf["main"].getboolean("auto_reconnect", False),
|
||||||
reconnect_delay=conf["main"].getfloat("reconnect_delay", 1.0),
|
reconnect_delay=conf["main"].getfloat("reconnect_delay", 1.0),
|
||||||
connect_timeout=conf["main"].getfloat("connect_timeout", 60.0),
|
|
||||||
list=conf["main"]["list"],
|
list=conf["main"]["list"],
|
||||||
access_token=conf["main"]["token"],
|
access_token=conf["main"]["token"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from configparser import ConfigParser, SectionProxy
|
from configparser import ConfigParser, SectionProxy
|
||||||
from typing import ClassVar, Dict, NamedTuple, Type
|
from typing import ClassVar, Dict, NamedTuple, Type
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import ConfigParser, SectionProxy
|
from configparser import ConfigParser, SectionProxy
|
||||||
from typing import Callable, ClassVar, Dict, List, Sequence
|
from typing import Callable, ClassVar, Dict, List, Sequence
|
||||||
from mastoposter.filters.base import BaseFilter, FilterInstance
|
from mastoposter.filters.base import BaseFilter, FilterInstance
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from typing import Literal, Set
|
from typing import Literal, Set
|
||||||
from mastoposter.filters.base import BaseFilter
|
from mastoposter.filters.base import BaseFilter
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from re import Pattern, compile as regexp
|
from re import Pattern, compile as regexp
|
||||||
from typing import ClassVar, Set
|
from typing import ClassVar, Set
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from re import Pattern, compile as regexp
|
from re import Pattern, compile as regexp
|
||||||
from mastoposter.filters.base import BaseFilter
|
from mastoposter.filters.base import BaseFilter
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from re import Pattern, compile as regexp
|
from re import Pattern, compile as regexp
|
||||||
from typing import Optional, Set
|
from typing import Optional, Set
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from typing import Set
|
from typing import Set
|
||||||
from mastoposter.filters.base import BaseFilter
|
from mastoposter.filters.base import BaseFilter
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import List, NamedTuple
|
from typing import List, NamedTuple
|
||||||
from mastoposter.filters.base import FilterInstance
|
from mastoposter.filters.base import FilterInstance
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
@ -52,11 +51,9 @@ class DiscordIntegration(BaseIntegration):
|
||||||
"content": content,
|
"content": content,
|
||||||
"username": username,
|
"username": username,
|
||||||
"avatar_url": avatar_url,
|
"avatar_url": avatar_url,
|
||||||
"embeds": (
|
"embeds": [embed.asdict() for embed in embeds]
|
||||||
[embed.asdict() for embed in embeds]
|
if embeds is not None
|
||||||
if embeds is not None
|
else [],
|
||||||
else []
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Executing webhook with %r", json)
|
logger.debug("Executing webhook with %r", json)
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import asdict, dataclass
|
from dataclasses import asdict, dataclass
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Callable, Dict, List, Optional
|
from typing import Any, Callable, Dict, List, Optional
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import SectionProxy
|
from configparser import SectionProxy
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from asyncio import exceptions, sleep
|
from asyncio import exceptions, sleep
|
||||||
from json import loads
|
from json import loads
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
@ -24,8 +23,7 @@ logger = getLogger("sources")
|
||||||
|
|
||||||
|
|
||||||
async def websocket_source(
|
async def websocket_source(
|
||||||
url: str, reconnect: bool = False, reconnect_delay: float = 1.0,
|
url: str, reconnect: bool = False, reconnect_delay: float = 1.0, **params
|
||||||
connect_timeout: float = 60.0, **params
|
|
||||||
) -> AsyncGenerator[Status, None]:
|
) -> AsyncGenerator[Status, None]:
|
||||||
from websockets.client import connect
|
from websockets.client import connect
|
||||||
from websockets.exceptions import WebSocketException
|
from websockets.exceptions import WebSocketException
|
||||||
|
@ -38,7 +36,7 @@ async def websocket_source(
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
logger.info("attempting to connect to %s", public_url)
|
logger.info("attempting to connect to %s", public_url)
|
||||||
async with connect(url, open_timeout=connect_timeout) as ws:
|
async with connect(url, open_timeout=60) as ws:
|
||||||
logger.info("Connected to WebSocket")
|
logger.info("Connected to WebSocket")
|
||||||
while (msg := await ws.recv()) is not None:
|
while (msg := await ws.recv()) is not None:
|
||||||
event = loads(msg)
|
event = loads(msg)
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from typing import Callable, Iterable, Literal, Optional
|
from typing import Callable, Iterable, Literal, Optional
|
||||||
from bs4.element import Tag, PageElement
|
from bs4.element import Tag, PageElement
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from bs4 import NavigableString
|
from bs4 import NavigableString
|
||||||
from mastoposter.text import (
|
from mastoposter.text import (
|
||||||
nodes_process,
|
nodes_process,
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from dataclasses import dataclass, field, fields
|
from dataclasses import dataclass, field, fields
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Any, Callable, Optional, List, Literal, TypeVar
|
from typing import Any, Callable, Optional, List, Literal, TypeVar
|
||||||
|
|
|
@ -12,7 +12,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue