Skip to content

Commit

Permalink
Added option to post replies anyways
Browse files Browse the repository at this point in the history
Also reformatting because I forgot
  • Loading branch information
hatkidchan committed Jun 8, 2024
1 parent 2ddb263 commit 6249988
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 4 deletions.
4 changes: 4 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ user = auto
# address bar while you have that list open)
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?
# That option exists because it's not really a big deal when crossposter runs
# as a service and restarts automatically by the service manager.
Expand Down
1 change: 1 addition & 0 deletions mastoposter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from asyncio import gather
from configparser import ConfigParser
from logging import getLogger
Expand Down
8 changes: 7 additions & 1 deletion mastoposter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async def listen(
source: Callable[..., AsyncGenerator[Status, None]],
drains: List[FilteredIntegration],
user: str,
replies_to_other_accounts_should_not_be_skipped: bool = False,
/,
**kwargs,
):
Expand Down Expand Up @@ -93,7 +94,7 @@ async def listen(
if (
status.in_reply_to_account_id is not None
and status.in_reply_to_account_id != user
):
) and not replies_to_other_accounts_should_not_be_skipped:
logger.info(
"Skipping post %s because it's a reply to another person",
status.uri,
Expand Down Expand Up @@ -147,6 +148,11 @@ def main():
modules,
user_id,
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_delay=conf["main"].getfloat("reconnect_delay", 1.0),
list=conf["main"]["list"],
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from logging import getLogger
from typing import List

Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from abc import ABC, abstractmethod
from configparser import ConfigParser, SectionProxy
from typing import ClassVar, Dict, NamedTuple, Type
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from fnmatch import fnmatch
from typing import List
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import ConfigParser, SectionProxy
from typing import Callable, ClassVar, Dict, List, Sequence
from mastoposter.filters.base import BaseFilter, FilterInstance
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/media.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from typing import Literal, Set
from mastoposter.filters.base import BaseFilter
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/mention.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from re import Pattern, compile as regexp
from typing import ClassVar, Set
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/spoiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from re import Pattern, compile as regexp
from mastoposter.filters.base import BaseFilter
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from re import Pattern, compile as regexp
from typing import Optional, Set
Expand Down
1 change: 1 addition & 0 deletions mastoposter/filters/visibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from typing import Set
from mastoposter.filters.base import BaseFilter
Expand Down
1 change: 1 addition & 0 deletions mastoposter/integrations/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from typing import List, NamedTuple
from mastoposter.filters.base import FilterInstance

Expand Down
1 change: 1 addition & 0 deletions mastoposter/integrations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from abc import ABC, abstractmethod
from configparser import SectionProxy
from typing import Optional
Expand Down
9 changes: 6 additions & 3 deletions mastoposter/integrations/discord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from logging import getLogger
from typing import List, Optional
Expand Down Expand Up @@ -51,9 +52,11 @@ async def execute_webhook(
"content": content,
"username": username,
"avatar_url": avatar_url,
"embeds": [embed.asdict() for embed in embeds]
if embeds is not None
else [],
"embeds": (
[embed.asdict() for embed in embeds]
if embeds is not None
else []
),
}

logger.debug("Executing webhook with %r", json)
Expand Down
1 change: 1 addition & 0 deletions mastoposter/integrations/discord/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from dataclasses import asdict, dataclass
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional
Expand Down
1 change: 1 addition & 0 deletions mastoposter/integrations/telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import SectionProxy
from dataclasses import dataclass
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions mastoposter/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from asyncio import exceptions, sleep
from json import loads
from logging import getLogger
Expand Down
1 change: 1 addition & 0 deletions mastoposter/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from typing import Callable, Iterable, Literal, Optional
from bs4.element import Tag, PageElement

Expand Down
1 change: 1 addition & 0 deletions mastoposter/text/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from bs4 import NavigableString
from mastoposter.text import (
nodes_process,
Expand Down
1 change: 1 addition & 0 deletions mastoposter/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from dataclasses import dataclass, field, fields
from datetime import datetime
from typing import Any, Callable, Optional, List, Literal, TypeVar
Expand Down
1 change: 1 addition & 0 deletions mastoposter/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
"""

from configparser import ConfigParser
from logging import getLogger

Expand Down

0 comments on commit 6249988

Please sign in to comment.