-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from MarioRuiz/v1.11.0
V1.11.0
- Loading branch information
Showing
78 changed files
with
945 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class SlackSmartBot | ||
def delete(channel, ts) | ||
result = true | ||
begin | ||
resp = client.web_client.chat_delete(channel: channel, as_user: true, ts: ts) | ||
result = resp.ok.to_s == 'true' | ||
rescue Exception => exc | ||
result = false | ||
@logger.fatal exc.inspect | ||
end | ||
return result | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class SlackSmartBot | ||
def add_admin(user, admin_user) | ||
save_stats(__method__) | ||
if Thread.current[:dest][0]=='D' | ||
respond "This command cannot be called from a DM" | ||
else | ||
if Thread.current[:typem] == :on_call | ||
channel = Thread.current[:dchannel] | ||
elsif Thread.current[:using_channel].to_s=='' | ||
channel = Thread.current[:dest] | ||
else | ||
channel = Thread.current[:using_channel] | ||
end | ||
messages = [] | ||
admins = config.masters.dup | ||
channels = get_channels() | ||
channel_found = channels.detect { |c| c.id == channel } | ||
if !channel_found.nil? and channel_found.creator.to_s != '' | ||
creator_info = @users.select{|u| u.id == channel_found.creator or (u.key?(:enterprise_user) and u.enterprise_user.id == channel_found.creator)}[-1] | ||
admins << creator_info.name | ||
end | ||
if Thread.current[:typem] == :on_bot or Thread.current[:typem] == :on_master | ||
admins << config.admins.dup | ||
end | ||
if @admins_channels.key?(channel) and @admins_channels[channel].size > 0 | ||
admins << @admins_channels[channel] | ||
end | ||
admins.flatten! | ||
admins.uniq! | ||
admins.delete(nil) | ||
if admins.include?(user.name) | ||
admin_info = @users.select{|u| u.id == admin_user or (u.key?(:enterprise_user) and u.enterprise_user.id == admin_user)}[-1] | ||
if admins.include?(admin_info.name) | ||
messages << "This user is already an admin of this channel." | ||
else | ||
@admins_channels[channel] ||= [] | ||
@admins_channels[channel] << admin_info.name | ||
update_admins_channels() | ||
messages << "The user is an admin of this channel from now on." | ||
admins << admin_info.name | ||
end | ||
messages << "*Admins*: <@#{admins.join('>, <@')}>" | ||
else | ||
messages << "Only the creator of the channel, Master admins or admins can add a new admin for this channel." | ||
messages << "*Admins*: <@#{admins.join('>, <@')}>" | ||
end | ||
|
||
respond messages.join("\n") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class SlackSmartBot | ||
def remove_admin(user, admin_user) | ||
save_stats(__method__) | ||
if Thread.current[:dest][0]=='D' | ||
respond "This command cannot be called from a DM" | ||
else | ||
|
||
if Thread.current[:typem] == :on_call | ||
channel = Thread.current[:dchannel] | ||
elsif Thread.current[:using_channel].to_s=='' | ||
channel = Thread.current[:dest] | ||
else | ||
channel = Thread.current[:using_channel] | ||
end | ||
messages = [] | ||
admins = config.masters.dup | ||
channels = get_channels() | ||
channel_found = channels.detect { |c| c.id == channel } | ||
if !channel_found.nil? and channel_found.creator.to_s != '' | ||
creator_info = @users.select{|u| u.id == channel_found.creator or (u.key?(:enterprise_user) and u.enterprise_user.id == channel_found.creator)}[-1] | ||
admins << creator_info.name | ||
end | ||
if Thread.current[:typem] == :on_bot or Thread.current[:typem] == :on_master | ||
admins << config.admins.dup | ||
end | ||
if @admins_channels.key?(channel) and @admins_channels[channel].size > 0 | ||
admins << @admins_channels[channel] | ||
end | ||
admins.flatten! | ||
admins.uniq! | ||
admins.delete(nil) | ||
if admins.include?(user.name) | ||
admin_info = @users.select{|u| u.id == admin_user or (u.key?(:enterprise_user) and u.enterprise_user.id == admin_user)}[-1] | ||
if creator_info.name == admin_info.name | ||
messages << "This user created the channel and cannot be removed as an admin." | ||
elsif config.masters.include?(admin_info.name) or config.masters.include?(admin_user) | ||
messages << "Master admins cannot be removed as admins of this channel." | ||
elsif config.admins.include?(admin_info.name) or config.admins.include?(admin_user) | ||
messages << "This user is a defaulted admin for this channel and cannot be removed using this command." | ||
elsif !admins.include?(admin_info.name) | ||
messages << "This user is not an admin of this channel." | ||
else | ||
@admins_channels[channel] ||= [] | ||
@admins_channels[channel].delete(admin_info.name) | ||
update_admins_channels() | ||
messages << "The user is not an admin of this channel from now on." | ||
admins.delete(admin_info.name) | ||
end | ||
messages << "*Admins*: <@#{admins.join('>, <@')}>" | ||
else | ||
messages << "Only the creator of the channel, Master admins or admins can remove an admin of this channel." | ||
messages << "*Admins*: <@#{admins.join('>, <@')}>" | ||
end | ||
|
||
respond messages.join("\n") | ||
end | ||
end | ||
end |
Oops, something went wrong.