Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Rework to not pass bot and trigger phab T69 #2 (#293)
Browse files Browse the repository at this point in the history
* Update welcome.py

Fixed welcome.py send_welcome to not pass bot and trigger

* Spaces to Tab

* autopep8 results

Change spacing with autopep8 for .... 'tool happiness'

Co-authored-by: RhinosF1 <rhinosf1@gmail.com>
Co-authored-by: Operator873 <operator873@873gear.com>
  • Loading branch information
3 people committed Aug 17, 2020
1 parent 0d8453b commit 22f8583
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions MirahezeBots/plugins/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@
CHANNEL_RE = re.compile(r'#[A-Za-z0-9#\-]+$')


def send_welcome(bot, trigger):
user = trigger.nick
if trigger.sender == '#miraheze' and user[:4] != 'Not-':
def send_welcome(nick, chan):
if chan == '#miraheze' and nick[:4] != 'Not-':
message = ("Hello {}! If you have any questions, feel free to ask "
"and someone should answer soon.").format(trigger.nick)
elif trigger.sender == '#miraheze-cvt':
"and someone should answer soon.").format(nick)
elif chan == '#miraheze-cvt':
message = ("Welcome {}. If you need to report spam or abuse,"
" please feel free to notify"
" any of the voiced (+v) users,"
" if it contains personal information you can pm them,"
" or email us"
" at cvt [at] miraheze.org").format(trigger.nick)
" at cvt [at] miraheze.org").format(nick)
else:
return
if trigger.account == '*':
bot.known_users_list[trigger.sender].append(trigger.nick)
else:
bot.known_users_list[trigger.sender].append(trigger.account)
bot.say(message)
save_known_users_list(get_filename(bot), bot.known_users_list)
message = None

return message


def get_filename(bot):
Expand Down Expand Up @@ -84,10 +79,18 @@ def welcome_user(bot, trigger):
bot.known_users_list[trigger.sender] = []
if trigger.account == '*':
if trigger.nick not in bot.known_users_list[trigger.sender]:
send_welcome(bot, trigger)
bot.known_users_list[trigger.sender].append(trigger.nick)
welcome = send_welcome(trigger.nick, trigger.sender)
if welcome is not None:
bot.say(welcome)
else:
if trigger.account not in bot.known_users_list[trigger.sender] and trigger.nick not in bot.known_users_list[trigger.sender]:
send_welcome(bot, trigger)
bot.known_users_list[trigger.sender].append(trigger.account)
welcome = send_welcome(trigger.nick, trigger.sender)
if welcome is not None:
bot.say(welcome)

save_known_users_list(get_filename(bot), bot.known_users_list)


@commands('add_known', 'adduser')
Expand Down Expand Up @@ -119,12 +122,12 @@ def add_known_user(bot, trigger):

if username in bot.known_users_list[channel]:
bot.say('{} is already added to known users list of channel {}'.format(
username, channel
))
username, channel
))
return

bot.known_users_list[channel].append(username)
save_known_users_list(get_filename(bot), bot.known_users_list)
bot.say('Okay, {} is now added to known users list of channel {}'.format(
username, channel
))
username, channel
))

0 comments on commit 22f8583

Please sign in to comment.