コード例 #1
0
def create_twitch_bot():
    bot = commands.Bot(
        irc_token=get_oauth_token(),
        client_id=client_id,
        nick=nick,
        prefix='!',
        initial_channels=['rubikon'],
    )

    # Events don't need decorators when subclassed
    @bot.event
    async def event_ready():
        print(f'Ready | {bot.nick}')

    @bot.event
    async def event_message(message):
        print(f'<{message.author.name}>: {message.content}')
        await bot.handle_commands(message)

    # Commands use a different decorator
    @bot.command(name='test')
    async def my_command(ctx):
        await ctx.send(f'Hello @{ctx.author.name}!')

    return bot
コード例 #2
0
ファイル: bot.py プロジェクト: RishiRamraj/gstone
def make(irc_token, client_id, channel, conf):
    """
    Create and return the bot.
    """
    bot = commands.Bot(
        irc_token=irc_token,
        client_id=client_id,
        nick=conf["nick"],
        prefix=conf.get("prefix", PREFIX),
        initial_channels=[channel],
    )

    # Add a ready command.
    @bot.event
    async def event_ready():
        """
        Called once when the bot goes online.
        """
        greeting = conf.get("greeting", GREETING)
        await bot._ws.send_privmsg(channel, greeting)
        log.info("%s is online", conf["nick"])

    # Called on every message.
    @bot.event
    async def event_message(ctx):
        """
        Runs every time a message is sent in chat.
        """
        # Handle commands.
        await bot.handle_commands(ctx)

    return bot
コード例 #3
0
def main():

    load_dotenv()

    irc_token = os.getenv('TMI_TOKEN')
    client_id = os.getenv('CLIENT_ID')
    bot_nick = os.getenv('BOT_NICK')
    prefix = os.getenv('BOT_PREFIX')
    channel = os.getenv('CHANNEL')

    bot = commands.Bot(irc_token=irc_token,
                       client_id=client_id,
                       nick=bot_nick,
                       prefix=prefix,
                       initial_channels=[channel])

    @bot.event
    async def event_ready():
        print(f"bot is online!")
        ws = bot._ws  # this is only needed to send messages within event_ready
        await ws.send_privmsg(channel, f"/me online!")

    @bot.event
    async def event_message(ctx):
        # make sure the bot ignores itself
        if ctx.author.name.lower() == bot_nick.lower():
            return

        if ctx.content.lower().startswith(prefix):
            await command_process(ctx, ctx.content.lower())

    # Starting the bot
    bot.run()
コード例 #4
0
ファイル: twitch.py プロジェクト: JakeSichley/Discord-Bot
 def __init__(self, bot: discord_commands.Bot):
     self.discord_bot = bot
     self.bot = twitch_commands.Bot(irc_token=getenv('TWITCH_TOKEN'), client_id=getenv('TWITCH_ID'),
                                    nick=getenv('TWITCH_NICK'), prefix=getenv('PREFIX'),
                                    initial_channels=['#csuflol'])
     self.discord_bot.loop.create_task(self.bot.start())
     self.bot.command(name="giveaway")(self.twitch_giveaway)
     self.bot.listen("event_message")(self.event_message)
     self.active_chatters = {}
コード例 #5
0
 def __init__(self, bot):
     self.discord_bot = bot
     self.bot = commands.Bot(
         # set up the bot
         irc_token='',
         client_id='',
         nick='',
         prefix='',
         initial_channels=[''])
     self.discord_bot.loop.create_task(self.bot.start())
     self.bot.command(name="test")(self.twitch_command)
     self.bot.listen("event_message")(self.event_message)
コード例 #6
0
ファイル: twitch.py プロジェクト: tipptop3d/Canyon
    def __init__(self, bot):
        self.discord_bot = bot
        self.emoji = '🎥'

        self.twitch_bot = twitch_commands.Bot(
            # set up the bot
            irc_token=config.TWITCH_BOT_IRC,
            client_id=config.TWITCH_CLIENT_ID,
            nick=config.TWITCH_BOT_USERNAME,
            prefix='!',
            initial_channels=[config.TWITCH_CHANNEL_NAME])
        self.discord_bot.loop.create_task(self.twitch_bot.start())
        self.twitch_bot.listen('event_message')(self.event_message)
        self.twitch_bot.command(name='test')(self.my_command)
