Skip to content

Commit

Permalink
Merge pull request #44 from southbridgeio/update_tg_methods
Browse files Browse the repository at this point in the history
#1013902 upgrade telegram usage for new tg version
  • Loading branch information
nevrfl authored Sep 2, 2024
2 parents 2aba2a7 + ec15da9 commit feac017
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4.1

* Adapt tdlib commands for new version

# 0.4.0

* Fix USER_NOT_PARTICIPANT error
Expand Down
11 changes: 10 additions & 1 deletion lib/redmine2chat/platforms/telegram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ def create_chat(title)
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_promote_members: 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
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/redmine2chat/telegram/tdlib/kick_locked_users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def call
.to_a

promises = IssueChat.active.where(platform_name: 'telegram').where.not(im_id: nil).map do |group|
client.get_chat(group.im_id).then do |chat|
client.get_basic_group_full_info(chat.type.basic_group_id)
client.get_chat(chat_id: group.im_id).then do |chat|
client.get_basic_group_full_info(basic_group_id: chat.type.basic_group_id)
end.flat.rescue { nil }.then do |group_info|
next Promises.fulfilled_future(true) if group_info.blank?

Expand All @@ -28,7 +28,7 @@ def call
private

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

0 comments on commit feac017

Please sign in to comment.