Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Beniamiiin committed Sep 28, 2023
1 parent fda42b2 commit 49b190b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ jobs:
key: "api.admin"
value: ${{ vars.API_ADMIN }}

- name: Update api.seeders_channel_id in config file
- name: Update api.seeders_chat_id in config file
uses: ciiiii/toml-editor@1.0.0
with:
file: "ultimate_pollbot.toml"
key: "api.seeders_channel_id"
value: ${{ vars.SEEDERS_CHANNEL_ID }}
key: "api.seeders_chat_id"
value: ${{ vars.SEEDERS_CHAT_ID }}

- name: Update database.sql_uri in config file
uses: ciiiii/toml-editor@1.0.0
Expand Down
12 changes: 6 additions & 6 deletions resources/poll_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ def post(self):
session=session,
)

reference = Reference(poll, ReferenceType.api.name, user=user, chat_id=api_config['seeders_channel_id'])
reference = Reference(poll, ReferenceType.api.name, user=user, chat_id=api_config['seeders_chat_id'])
session.add(reference)
session.commit()

poll_message_id, discussion_message_id = self.send_message_to_channel(seeders_channel_id=api_config['seeders_channel_id'], reference=reference, session=session)
poll_message_id, discussion_message_id = self.send_message_to_channel(seeders_chat_id=api_config['seeders_chat_id'], reference=reference, session=session)
except:
traceback.print_exc()

Expand Down Expand Up @@ -97,15 +97,15 @@ def create_poll(self, user: User, poll_name: str, poll_description: Optional[str

return poll

def send_message_to_channel(self, seeders_channel_id: int, reference: Reference, session: Session) -> tuple[int, int]:
def send_message_to_channel(self, seeders_chat_id: int, reference: Reference, session: Session) -> tuple[int, int]:
poll = reference.poll
text, keyboard = get_poll_text_and_vote_keyboard(session, poll, user=poll.user)

bot = telegram.Bot(token=config['telegram']['api_key'])

poll_message = bot.send_message(
text=text,
chat_id=seeders_channel_id,
chat_id=seeders_chat_id,
reply_markup=keyboard,
parse_mode='markdown',
disable_web_page_preview=True,
Expand All @@ -117,7 +117,7 @@ def send_message_to_channel(self, seeders_channel_id: int, reference: Reference,
text = f'Тред с обсуждением этого [предложения]({poll_message_url})'
discussion_message = bot.send_message(
text=text,
chat_id=seeders_channel_id,
chat_id=seeders_chat_id,
parse_mode='markdown',
disable_web_page_preview=True,
disable_notification=True,
Expand All @@ -136,7 +136,7 @@ def send_message_to_channel(self, seeders_channel_id: int, reference: Reference,
text, keyboard = get_poll_text_and_vote_keyboard(session, poll, user=poll.user)
bot.edit_message_text(
text=text,
chat_id=seeders_channel_id,
chat_id=seeders_chat_id,
message_id=poll_message.message_id,
reply_markup=keyboard,
parse_mode='markdown',
Expand Down
2 changes: 1 addition & 1 deletion resources/vote_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get(self):
case PollOption.No:
vote_json['option'] = 'no'
case PollOption.Acknowledge:
vote_json['option'] = 'acknowledge'
vote_json['option'] = 'acknowledged'

votes.append(vote_json)

Expand Down
2 changes: 1 addition & 1 deletion ultimate_pollbot_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ max_inline_shares = 20

[api]
admin = "admin"
seeders_channel_id = 0
seeders_chat_id = 0

[database]
sql_uri = "postgres://localhost/pollbot"
Expand Down

0 comments on commit 49b190b

Please sign in to comment.