コード例 #7
0
    def __init__(self, bot: discord.Client):
        self._voice_clients = {}
        self.discord_bot = bot

        self.bot: twitch_commands.Bot = twitch_commands.Bot(
            # set up the bot
            irc_token=tokens['twitch'],
            api_tocken='test',
            nick='IAM0VERIT',
            prefix='!',
            initial_channels=[])
        self.discord_bot.loop.create_task(self.bot.start())
        # self.bot.command(name="help")(self.twitch_command)
        self.bot.listen("event_message")(self.event_message)
コード例 #8
0
    def __init__(self):
        self.flask_app = Flask(__name__)  # Flask application

        self.config = json.load(open('config.json'))  # Contains credentials and settings

        self.bot = commands.Bot(  # The Twitch bot
            irc_token=self.config['tmi_token'],
            client_id=self.config['client_id'],
            nick=self.config['bot_nickname'],
            prefix=self.config['bot_prefix'],
            initial_channels=[self.config['channel']]
        )

        # Oauth code which will needs to be provided every time the script is run
        self.oauth_code = None

        self._api = None
コード例 #9
0
def Setup():

    #nick = input("What is your twitch: ")
    nick = "starlightdev"

    bot = commands.Bot(
        irc_token=data[2],
        client_id=data[0],
        nick= nick,
        prefix="!!!",
        initial_channels=[nick]
    )

    @bot.event
    async def event_ready():
        print("Bot is online!")
        ws = bot._ws
        #await ws.send_privmsg(nick, f"/me has landed!")

    @bot.event
    async def event_message(ctx):

        time = ctx.timestamp

        print(ctx)

        messages2.append(
            {
                "Author": ctx.author.display_name,
                "Message": ctx.content,
                #"Time": ctx.timestamp,
                "TimeStamp":time.strftime("%H:%M"),
                "Color": "#9147FF"
            }
        )

    def startThread():
        bot.run()

    thread = threading.Thread(name="Twitch", target=startThread)

    return thread
コード例 #10
0
import socket
import os
from twitch_db import update_twitch, authorized_users
from Song_suggestions import suggest, conn
from Song_List import connect, insert_song
from twitchio.ext import commands
bot = commands.Bot(
    # set up the bot
    irc_token="oauth:TOCKEN",
    client_id="ID",
    nick="NAME",
    prefix="!",
    initial_channels=["CHANNEL_NAME"])


@bot.event
async def event_ready():
    print(f'Ready | {bot.nick}')


@bot.event
async def event_message(message):
    print(message.content)
    author = message.author
    update_twitch(author)
    await bot.handle_commands(message)


