Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.02 KB | None | 0 0
  1. # https://www.thecodeship.com/patterns/guide-to-python-function-decorators/
  2. # https://pastebin.com/ba3tzQD9
  3. from typing import Any
  4. import os
  5. from twitchio.ext import commands
  6. import asyncio
  7.  
  8. # set up the bot
  9.  
  10. bot = commands.Bot(
  11.     irc_token=os.environ['TMI_TOKEN'],
  12.     client_id=os.environ['CLIENT_ID'],
  13.     nick=os.environ['BOT_NICK'],
  14.     prefix=os.environ['BOT_PREFIX'],
  15.     initial_channels=[os.environ['CHANNEL']]
  16.  
  17. )
  18.  
  19.  
  20. @bot.event
  21. async def event_ready():
  22.     'Called once when the bot goes online.'
  23.     print(f"{os.environ['BOT_NICK']} ist online!")
  24.     ws = bot._ws  # this is only needed to send messages within event_ready
  25.     await ws.send_privmsg(os.environ['CHANNEL'], f"/me ist online!")
  26.  
  27.  
  28. @bot.event
  29. async def event_message(ctx):
  30.     'Runs every time a message is sent in chat.'
  31.  
  32.     # make sure the bot ignores itself and the streamer
  33.     # if ctx.author.name.lower() == os.environ['BOT_NICK'].lower():
  34.     #   return
  35.  
  36.     await bot.handle_commands(ctx)
  37.     # await ctx.channel.send(ctx.content)
  38.  
  39.     if 'hallo' in ctx.content.lower():
  40.         await ctx.channel.send(f"Guten Tag, @{ctx.author.name}!")
  41.  
  42.     if 'cs' in ctx.content.lower():
  43.         await ctx.channel.send(f" 2.if")
  44.  
  45.     if 'hi' in ctx.content.lower():
  46.         test(ctx.test)
  47.  
  48.  
  49. @bot.command(name='test')
  50. async def test(ctx):
  51.     print('test')
  52.  
  53.  
  54. @bot.command(name='bsg')
  55. async def bsg(ctx):
  56.     await ctx.send(f" @{ctx.author.name} [Backseatgaming] - Beschreibt im allgemeinen jemanden, der aus der zweiten "
  57.                    f"Reihe (Backseat), "
  58.                    f"dem Spieler sagt was er machen soll, sowie den Spieler daran zu Erinnern, wenn er etwas "
  59.                    f"vergessen hat. - Der Ingame Charakter kennt kein Twitch und hat keine 200 Stimmen im Kopf, "
  60.                    f"die ihm sagen was er machen soll!")
  61.     print('bsg')
  62.  
  63.  
  64. @bot.command(name='zeit')
  65. async def zeit(ctx):
  66.     await ctx.send('Der 24h Stream läuft noch bis 14Uhr')
  67.     print('zeit')
  68.  
  69.  
  70. if __name__ == "__main__":
  71.     bot.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement