forked from AdamMcWilliam/TwitchBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
175 lines (124 loc) · 4.61 KB
/
bot.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# bot.py
import os # for importing env vars for the bot to use
from twitchio.ext import commands
from grovelAttempt import *
from getBotStreetCred import *
from getBotCoolPoints import *
from AppendCubeTime import *
from stealFromBot import *
from AverageCubeTime import *
from DailyAverageCubeTime import *
from inflate import *
from switchSides import *
import datetime
bot = commands.Bot(
#all this is loaded from the .env file that you need to create
# set up the bot
irc_token=os.environ['TMI_TOKEN'],
client_id=os.environ['CLIENT_ID'],
nick=os.environ['BOT_NICK'],
prefix=os.environ['BOT_PREFIX'],
initial_channels=[os.environ['CHANNEL']]
)
# bot.py, below bot object
@bot.event
async def event_ready():
'Called once when the bot goes online.'
print(f"{os.environ['BOT_NICK']} is online!")
#ws = bot._ws # this is only needed to send messages within event_ready
#await ws.send_privmsg(os.environ['CHANNEL'], f"/me has Entered the chat!")
# bot.py, below event_ready
@bot.event
async def event_message(ctx):
'Runs every time a message is sent in chat.'
# make sure the bot ignores itself and the streamer
if ctx.author.name.lower() == os.environ['BOT_NICK'].lower():
return
#bot.py, in event_message, below the bot ignore stuffs
await bot.handle_commands(ctx)
# bot.py, below event_message function
# @bot.command(name='test')
# async def test(ctx):
# await ctx.send('test passed!')
@bot.command(name='!manifestozanussbot')
async def manifestozanussbot(ctx):
await ctx.send('This bot Logs Begins cube times in a google spreadsheet with !cubed 0:00:00 when entered by beginbotbot. The average cube time can be fetched with !!act. The average of begins attempts of the day can be fetched with !!dact.')
@bot.command(name='!botcss')
async def botcss(ctx):
if(ctx.author.name.lower() !='zanuss'):
return
await ctx.send('!css https://gist.githubusercontent.com/AdamMcWilliam/5619ec9f7fa83bef75e718e6d7daec22/raw/0376fc54fdfe47a5c71a2b8ea6911d8abb1d58f3/beginZanussBot.css')
@bot.command(name='!propsme')
async def propsme(ctx):
await ctx.send(f'!props {ctx.author.name.lower()}')
@bot.command(name='!csstemplate')
async def csstemplate(ctx):
await ctx.send('Here is a css template to help you get started on https://mygeoangelfirespace.city/: https://codepen.io/Zanuss/pen/dyGoamX')
@bot.command(name='!donateme')
async def donateme(ctx):
await ctx.send(f'!donate {ctx.author.name.lower()}')
@bot.command(name='!propsall')
async def propsall(ctx):
totalProps = getBotStreet()
#print(f'!props zanuss {totalProps}')
await ctx.send(f'!props {ctx.author.name.lower()} {totalProps}')
@bot.command(name='!buyall')
async def buyall(ctx):
if(ctx.author.name.lower() !='zanuss'):
return
totalCool = getBotCool()
#print(f'!props zanuss {totalProps}')
await ctx.send(f'!buy random {totalCool}')
@bot.command(name='cubed')
async def cubed(ctx):
if(ctx.author.name.lower() !='beginbotbot'):
return
message = ctx.content
timestamp = ctx.message.timestamp
#remove command text with str split
x = message.split('!cubed ')
message = str(x[1])
message = datetime.datetime.strptime(message, '%H:%M:%S')
#strip year
x = str(message).split()
message = str(x[1])
print(message)
#remove everything but the date
y = str(timestamp).split()
timestamp = y[0]
print(timestamp)
#send to function in AppendCubeTime.py
AppendCubeTime(str(message),str(timestamp))
@bot.command(name='steal')
async def steal(ctx):
if(ctx.author.name.lower() !='opsecbot'):
return
stealCommand = StealFromBot(ctx.content, ctx.author.name.lower())
print(f"!steal {stealCommand}")
await ctx.send(f"!steal {stealCommand}")
@bot.command(name='!inflate')
async def inflate(ctx):
if(ctx.author.name.lower() !='zanuss'):
return
inflateSound = inflateSoundFn(ctx.content)
await ctx.send(f'!steal {inflateSound} zanuss')
@bot.command(name='la_libre')
async def sideWithWin(ctx):
majority = sideWithWinners()
await ctx.send(f'!{majority}')
print(f'!{majority}')
@bot.command(name='!act')
async def act(ctx):
act = AvgCubeTime()
await ctx.send(f"Begins Overall Average: {act}")
@bot.command(name='!dact')
async def dact(ctx):
dact = DailyAvgCubeTime()
await ctx.send(f"Begins Daily Average: {dact}")
@bot.command(name='!grovel')
async def dact(ctx):
grovelerMessage = grovelAttempt(ctx.author.name.lower())
await ctx.send(f"{grovelerMessage}")
# bot.py
if __name__ == "__main__":
bot.run()