@bot.command()
async def calp(ctx):
    await ctx.send(
コード例 #11
0
"""Main bot file for Kappa Deep."""

from twitchio.ext import commands

from config import config
from tokens import tokens

startup_extensions = ['extensions.general',
                      'extensions.obs',
                      'extensions.sfx',
                      'extensions.skyline',
                      'extensions.streamelements']

bot = commands.Bot(irc_token=tokens.TWITCH_TOKEN,
                   nick=config.NICK,
                   prefix=config.PREFIX,
                   initial_channels=[config.CHAN])


@bot.event
async def event_ready():
  """Run when bot loads."""
  msg = f'{config.NICK} ready for duty! Batteries not included.'
  print(msg)

@bot.event
async def event_message(message):
  """Print messages."""
  # print(message._raw_data)

  await bot.handle_commands(message)
コード例 #12
0
import time

import requests
from requests_html import HTMLSession
from twitchio.ext import commands

config = configparser.ConfigParser()
config.read('config.ini')

nick_bot = 'casadodevbot'
inicia_canal = 'casadodev'

bot = commands.Bot(
    # set up the bot
    irc_token=config['bot']['token'],
    client_id=config['bot']['client_id'],
    nick=nick_bot,
    prefix='!',
    initial_channels=[inicia_canal],
)

# globais
counters = {}
pessoas_online = []
count_pessoa = []


@bot.event
async def event_ready():
    'Chama quando o bot está online.'
    print(f"@{nick_bot} está online!")
    ws = bot._ws  # só é chamado no evento inicial
コード例 #13
0
ファイル: bot.py プロジェクト: neyoneit/DFTwitchBot
import console
import serverstate
from env import environ
import threading
import queue
import asyncio
import websockets
import json

df_channel = environ['CHANNEL'] if 'CHANNEL' in environ and environ[
    'CHANNEL'] != "" else input("Your twitch channel name: ")

# bot setup
bot = commands.Bot(irc_token=environ['TMI_TOKEN'],
                   client_id=environ['CLIENT_ID'],
                   nick=environ['BOT_NICK'],
                   prefix=environ['BOT_PREFIX'],
                   initial_channels=[df_channel])


@bot.event
async def event_ready():
    """Called once when the bot goes online."""
    print(f"{environ['BOT_NICK']} is online!")
    ws = bot._ws  # this is only needed to send messages within event_ready
    await ws.send_privmsg(df_channel, f"/me has landed!")


@bot.event
async def event_message(ctx):
    """Activates for every message"""
コード例 #14
0
Ignore_Users = [str.lower() for str in Ignore_Users]

# 無視テキストリストの準備 ################
Ignore_Line = [x.strip() for x in config.Ignore_Line]

# 無視単語リストの準備 ################
Delete_Words = [x.strip() for x in config.Delete_Words]


####################################################
#####################################
# Simple echo bot.
bot = commands.Bot(
    irc_token           = "oauth:" + config.Trans_OAUTH,
    client_id           = "",
    nick                = config.Trans_Username,
    prefix              = "!",
    initial_channels    = [config.Twitch_Channel]
)

##########################################
# メイン動作 ##############################
##########################################

# 起動時 ####################
@bot.event
async def event_ready():
    'Called once when the bot goes online.'
    print(f"{config.Trans_Username} is online!")
    ws = bot._ws  # this is only needed to send messages within event_ready
    await ws.send_privmsg(config.Twitch_Channel, f"/color {config.Trans_TextColor}")
コード例 #15
0
import os  # for importing env vars for the bot to use
from twitchio.ext import commands
import random
from dotenv import load_dotenv

load_dotenv()
CHANNEL1 = 'calitobundo'
#channels = str(channels)
channels = CHANNEL1
print("running on:", channels)

bot = commands.Bot(
    # set up the bot
    irc_token=os.environ['TWITCH_TMI_TOKEN'],
    client_id=os.environ['TWITCH_CLIENT_ID'],
    nick=os.environ['TWITCH_BOT_NICK'],
    prefix=os.environ['TWITCH_BOT_PREFIX'],
    initial_channels=[f"{CHANNEL1}"])

channelid = [os.environ['TWITCH_CHANNELID']]


@bot.event
async def event_command_error(ctx, error):
    error = str(error)
    with open("calitoerr.log", "a+") as errorfile:
        error = error + "\n"
        errorfile.write(error)


@bot.event
コード例 #16
0
def start_bot(vote_manager: VoteManager):
    asyncio.set_event_loop(asyncio.new_event_loop())
    bot = commands.Bot(irc_token=TWITCH['IRCToken'],
                       client_id=TWITCH['ClientId'],
                       nick=TWITCH['Nick'],
                       prefix=TWITCH['Prefix'],
                       initial_channels=[TWITCH['Channel']])

    @bot.event
    async def event_ready():
        'Called once when the bot goes online.'
        print(f"Twitch layer ready")
        ws = bot._ws
        await ws.send_privmsg(TWITCH['Channel'],
                              f"/me is ready to receive votes")

    @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() == TWITCH['Nick'].lower():
            return
        try:
            await bot.handle_commands(ctx)
        except:
            pass

    @bot.command(name='vote')
    async def vote_command(ctx, vote=''):
        if not vote_manager.is_poll_available():
            await ctx.send(
                f'{ctx.author.name}, there\'s no vote happening at the moment')
        else:
            if vote:
                vote_manager.cast_vote(ctx.author.name, vote)
            else:
                await ctx.send(
                    f'{ctx.author.name} tell me what you\'re voting for!')

    @bot.command(name='points')
    async def points_command(ctx):
        points = vote_manager.get_points_for_user(ctx.author.name)
        ending = 's' if points != 1 else ''
        await ctx.send(f'{ctx.author.name}, you have {points} point{ending}')

    @bot.command(name='spend')
    async def spend_command(ctx, action='', argument=''):
        if action:
            if action not in ACTIONS:
                await ctx.send(
                    f'{ctx.author.name}, that\'s not a thing you can do...')
            elif not vote_manager.spend_points(ctx.author.name, action,
                                               argument):
                await ctx.send(
                    f'{ctx.author.name}, you don\'t have enough points!')
            else:
                await ctx.send(f'Thanks {ctx.author.name}!')
        else:
            await ctx.send(
                f'{ctx.author.name}, tell me what you\'re spending points on!')

    bot.run()
コード例 #17
0
import os
from twitchio.ext import commands
from interface import twitch_api

from logger import loggymclogger as log

bot_name = os.environ['BOT_NICK']
team = twitch_api.team_members

# set up the bot
bot = commands.Bot(irc_token=os.environ['TMI_TOKEN'],
                   client_id=os.environ['CLIENT_ID'],
                   nick=bot_name,
                   prefix=os.environ['BOT_PREFIX'],
                   initial_channels=[os.environ['CHANNEL']])


@bot.event
async def event_ready():
    'Called once when the bot goes online.'
    log.info(f"{bot_name} is online!")
    msg = f"/me has landed!"
    ws = bot._ws  # set up websocket for sending first message (no ctx yet)
    await ws.send_privmsg(os.environ['CHANNEL'], msg)


@bot.event
async def event_message(ctx):
    'everythign that happens in this function happens every time a message is sent in teh channel'

    author = ctx.author.name  # define the author of the msg
コード例 #18
0
import os
from datetime import date, datetime

from dotenv import load_dotenv
from twitchio import Client
from twitchio.ext import commands
from twitchio.ext.commands import CommandNotFound

from quotes.QuoteHandler import QuoteHandler

load_dotenv()

bot = commands.Bot(
    # 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.event
async def event_ready():
    # Called once when the bot goes online.
    print(f"{os.environ['BOT_NICK']} is online!")


@bot.event
async def event_message(ctx):
    # Runs every time a message is sent in chat.
コード例 #19
0
ファイル: bot.py プロジェクト: 24kaliber/Tarkov-Twitch-Bot
    backupCount=3
)
log_handler.setLevel(logging.DEBUG)
log_handler.setFormatter(formatter)
log.addHandler(log_handler)

locale = []
with open("localizations.json", "r") as read_file:
    locale = json.load(read_file)


bot = commands.Bot(
    loop=loop,
    irc_token=settings.irc_token,
    client_id=settings.client_id,
    client_secret=settings.client_secret,
    nick=settings.nick,
    prefix=settings.prefix,
    initial_channels=channels[:99]
)

@bot.event
async def event_ready():
    print("I am online!\n")
    ws = bot._ws
    if len(channels) > 100:
        pack = 1
        while len(channels) > pack * 100:
                time.sleep(16)
                pack += 1
                print(f'Joining pack #{pack}\n')
コード例 #20
0
prefix = os.environ['BOT_PREFIX']
initial_channels = [os.environ['CHANNEL']]

# check env tables
if [
        x for x in (irc_token, client_id, nick, prefix, initial_channels)
        if x is None
]:
    print("Fill in the .env file.")
    exit(2)

# create bot object
bot = commands.Bot(
    # set up the bot
    irc_token=irc_token,
    client_id=client_id,
    nick=nick,
    prefix=prefix,
    initial_channels=initial_channels)


# bot.py, below bot object
@bot.event
async def event_ready():
    'Called once when the bot goes online.'
    print(f"{os.environ['BOT_NICK']} joined the party!\n")
    ws = bot._ws  # this is only needed to send messages within event_ready
    await ws.send_privmsg(os.environ['CHANNEL'],
                          f"/me pulled up on the scene.")

コード例 #21
0
from twitchio.ext import commands

from alttprbot.exceptions import SahasrahBotException
from config import Config as c

twitchbot = commands.Bot(irc_token=c.SB_TWITCH_TOKEN,
                         client_id=c.SB_TWITCH_CLIENT_ID,
                         nick=c.SB_TWITCH_NICK,
                         prefix=c.SB_TWITCH_PREFIX,
                         initial_channels=c.SB_TWITCH_CHANNELS)

twitchbot.load_module('alttprbot_twitch.cogs.gtbk')
twitchbot.load_module('alttprbot_twitch.cogs.league')


@twitchbot.event
async def event_command_error(ctx, error):
    if isinstance(error, commands.errors.CheckFailure):
        pass
    elif isinstance(error, commands.CommandNotFound):
        pass
    elif isinstance(error, SahasrahBotException):
        await ctx.send(error)
    else:
        await ctx.send(error)
        raise error
コード例 #22
0
import Settings
from twitchio.ext import commands
import os
import time

bot = commands.Bot(irc_token=Settings.TMI_TOKEN,
                   client_id=Settings.CLIENT_ID,
                   nick=Settings.BOT_NICK,
                   prefix=Settings.BOT_PREFIX,
                   initial_channels=[Settings.CHANNEL])


@bot.event
async def event_ready():
    'Called once when the bot goes online.'
    print(f"{Settings.BOT_NICK} is online!")
    ws = bot._ws  # this is only needed to send messages within event_ready
    #await ws.send_privmsg(Settings.CHANNEL, f"/me has landed!")


@bot.event
async def event_message(ctx):
    'Runs every time a message is sent in chat.'

    print(f'{ctx.author.name}: {ctx.content}')
    # make sure the bot ignores itself and the streamer
    if ctx.author.name.lower() == Settings.BOT_NICK.lower():
        await bot.handle_commands(ctx)


# bot.py
コード例 #23
0
players = []

# Emotions game SPIN
spin = [
    'EarthDay', 'PurpleStar', 'PraiseIt', 'duDudu', 'ItsBoshyTime',
    "PorscheWIN"
]

# Agua
agua = 'Bora beber água galera DrinkPurple '
water = "Let's go everyone frink water DrinkPurple "

# Váriavel para fazer as interações e conectar com os canaais
bot = commands.Bot(irc_token=oauth_key,
                   api_token=client_key,
                   nick='nickbot',
                   prefix='!',
                   initial_channels=['channel'])


@bot.event
async def event_ready():
    ws = bot._ws
    print(bot.initial_channels[0], f"Let's go, @{bot.nick} is online now.")

    await ws.send_privmsg(bot.initial_channels[0], f'Bot ta on :)')
    while True:
        await ws.send_privmsg(bot.initial_channels[0], f'/me {agua}. {water}.')
        await asyncio.sleep(1800)

コード例 #24
0
ファイル: config.py プロジェクト: thomas-j-sell/teaja-bot
import os, sys
from twitchio.ext import commands


# parse arguments to decide which bot to boot and where to connect it
# selects different sets of environment varialbes and commands
if(len(sys.argv) > 1):
    if(sys.argv[1] == 'teaja'):
        print('booting teaja_bot')
        env_prefix = 'TEAJA_'
    elif(sys.argv[1] == 'celery'):
        print('booting celery_bot')
        env_prefix = 'CELERY_'
    elif(sys.argv[1] == 'soda'):
        print('booting soda_bot')
        env_prefix = 'SODA_'
    else:
        print(f"{sys.argv[1]} is not a valid bot. Booting teaja_bot")

# set up the bot
bot = commands.Bot(
    irc_token=os.environ[f"{env_prefix}TMI_TOKEN"],
    client_id=os.environ[f"{env_prefix}CLIENT_ID"],
    nick=os.environ[f"{env_prefix}BOT_NICK"],
    prefix=os.environ[f"{env_prefix}BOT_PREFIX"],
    initial_channels=[os.environ[f"{env_prefix}CHANNEL"]]
)
コード例 #25
0
ファイル: WagerBot.py プロジェクト: Korpip/wagerbot-twitch
#wagerbot.py made using https://www.richwerks.com/index.php/2019/beginner-twitch-chatbot-using-python/
from twitchio.ext import commands
import random
from config import *

bot = commands.Bot(irc_token=TMI_TOKEN,
                   client_id=CLIENT_ID,
                   nick=BOT_NICK,
                   prefix=BOT_PREFIX,
                   initial_channels=CHANNEL)
bookiename = 'pipsname'
openwagers = {}
confirmedwagers = {}
wagersloss = {}
wagerswon = {}
settings = {
    "userlimit":
    0,  # 0 = Everyone can play, 1 = subscribed only, 2 = only mods can play
    "minbet": "20",
    "currency": "USD"
}


@bot.event
async def event_ready():
    print(f"{BOT_NICK} is online!")
    ws = bot._ws


@bot.event
async def event_message(ctx):
コード例 #26
0
from twitchio.ext import commands

bot = commands.Bot(
    irc_token=
    'oauth:',  #填入你的oauth, 形式為"oauth:1a2b..." https://twitchapps.com/tmi/
    client_id='',  #填入註冊應用給的clien id  https://dev.twitch.tv/console/apps
    nick='kaneyxx',  #隨意
    prefix='!!',  #純掛網可以不用改
)


@bot.event
async def event_ready():
    login_list = []
    print(f'Ready | {bot.nick}')
    language_choice = input("language(N for pass): ")
    if language_choice == "N":
        language_choice = None
    game_choice = input("game_id(N for pass): ")
    if game_choice == "N":
        game_choice = None
    limit_choice = input("limit(1~100): ")
    data = await bot.get_streams(language=None,
                                 game_id=game_choice,
                                 limit=int(limit_choice))
    for i in data:
        id = i['user_id']
        names = await bot.get_users(id)
        login_list.append(names[0][1])
        # print(login_list)
    await bot.join_channels(login_list)
コード例 #27
0
import os

from twitchio.ext import commands
from pynput.keyboard import Key, Controller
import time
from config import irc_token, client_id
from util import queue_match_replay, get_queue, is_match_id

# Channels is the initial channels to join, this could be a list, tuple or callable
bot = commands.Bot(
    irc_token=irc_token,
    client_id=client_id,
    nick='aiarenastream',
    prefix='!',
    initial_channels=['#aiarenastream']
)


# Register an event with the bot
@bot.event
async def event_ready():
    print(f'Ready | {bot.nick}')


@bot.event
async def event_message(message):
    print(message.content)

    # If you override event_message you will need to handle_commands for commands to work.
    await bot.handle_commands(message)
コード例 #28
0
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):
    print(message.content)

    # If you override event_message you will need to handle_commands for commands to work.
