Skip to content

Commit

Permalink
fix set admin permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
nevrfl committed Sep 5, 2024
1 parent feac017 commit ab8f521
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.4.2

* Fix set admin permissions
* Refactor commands

# 0.4.1

* Adapt tdlib commands for new version
Expand Down
29 changes: 12 additions & 17 deletions lib/redmine2chat/platforms/telegram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,18 @@ def create_chat(title)

if user_telegram_account&.username
RedmineBots::Telegram::Tdlib::AddToChat.(chat.id, user_telegram_account.username).then do
RedmineBots::Telegram.bot.async.promote_chat_member(chat_id: chat.id,
user_id: user_telegram_account.telegram_id.to_i,
can_manage_chat: true,
can_change_info: true,
can_post_messages: true,
can_edit_messages: true,
can_delete_messages: true,
can_invite_users: true,
can_restrict_members: true,
can_pin_messages: true,
can_manage_topics: true,
can_promote_members: true,
can_manage_video_chats: true,
can_post_stories: false,
can_edit_stories: false,
can_delete_stories: false,
is_anonymous: false
RedmineBots::Telegram.bot.promote_chat_member(chat_id: chat.id,
user_id: user_telegram_account.telegram_id.to_i,
can_manage_chat: true,
can_change_info: true,
can_delete_messages: true,
can_invite_users: true,
can_restrict_members: true,
can_pin_messages: true,
can_manage_topics: true,
can_promote_members: true,
can_manage_video_chats: true,
is_anonymous: false
)
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/redmine2chat/telegram/tdlib/kick_locked_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def call
private

def kick_member(chat_id, user_id)
client.set_chat_member_status(chat_id: chat_id, member_id: user_id, status: ChatMemberStatus::Left.new).rescue { nil }
client.set_chat_member_status(chat_id: chat_id, member_id: message_sender(user_id), status: ChatMemberStatus::Left.new).rescue { nil }
end

def message_sender(user_id)
TD::Types::MessageSender::User.new(user_id: user_id)
end
end
end

0 comments on commit ab8f521

Please sign in to comment.