Skip to content

Commit

Permalink
Merge pull request #168 from leocabeza/ngve-arregla-saludos
Browse files Browse the repository at this point in the history
Ngve arregla saludos
  • Loading branch information
leocabeza authored Feb 26, 2019
2 parents ff290f3 + 04d22c6 commit 035abc0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## [Unreleased]

## 4.0.1 (2019-02-26)

### Arreglado

- Saludos a nuevos (ex)miembros

## 4.0.0 (2019-02-23)

### Agregado
Expand Down
37 changes: 34 additions & 3 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion src/listen-commands/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ const { forwardMessage } = require('bot-api-overrides');
const verifyUrls = async (bot, msg) => {
const chatId = msg.chat.id;
const chatInfo = await bot.getChat(chatId);
const {
type,
all_members_are_administrators: allMembersAreAdministrators,
} = chatInfo;

if (chatInfo.type === 'group') {
if (['group', 'supergroup'].includes(type) && !allMembersAreAdministrators) {
const urlEntities = msg.entities
? msg.entities.filter(entity => entity.type === 'url')
: [];
Expand Down
2 changes: 1 addition & 1 deletion src/listen-commands/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const verifyCode = async (bot, msg) => {
const chatId = msg.chat.id;
const chatInfo = await bot.getChat(chatId);

if (chatInfo.type === 'group') {
if (['supergroup', 'group'].includes(chatInfo.type)) {
if (!Object.prototype.hasOwnProperty.call(msg, 'entities')) {
return;
}
Expand Down
12 changes: 10 additions & 2 deletions src/listen-commands/greetings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const formatName = (firstName, userName) =>
const sayHello = async (bot, msg) => {
const chatId = msg.chat.id;
const chatInfo = await bot.getChat(chatId);
if (chatInfo.type === 'group') {
const {
type,
all_members_are_administrators: allMembersAreAdministrators,
} = chatInfo;
if (['supergroup', 'group'].includes(type) && !allMembersAreAdministrators) {
msg.new_chat_members.forEach(({ first_name, username }) => {
const message = welcome.replace(
'#{name}',
Expand All @@ -41,7 +45,11 @@ const sayGoodbye = async (bot, msg) => {
const chatId = msg.chat.id;
const chatInfo = await bot.getChat(chatId);
const { first_name: firstName, username } = msg.left_chat_member;
if (chatInfo.type === 'group') {
const {
type,
all_members_are_administrators: allMembersAreAdministrators,
} = chatInfo;
if (['supergroup', 'group'].includes(type) && !allMembersAreAdministrators) {
sendMessage(
bot,
msg.chat.id,
Expand Down

0 comments on commit 035abc0

Please sign in to comment.