forked from installgen2/spaghooter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintro.py
More file actions
73 lines (61 loc) · 1.73 KB
/
intro.py
File metadata and controls
73 lines (61 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Intros
# by wiiam
def joinintro(phenny, input):
phenny.say(read(input.nick))
joinintro.event = 'JOIN'
joinintro.rule = r'.*'
def sintro(phenny, input):
introsplit = input.group(2).split(' ')
if introsplit[0] == "set":
introtoadd = ""
for i in range(1, len(introsplit)):
introtoadd += introsplit[1]
phenny.say("\"" + introtoadd + "\" set as intro")
write(input.nick, introtoadd)
if introsplit[0] == "del":
if delete(input.nick) is True:
phenny.say("Your intro has been deleted")
else:
phenny.say("You didn't have an intro")
sintro.commands = ['sintro']
sintro.priority = 'medium'
def read(nick):
f = open('intros', 'r')
lines = f.readlines()
intro = " "
for i in range(0, len(lines), 2):
if lines[i] == nick + "\n":
intro = lines[i+1]
f.close()
if intro.endswith("\n"):
intro = intro[:-1]
return intro
def write(nick, intro):
f = open('intros', 'r')
list = f.readlines()
foundnick = False
f = open('intros', 'w+')
for i in range(0, len(list), 2):
if list[i] == nick + "\n":
list[i+1] = intro + "\n"
foundnick = True
break
if foundnick is False:
list += [nick + "\n"]
list += [intro + "\n"]
for i in range(len(list)):
f.write(list.pop(0))
def delete(nick):
f = open('intros', 'r')
list = f.readlines()
foundnick = False
f = open('intros', 'w+')
for i in range(len(list)):
if list[i] == nick + "\n":
foundnick = True
list.pop(i)
list.pop(i)
break
for i in range(len(list)):
f.write(list.pop(0))
return foundnick