Add welcome_message configuration to settings.ini

This commit is contained in:
Alex Parella 2014-12-30 17:23:43 -08:00
parent 5ac9faa614
commit b98dac4aa9
3 changed files with 13 additions and 6 deletions

6
bot.py
View File

@ -17,8 +17,9 @@ help_list = [r'help', r'info', r'faq', r'explain yourself']
# Defines a bot # Defines a bot
class Bot(object): class Bot(object):
def __init__(self, botnick, nick_source='nicks.csv', wait_time=60): def __init__(self, botnick, welcome_message, nick_source='nicks.csv', wait_time=60):
self.botnick = botnick self.botnick = botnick
self.welcome_message = welcome_message
self.nick_source = nick_source self.nick_source = nick_source
self.wait_time = wait_time self.wait_time = wait_time
self.known_nicks = [] self.known_nicks = []
@ -65,7 +66,6 @@ def parsesettings():
for option in parser.options(section): for option in parser.options(section):
settings[option] = parser.get(section, option) settings[option] = parser.get(section, option)
print(settings)
return settings return settings
# Creates a socket that will be used to send and receive messages, # Creates a socket that will be used to send and receive messages,
@ -236,7 +236,7 @@ def main():
settings = parsesettings() settings = parsesettings()
ircsock = irc_start(settings["server"]) ircsock = irc_start(settings["server"])
join_irc(ircsock, settings["botnick"], settings["channel"]) join_irc(ircsock, settings["botnick"], settings["channel"])
WelcomeBot = Bot(settings["botnick"]) WelcomeBot = Bot(settings["botnick"], settings["welcome_message"])
while 1: # Loop forever while 1: # Loop forever
ready_to_read, b, c = select.select([ircsock],[],[], 1) # b&c are ignored here ready_to_read, b, c = select.select([ircsock],[],[], 1) # b&c are ignored here
process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time],ircsock,settings["channel"], settings["channel_greeters"].split(",")) process_newcomers(WelcomeBot, [i for i in WelcomeBot.newcomers if i.around_for() > WelcomeBot.wait_time],ircsock,settings["channel"], settings["channel_greeters"].split(","))

View File

@ -73,3 +73,5 @@ MaraJade
achock achock
aaparella aaparella
abcqfiojqw abcqfiojqw
somethingsoemthi
blahblahbloo

1 paulproteus
73 achock
74 aaparella
75 abcqfiojqw
76 somethingsoemthi
77 blahblahbloo

View File

@ -1,4 +1,9 @@
; Replace these default settings with your own personal settings
[Configurations] [Configurations]
channel : #openhatch-bots channel : #openhatch-bots
botnick: welcomebot botnick : parsewelcomebot
server : irc.freenode.net server : irc.freenode.net
channel_greeters : shauna,paulproteus,marktraceur
hello_list : hello,hi,hey,yo,sup
help_list : help,info,faq,explain_yourself
welcome_message : Welcome! THe channel is pretty quiet right now, so I thought I'd say hello, and ping some people that you're here. If no one responds for a whle, try emailing us at hello@openhatch.org or just try coming back later. FYI, you're now on my list of known nicknames, so I won't bother you again.