forked from yagich/potomark-bot-rb
		
	Compare commits
	
		
			9 Commits
		
	
	
		
			24e13036ce
			...
			feature/pu
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 83f6a5db1a | |||
| ce02f1aeb5 | |||
| 122447095b | |||
| 0529dbac85 | |||
| e75ac68a57 | |||
| ba2f91d620 | |||
| 8829c57dd7 | |||
| 6a10c6beb7 | |||
| c66178451a | 
							
								
								
									
										35
									
								
								bot.rb
									
									
									
									
									
								
							
							
						
						
									
										35
									
								
								bot.rb
									
									
									
									
									
								
							| @@ -8,6 +8,8 @@ PIN_EMOJI = '📌' | |||||||
|  |  | ||||||
| TRIM_MESSAGE_LENGTH = 500 | TRIM_MESSAGE_LENGTH = 500 | ||||||
|  |  | ||||||
|  | $sentence = {} | ||||||
|  |  | ||||||
| bot.reaction_add do |event| | bot.reaction_add do |event| | ||||||
|   next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name |   next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name | ||||||
|  |  | ||||||
| @@ -21,6 +23,9 @@ bot.reaction_add do |event| | |||||||
|     message_author_fname = "#{message_author_nickname} (#{message_author_distinct})" # this is the 'author' field of the embed |     message_author_fname = "#{message_author_nickname} (#{message_author_distinct})" # this is the 'author' field of the embed | ||||||
|  |  | ||||||
|     trimmed_msg = "#{event.message.content[0..TRIM_MESSAGE_LENGTH]}#{'...' if event.message.content.length > TRIM_MESSAGE_LENGTH}" # trim the string to TRIM_MESSAGE_LENGTH chars max to not make the embed too huge |     trimmed_msg = "#{event.message.content[0..TRIM_MESSAGE_LENGTH]}#{'...' if event.message.content.length > TRIM_MESSAGE_LENGTH}" # trim the string to TRIM_MESSAGE_LENGTH chars max to not make the embed too huge | ||||||
|  |     if trimmed_msg.empty? | ||||||
|  |       trimmed_msg = "<empty>" | ||||||
|  |     end | ||||||
|     original_msg_link = event.message.link |     original_msg_link = event.message.link | ||||||
|  |  | ||||||
|     pm = event.user.pm |     pm = event.user.pm | ||||||
| @@ -30,6 +35,12 @@ bot.reaction_add do |event| | |||||||
|       embed.url = original_msg_link |       embed.url = original_msg_link | ||||||
|       embed.author = Discordrb::Webhooks::EmbedAuthor.new(icon_url: message_author_pfp, name: message_author_fname) |       embed.author = Discordrb::Webhooks::EmbedAuthor.new(icon_url: message_author_pfp, name: message_author_fname) | ||||||
|       embed << Discordrb::Webhooks::EmbedField.new(name: 'Message (trimmed)', value: trimmed_msg) |       embed << Discordrb::Webhooks::EmbedField.new(name: 'Message (trimmed)', value: trimmed_msg) | ||||||
|  |       if !event.message.attachments.empty? | ||||||
|  |         event.message.attachments.each_index do |idx| | ||||||
|  |           attachment = event.message.attachments[idx] | ||||||
|  |           embed << Discordrb::Webhooks::EmbedField.new(name: "Attachment \##{idx + 1}", value: attachment.url) | ||||||
|  |         end | ||||||
|  |       end | ||||||
|       embed.timestamp = event.message.timestamp |       embed.timestamp = event.message.timestamp | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| @@ -43,8 +54,30 @@ end | |||||||
|  |  | ||||||
| bot.reaction_remove do |event| | bot.reaction_remove do |event| | ||||||
|   next unless event.emoji.name == PIN_EMOJI |   next unless event.emoji.name == PIN_EMOJI | ||||||
|   event.message.unpin unless event.message.reactions.include? PIN_EMOJI |   pin_reactions = event.message.reactions.filter {|el| el.name == PIN_EMOJI} | ||||||
|  |   event.message.unpin if pin_reactions.empty? | ||||||
|   nil |   nil | ||||||
| end | end | ||||||
|  |  | ||||||
|  | bot.message(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| | ||||||
|  |   if ['?', '!', '.', '...'].include? event.message.content | ||||||
|  |     if $sentence.empty? | ||||||
|  |       next | ||||||
|  |     end | ||||||
|  |     event << "Congratulations, your sentence is: #{$sentence.values.join(" ")}${event.message.content}" | ||||||
|  |     $sentence.clear | ||||||
|  |     next | ||||||
|  |   end | ||||||
|  |  | ||||||
|  |   $sentence[event.message.id] = event.message.content | ||||||
|  | end | ||||||
|  |  | ||||||
|  | bot.message_delete(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| | ||||||
|  |   $sentence.delete(event.id) | ||||||
|  | end | ||||||
|  |  | ||||||
|  | bot.message_edit(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| | ||||||
|  |   $sentence[event.message.id] = event.message.content | ||||||
|  | end | ||||||
|  |  | ||||||
| bot.run | bot.run | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user