Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import os
import sys
import aiohttp
import asyncpg
import dotenv
import pyowm
from utilities import context
from utilities import logging
sys.path.insert(0, "..")
from units.games import eightball
sys.path.pop(0)
class Bot(commands.Bot):
def __init__(self, loop = None, initial_channels = None, **kwargs):
self.version = "3.0.0-b.133"
loop = loop or asyncio.get_event_loop()
if initial_channels is None:
initial_channels = []
initial_channels = list(initial_channels)
# Constants
self.char_limit = self.character_limit = 500
# aiohttp Client Session - initialized on ready
self.aiohttp_session = None
# Credentials
)):
pass
else:
print("You need to add your secrets to the .env-example file. Be sure to rename to \".env\".")
from twitchio.ext import commands
twitch_bot_nick = os.environ['TWITCH_BOT_NICK']
twitch_token = os.environ['TWITCH_TOKEN']
twitch_client_id = os.environ['TWITCH_CLIENT_ID']
twitch_cmd_prefix = os.environ['TWITCH_PREFIX']
twitch_channel = os.environ['TWITCH_CHANNEL']
twitch_team = os.environ['TWITCH_TEAM']
# Instantiate a bot with teh settings & secrets.
bot = commands.Bot(
irc_token=twitch_token,
client_id=twitch_client_id,
nick=twitch_bot_nick,
prefix=twitch_cmd_prefix,
initial_channels=[twitch_channel]
)
# Other secrets we needs
webserver_key = os.environ['BOT_SERVER_KEY']
streamlabs_key = os.environ['STREAMLABS_KEY']
# Feel free to customize this string!
sign_on_msg = "I'm back, baby!"
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from twitchio.ext import commands
# api token can be passed as test if not needed.
# Channels is the initial channels to join, this could be a list, tuple or callable
bot = commands.Bot(
irc_token='...',
api_token='test',
nick='mysterialpy',
prefix='!',
initial_channels=['mysterialpy']
)
# Register an event with the bot
@bot.event
async def event_ready():
print(f'Ready | {bot.nick}')
@bot.event
async def event_message(message):
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from discord.ext import commands as discord_commands
from twitchio.ext import commands as commands
class DiscordCog(commands.Bot):
def __init__(self, bot):
# Discord bot instance
self.discord_bot = bot
super().__init__(irc_token='...', nick='...', prefix='!', initial_channels=['...'])
# Start the Twitch Bot
self.loop.create_task(self.start())
# Discord.py event
async def on_message(self, message):
print(message.content)
# TwitchIO event
async def event_message(self, message):
print(message.content)
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
from twitchio.ext import commands
class Bot(commands.Bot):
def __init__(self):
super().__init__(
irc_token='...',
api_token='...',
nick='mysterialpy',
prefix='!',
initial_channels=['mysterialpy']
)
# Events don't need decorators when subclassed
async def event_ready(self):
print(f'Ready | {self.nick}')
async def event_message(self, message):
print(message.content)