Skip to content

Commit

Permalink
Merge pull request #103 from BluLightShow/develop
Browse files Browse the repository at this point in the history
Merge v0.1.5
  • Loading branch information
max-bromberg authored Jun 14, 2021
2 parents 1c3cf94 + 42c7542 commit e1d7063
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Arduino Bot
[![Issues Badge](https://img.shields.io/github/issues/BluLightShow/arduino-bot)](https://github.com/BluLightShow/arduino-bot/issues) [![Forks Badge](https://img.shields.io/github/forks/BluLightShow/arduino-bot)](https://github.com/BluLightShow/arduino-bot) [![Stars Badge](https://img.shields.io/github/stars/BluLightShow/arduino-bot)](https://github.com/BluLightShow/arduino-bot) [![License Badge](https://img.shields.io/github/license/BluLightShow/arduino-bot)](https://github.com/BluLightShow/arduino-bot/blob/master/LICENSE) [![Discord Badge](https://img.shields.io/discord/420594746990526466?color=%237289DA&label=%20Discord%20&logo=discord&logoColor=%23FFFFFF)](https://arduino.cc/discord)

Arduino Bot is a utility Discord bot built for use on the official [Arduino Discord Server](https://arduino.cc/discord "Arduino Discord Server"). This is an open source project involving the community to build a Discord bot that makes helping others easier.
Arduino Bot is a utility Discord bot built for use on the official [Arduino Discord Server](https://arduino.cc/discord "Arduino Discord Server"). This is an open source project involving the community to build a Discord bot that makes helping others easier. If you're an existing contributor or you're interested in getting involved, consider joining the [Arduino Contributors Discord Server](https://discord.gg/HwNsEctYYU).

# Contributing
If you're interested in contributing, please see [`contributing.md`](https://github.com/BluLightShow/arduino-bot/blob/main/CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MainClient extends AkairoClient {
presence: {
status: 'online',
activity: {
name: `!help | ${version}`,
name: `${config.prefix}help | ${version}`,
type: 'WATCHING'
}
}
Expand Down
4 changes: 2 additions & 2 deletions commands/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class AboutCommand extends Command {
about.addField('Akairo Version', 'v' + packLock.dependencies['discord-akairo'].version, true)
}
about.addField('Contributing', '[GitHub](https://github.com/BluLightShow/arduino-bot)', true)
var clientDuration = Duration.fromMillis(this.client.uptime)
about.addField('Uptime', `${clientDuration.minutes} minutes, ${clientDuration.hours} hours, ${clientDuration.days} days`)
var clientDuration = Duration.fromMillis(this.client.uptime).toFormat('d h m').split(' ')
about.addField('Uptime', `${clientDuration[0]} days, ${clientDuration[1]} hours, ${clientDuration[2]} minutes`)
message.channel.send(about)
}
}
Expand Down
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"guild": "420594746990526466",
"staffPrefix": "=",
"channels": {
"joinLeaveLog": "746375238845071451"
"joinLeaveLog": "746375238845071451",
"crosspostLog": "801316586371416074",
"moderationLog": "451381471740166144",
"toCrosspost": ["610239559376044043", "610239597317849248", "610253712824467473"],
"preventDuplicates": ["556594862502182914", "420594746990526468", "775732279938777088", "700051397344886875", "451155251580633089", "438792322340093953", "451155280177266688", "622118305930674192", "759262278050381834", "759262030506360852", "639856342449782798"]
},
"embeds": {
"footer":"Arduino Bot • Submit bugs on GitHub!",
Expand Down
50 changes: 44 additions & 6 deletions listeners/message.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Listener } = require('discord-akairo')
const { MessageEmbed } = require('discord.js')
const stringSimilarity = require('string-similarity')
const { embed } = require('../bot')
const config = require('../config.json')

Expand All @@ -12,18 +13,55 @@ class MessageListener extends Listener {
}

exec(message) {
if (message.author.bot) return
// Duplicates filter
for (var i = 0; i < config.channels.preventDuplicates.length; i++) {
var channelID = config.channels.preventDuplicates[i]
if (message.channel.id === channelID) continue
var channel = message.guild.channels.resolve(channelID)
var original = channel.messages.cache.find(msg => stringSimilarity.compareTwoStrings(msg.content, message.content) >= 0.9)

if (original) {
message.delete()

// DM offender
var dmMessage = new MessageEmbed(embed)
.setTitle("We've detected that you sent a duplicate message in multiple channels.")
.setDescription("This is against our rules, please refrain from crossposting duplicate messages in the future. If you believe this message was sent in error, please DM <@799678733723893821> with valid reasoning.")
.setTimestamp(new Date())
if (message.author.dmChannel) {
message.author.dmChannel.send(dmMessage)
} else {
message.author.createDM().then(dmChannel => {
dmChannel.send(dmMessage)
})
}

// Post to mod log
message.guild.channels.resolve(config.channels.moderationLog).send(
new MessageEmbed(embed)
.setTitle("Duplicate Crosspost Detected")
.addField("Offender", message.author.tag, true)
.addField("Channel", message.channel.toString())
.addField("Similarity", `${Math.floor(stringSimilarity.compareTwoStrings(original.content, message.content) * 10000) / 100}%`, true)
.setTimestamp(new Date())
)
break
}
}

// File filter
if (message.attachments.find(attachment => {
const allowedExtensions = ['png', 'jpg', 'gif', 'webp', 'tiff', 'heif', 'jpeg', 'svg', 'webm', 'mpg', 'mpeg', 'ogg', 'mp4', 'm4v', 'avi', 'mov', 'm4a', 'mp3', 'wav', 'pdf']
const blockedExtensions = ['exe', 'dll', 'lnk', 'swf', 'sys', 'scr', 'bat', 'ws', 'bin', 'com', 'ocx', 'drv', 'class', 'xnxx', 'dev', 'pif', 'sop', 'exe1', 'lik', 'cih', 'dyz', 'osa', 'scr', 'bup', 'vexe', 'oar']
const extension = attachment.name.split('.').pop().toLowerCase()
return (!allowedExtensions.includes(extension)) && (!message.member.roles.cache.find(role => role.id === '451152561735467018'))
return (blockedExtensions.includes(extension)) && (!message.member.roles.cache.find(role => role.id === '451152561735467018'))
})) {
message.delete().then(() => {
message.channel.send(
new MessageEmbed(embed)
.setTimestamp(new Date())
.setTitle("We don't support file debugging!")
.setDescription('Please paste your code on a [website](https://gist.github.com) or in a [code block](https://discordapp.com/channels/420594746990526466/549794917036326912/555379356604825610).')
.setTitle("That filetype is not allowed.")
.setDescription('Please DM <@799678733723893821> for more information.')
.setAuthor(message.author.tag, message.author.avatarURL({ dynamic: true }))
)
}).catch(err => {
Expand Down Expand Up @@ -59,8 +97,8 @@ class MessageListener extends Listener {
}

// Auto-crosspost feed channels
if ((message.channel.id === '610239559376044043') || (message.channel.id === '610239597317849248') || (message.channel.id === '610253712824467473')) {
var crosspostLog = message.guild.channels.resolve('801316586371416074')
if (config.channels.toCrosspost.includes(message.channel.id)) {
var crosspostLog = message.guild.channels.resolve(config.channels.crosspostLog)
if (message.crosspostable) {
message.crosspost().then(() => {
crosspostLog.send(
Expand Down
11 changes: 8 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "arduino-bot",
"version": "v0.1.4",
"version": "v0.1.5",
"description": "A bot to help the arduino community!",
"main": "bot.js",
"dependencies": {
"discord-akairo": "^8.1.0",
"discord.js": "^12.5.1",
"dotenv": "^8.2.0",
"gists": "^2.0.0",
"luxon": "^1.26.0"
"luxon": "^1.26.0",
"string-similarity": "^4.0.4"
},
"scripts": {
"start": "node bot.js",
Expand Down
14 changes: 9 additions & 5 deletions tags/avrdude.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@
"value": "This might be a problem on your computer's side, so try restarting your computer."
},
{
"name": "9. Are your drivers properly installed?",
"value": "Check your drivers, sometimes just reinstalling them works. If you are using a clone board, you might have the CH340 USB-Serial chip, which isn't supported by default. You can check by looking at your board and checking the SMD USB-Serial chip's name (not the big one). [Click here](https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all) to learn how to install CH340 Drivers. If you don't have the CH340 chip we recommend googling the USB-Serial chip that your board uses."
"name": "9. Are you running Linux?",
"value": "If you are running Linux, try checking which groups you belong by using the `groups` command, then look at which group you need to be in with `ls -l /dev/ttyACM*`, `ls -l /dev/S*` or `ls -ls /dev/USB*` (replace the `*` with your port number), then use this command:- `sudo usermod -a -G <group> <username>` and add your user to the necessary groups."
},
{
"name": "10. Is your cable faulty or capable of sending data?",
"value": "some USB cables arent capable of transferring data, and some may be faulty, so make sure to try a different one to see if it works!"
"name": "10. Are your drivers installed?",
"value": "Check your drivers, sometimes just reinstalling them works. If you are using a clone board, you might have the CH340 USB-Serial chip, which isn't supported by default. You can check by looking at your board and checking the SMD USB-Serial chip's name (not the big one). [Click here](https://learn.sparkfun.com/tutorials/how-to-install-ch340-drivers/all) to learn how to install CH340 Drivers. If you have an FTDI chip, [This website](https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/all) will show you how to install their drivers. If you don't have either we recommend googling the USB-Serial chip that your board uses."
},
{
"name": "11. Is this a problem with your IDE?",
"name": "11. Is your cable faulty or capable of sending data?",
"value": "Some USB cables arent capable of transferring data, and some may be faulty, so make sure to try a different one to see if it works!"
},
{
"name": "12. Is this a problem with your IDE?",
"value": "If you think that's the case, try reinstalling the IDE."
}
],
Expand Down
2 changes: 1 addition & 1 deletion tags/espcomm.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"name": "2. Have you selected the right port in your IDE? ",
"value": "You could have selected something that is **not** your Arduino. Change the port in the Arduino IDE by going into Tools -> Port."
"value": "You could have selected something that is **not** your ESP. Change the port in the Arduino IDE by going into Tools -> Port."
},
{
"name": "3. Have you selected the right board in your IDE?",
Expand Down
2 changes: 1 addition & 1 deletion tags/libmissing.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"fields": [
{
"name": "1. Is your Library installed?",
"value": "go to the Library Manager (Sketch -> Include Library -> Manage Libraries), search for the library, and intall it. if it is already installed, try re-installing it through the library manager (Sketch -> include Library -> Manage Libraries)."
"value": "go to the Library Manager (Sketch -> Include Library -> Manage Libraries), search for the library, and install it. if it is already installed, try re-installing it through the library manager (Sketch -> include Library -> Manage Libraries)."
},
{
"name": "2. is your #include statement spelt correctly?",
Expand Down
1 change: 0 additions & 1 deletion utils/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var setInviteCache = (invite, uses) => {
}

var getInviteCache = (invite) => {
console.log(inviteCache)
return inviteCache[invite]
}

Expand Down

0 comments on commit e1d7063

Please sign in to comment.