Skip to content

Commit

Permalink
chore: added a mattermost_comunication.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tyboro2002 committed Dec 24, 2024
1 parent fc2593b commit a583cdc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def run_scrapers(
# Default values
default_run_everything: bool = False
default_use_parallelism: bool = False
default_restaurant_names = ["bocca_ovp"]
default_restaurant_names = ["s5"]

# Parse command-line arguments
args = parse_arguments()
Expand Down
17 changes: 8 additions & 9 deletions mattermost_comunication.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def send_message(file_info, message):
)
except mattermostdriver.exceptions.InvalidOrMissingParameters as e:
# This will occur when we try to react to a file in a channel that is not the same as the originating channel.
unique_post_url = f"{config['mattermost']['server_url']}/pl/{post_id}"
channel.create_post(
f"{unique_post_url}\n\n{message}",
f"{message}",
)


Expand All @@ -51,10 +50,10 @@ def report_newly_found_but_invalid_file(file_info):
send_message(file_info, message)


send_message(
{
"originating_mm_post_channel_id": "dm1abp4wfidezmig1yqyu53mmy",
"originating_mm_post_id": "dm1abp4wfidezmig1yqyu53mmy"
},
"this is a test message"
)
# send_message(
# {
# "originating_mm_post_channel_id": "dm1abp4wfidezmig1yqyu53mmy",
# "originating_mm_post_id": "dm1abp4wfidezmig1yqyu53mmy"
# },
# "haldis_sync is started"
# )
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ pdfplumber==0.11.4
requests==2.32.3
selenium==4.27.1
seleniumbase==4.33.11
mattermostdriver
mattermostdriver
colored
19 changes: 19 additions & 0 deletions sync_gitmate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import tomllib
from pprint import pprint

from mattermost_comunication import send_message

# import mattermost_communication

with open("config.toml", mode="rb") as config_toml:
Expand All @@ -23,6 +25,11 @@
GIT_ORG = config["gitea"]["remote_org"]
GIT_REPO = config["gitea"]["remote_repo"]

conf = {
"originating_mm_post_channel_id": "dm1abp4wfidezmig1yqyu53mmy",
"originating_mm_post_id": "dm1abp4wfidezmig1yqyu53mmy"
}


def init_sync():
repo = get_repo()
Expand Down Expand Up @@ -152,6 +159,10 @@ def sync_file(repo, api_instance, file_info):
print(
" Creating a new merge request to update the git menu with the new version from the hlds menu."
)
send_message(
conf,
f"[hlds sync] Creating a new merge request to update the git menu of {sync_to} with the new version from the hlds menu."
)
api_instance.repo_create_pull_request(
GIT_ORG,
GIT_REPO,
Expand All @@ -163,6 +174,10 @@ def sync_file(repo, api_instance, file_info):
)
else:
print(" Creating a new merge request to add the Menu to git.")
send_message(
conf,
f"[hlds sync] Creating a new merge request to add the git menu of {sync_to} with the new version from the hlds menu."
)
api_instance.repo_create_pull_request(
GIT_ORG,
GIT_REPO,
Expand All @@ -174,5 +189,9 @@ def sync_file(repo, api_instance, file_info):
)
else:
print(" Merge request was already open.")
send_message(
conf,
f"[hlds sync] Merge request was already open for git menu of {sync_to}"
)
else:
print(" Menu has no changes.")

0 comments on commit a583cdc

Please sign in to comment.