コード例 #29
0
from time import sleep
from twitchio.ext import commands
import json
import helpers
import markov
import random

# Pull in the config json file and parse it into a dict
config_txtfile = open("config/config_secret.json", "rt+")
config = json.load(config_txtfile)
config_txtfile.close()

# Start the bot
twbot = commands.Bot(irc_token=config["twitch_irc_token"],
                     client_id=config["twitch_client_id"],
                     nick=config["twitch_bot_username"],
                     prefix=config["twitch_bot_prefix"],
                     initial_channels=config["twitch_initial_channels"])
m = markov.MarkovChainer(2)
helpers.markov_startup(m)


# bot commands below this line
@twbot.event
async def event_ready():
    print("bot ready......")
    ws = twbot._ws
    await ws.send_privmsg(config["twitch_initial_channels"][0],
                          f"/me has Logged In. Howdy gamers.")
    return
コード例 #30
0
from twitchio.ext import commands
import os
from discord import DISCORD_DIC
import re
import random
import json

bot = commands.Bot(
    # 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'], "gd_gurt", 'cee_bee_eff', "scorpionsen",
        "strawhat_deku", "alexandralynne", 'PancakeDAWGz', "strike_storm",
        "TallestThomas", "toogoodmules", "UsujioTarako"
    ])


@bot.command(name='test')
async def test(context):
    await context.send("First Try!")


@bot.command(name='race')
async def race(context):
    with open("runners.json") as _file:
        runners = json.load(_file)
        message = " | ".join([
            f"{i}" for i in runners