Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
Create setup and modification script (#47)
Browse files Browse the repository at this point in the history
* add all variables to define to getinfo()
*Create NS Password Variable
* create settings.csv with default settings
* create install.py script (#48)
* Update bot.py
* Create modifysetup.py (#50)
* Update modifysetup.py
  • Loading branch information
RhinosF1 authored Aug 5, 2019
1 parent bf90756 commit fe98c06
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 7 deletions.
46 changes: 39 additions & 7 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
pingbot = 1
buttbot = 0
cashortbot = 1
nspassword = ''

def getinfo():
global topic
Expand All @@ -36,33 +37,48 @@ def getinfo():
global linkbot
global pingbot
global buttbot
global cashort
global admins
global cashortbot
global admins
global owapikey
global nspassword
infofile = ('settings.csv', 'r')
for line in infofile:
setting = line.split(';')
if setting[0] == 'topic':
topic = setting[1]
if setting[0] == 'nick':
nick = setting[1]
if setting[0] == 'greetings':
greetings = settings[1].split(',')
if setting[0] == 'greetingsbot':
greetingsbot = setting[1]
if setting[0] == 'weatherbot':
weatherbot = setting[1]
if setting[0] == 'apikey':
apikey = setting[1]
if setting[0] == 'owapikey':
owapikey = setting[1]
if setting[0] == 'quotebot':
quotebot = setting[1]
if setting[0] == 'linkbot':
linkbot = setting[1]
if setting[0] == 'pingbot':
greetingsbot = setting[1]
if setting[0] == 'buttbot':
buttbot = setting[1]
if setting[0] == 'cashortbot':
cashortbot = setting[1]
if setting[0] == 'admins':
admins = setting[1]
admins = admins.split(',')
if setting[0] == 'nspassword':
nspassword = setting[1]

def on_connect(bot):
bot.set_nick(nick)
bot.send_user_packet(nick)

def on_welcome(bot):
bot.send_message('NickServ', 'identify ')
global nspassword
bot.send_message('NickServ', 'identify ' + nspassword)
print('Authed to NickServ')
time.sleep(10)
bot.join_channel('##channel')
Expand All @@ -78,7 +94,7 @@ def on_message(bot, channel, sender, message):
global linkbot
global pingbot
global buttbot
global cashort
global cashortbot
global admins
global owapikey
if "hi " in message.lower() and greetingsbot == 1 or "hello " in message.lower() and greetingsbot == 1:
Expand Down Expand Up @@ -171,12 +187,20 @@ def on_message(bot, channel, sender, message):
if message.lower() == '!getinfo' and sender in admins:
bot.set_nick(nick + '-down')
bot.send_message(sender, 'Rebuilding')
topic = ''
nick = ''
lastgreeter = ''
greetings = ''
owapikey = ''
admins = ''
greetingsbot = 0
weatherbot = 0
linkbot = 0
quotebot = 0
pingbot = 0
buttbot = 0
cashortbot = 0
nspassword = ''
time.sleep(1)
getinfo()
time.sleep(1)
Expand All @@ -202,7 +226,7 @@ def on_pm(bot, sender, message):
global linkbot
global pingbot
global buttbot
global cashort
global cashortbot
global admins
global owapikey
print('Got PM')
Expand Down Expand Up @@ -277,12 +301,20 @@ def on_pm(bot, sender, message):
if message.lower() == 'getinfo' and sender in admins:
bot.set_nick(nick + '-down')
bot.send_message(sender, 'Rebuilding')
topic = ''
nick = ''
lastgreeter = ''
greetings = ''
owapikey = ''
admins = ''
greetingsbot = 0
weatherbot = 0
linkbot = 0
quotebot = 0
pingbot = 0
buttbot = 0
cashortbot = 0
nspassword = ''
time.sleep(1)
getinfo()
time.sleep(1)
Expand Down
60 changes: 60 additions & 0 deletions install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
####DEFAULTS###
topic = ''
nick = 'quirctest123'
lastgreeter = ''
greetings = [
"Hello {}!",
"Hi {}!",
"Hello there {}!",
"Hi there {}!",
"Hey {}!"
]
owapikey = ''
admins = ['freenode-staff', 'freenode-staff']
greetingsbot = 1
weatherbot = 0
linkbot = 1
quotebot = 1
pingbot = 1
buttbot = 0
cashortbot = 1
##RUN THIS SCRIPT AFTER INSTALLING THIS -- THIS WILL ALLOW YOU TO SETUP A WORKING SETTINGS FILE
##WHEN ENABLING BOTS - YOU MUST ANSWER 1 (ON) OR 0 (OFF)
print('Thanks for downloading QuIRC's QuIRC Bot Scripts')
print('This will create your settings file for you')
print('----')
nick = input('What is your bot nick? ')
nspassword = input('What is the bot\'s NickServ Password? ')
topic = input('What is the topic in the channel the bot runs in?')
print = 'For each gretting please add a {} where the nick of the sender should go'
print = 'After each greeting, place a comma to seperate them'
greetings = input('What greetings should be used? ')
greetingsbot = input('Should the greetingsbot module be enabled?' )
weatherbot = input('Should the weatherbot module be enabled? ')
if weatherbot.isnum() = True:
if weatherbot == 1:
owapikey = input('What is your open weather map api key? ')
quotebot = input('Should the quotebot module be enabled? ')
if quotebot.isnum() = True:
if quotebot == 1:
print('Please gets your quotes ready, you should seperate quotes with a comma and place them in quoutes.csv')
pingbot = input('Should the pingbot module be enabled? (PM ONLY) ')
buttbot = input ('Should the buttbot module be enabled? ')
cashortbot = input('Should the central auth short links bot module be enabled? ')
admins = input('Who are the bots admins (they get access to functions which either require them to be present at the computer running the bot or that have the power to bring the botdown)? -- seperate with a comma ')
print('Your settings file will now be created')
file.open('settings.csv', 'a+')
content = ''
content = 'nick;'+nick+',\n'
content = content+'nspassword;'+nspassword+',\n'
content = content+'topic;'+topic+',\n'
content = content+'greetings;'+greetings+',\n'
content = content+'greetingsbot;'+greetingsbot+',\n'
content = content+'weatherbot;'+weatherbot+',\n'
content = content+'owapikey;'+owapikey+',\n'
content = content+'quotebot;'+quotebot+',\n'
content = content+'pingbot;'+pingbot+',\n'
content = content+'buttbot;'+buttbot+',\n'
content = content+'cashortbot;'+cashortbot+',\n'
content = content+'admins;'+admins+',\n'
print('Setup Complete. The bot may now be ran using bot.py')
120 changes: 120 additions & 0 deletions modifysetup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
print('QuIRC Setup Modifcation tool. Use !getinfo on IRC after running this to update the bots cache')
####DEFAULTS###
topic = '' #channel topic for use in channels where quotebot runs
nick = 'quirctest123'
lastgreeter = ''
greetings = [
"Hello {}!",
"Hi {}!",
"Hello there {}!",
"Hi there {}!",
"Hey {}!"
]
owapikey = '' #place an api key for open weather map here
admins = ['freenode-staff', 'freenode-staff']
##FUNCTION FLAGS - SET TO 1 TO ENABLE
greetingsbot = 1
weatherbot = 0
linkbot = 1
quotebot = 1
pingbot = 1
buttbot = 0
cashortbot = 1
nspassword = ''
print('Downloading your current settings...')
###GETSETTINGS###
infofile = ('settings.csv', 'r')
for line in infofile:
setting = line.split(';')
if setting[0] == 'topic':
topic = setting[1]
if setting[0] == 'nick':
nick = setting[1]
if setting[0] == 'greetings':
greetings = settings[1].split(',')
if setting[0] == 'greetingsbot':
greetingsbot = setting[1]
if setting[0] == 'weatherbot':
weatherbot = setting[1]
if setting[0] == 'owapikey':
owapikey = setting[1]
if setting[0] == 'quotebot':
quotebot = setting[1]
if setting[0] == 'linkbot':
linkbot = setting[1]
if setting[0] == 'pingbot':
greetingsbot = setting[1]
if setting[0] == 'buttbot':
buttbot = setting[1]
if setting[0] == 'cashortbot':
cashortbot = setting[1]
if setting[0] == 'admins':
admins = setting[1]
admins = admins.split(',')
if setting[0] == 'nspassword':
nspassword = setting[1]
print('Starting tool....')
run = 1
while run = 1:
print('----')
print('1.nick')
print('2.NickServ Password')
print('3.topic')
print('4.greetings')
print('5.greetingsbot')
print('6.weatherbot')
print('7.owapikey')
print('8.quotebot')
print('9.pingbot')
print('10.buttbot')
print('11.cashortbot')
print('12.admins')
settoupdate = input('Which setting would you like to update?')
if settoupdate = 1:
nick = input('What is your bot nick? ')
if settoupdate = 2:
nspassword = input('What is the bot\'s NickServ Password? ')
if settoupdate = 3:
topic = input('What is the topic in the channel the bot runs in?')
if settoupdate = 4:
print = 'For each gretting please add a {} where the nick of the sender should go'
print = 'After each greeting, place a comma to seperate them'
greetings = input('What greetings should be used? ')
if settoupdate = 5:
greetingsbot = input('Should the greetingsbot module be enabled?' )
if settoupdate = 6:
weatherbot = input('Should the weatherbot module be enabled? ')
if settoupdate = 7:
owapikey = input('What is your open weather map api key? ')
if settoupdate = 8:
quotebot = input('Should the quotebot module be enabled? ')
if quotebot.isnum() = True:
if quotebot == 1:
print('Please gets your quotes ready, you should seperate quotes with a comma and place them in quoutes.csv')
if settoupdate = 9:
pingbot = input('Should the pingbot module be enabled? (PM ONLY) ')
if settoupdate = 10:
buttbot = input ('Should the buttbot module be enabled? ')
if settoupdate = 11:
cashortbot = input('Should the central auth short links bot module be enabled? ')
if settoupdate = 12:
admins = input('Who are the bots admins (they get access to functions which either require them to be present at the computer running the bot or that have the power to bring the botdown)? -- seperate with a comma ')
another = input('Would you like to update anything else? y/n ').lower()
if another = 'n':
run = 0
print('Your settings file will now be updated')
file.open('settings.csv', 'a+')
content = ''
content = 'nick;'+nick+',\n'
content = content+'nspassword;'+nspassword+',\n'
content = content+'topic;'+topic+',\n'
content = content+'greetings;'+greetings+',\n'
content = content+'greetingsbot;'+greetingsbot+',\n'
content = content+'weatherbot;'+weatherbot+',\n'
content = content+'owapikey;'+owapikey+',\n'
content = content+'quotebot;'+quotebot+',\n'
content = content+'pingbot;'+pingbot+',\n'
content = content+'buttbot;'+buttbot+',\n'
content = content+'cashortbot;'+cashortbot+',\n'
content = content+'admins;'+admins+',\n'
print('Update Complete. Please use !getinfo to update bot\'s cache')
12 changes: 12 additions & 0 deletions settings.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
nick;quirctest123,
nspassword;password,
topic;channeltopics,
greetings;hello {}!,Hi {}!,Hello there {}!, Hi there {}!,Hey {},
greetingsbot;1,
weatherbot;0,
owapikey;000,
quotebot;1,
pingbot;1,
buttbot;1,
cashortbot;1,
admins;freenode-staff,RhinosF1,

0 comments on commit fe98c06

Please sign in to comment.