Pārlūkot izejas kodu

v1.0.2 - stop reactions being problematic by giving them a safe space

master
MrDetonia pirms 7 gadiem
vecāks
revīzija
b37b4561be
3 mainītis faili ar 21 papildinājumiem un 14 dzēšanām
  1. +2
    -12
      bot.py
  2. +1
    -1
      common.py
  3. +18
    -1
      helpers.py

+ 2
- 12
bot.py Parādīt failu

@@ -80,18 +80,8 @@ def on_message(msg):
fp.write('\n' + msg.content)
except PermissionError: pass

# TODO: dedicated reaction function
# someone noticed me! <3
if bool(re.search(r'\bmaki\b', msg.content, re.IGNORECASE)):
yield from client.add_reaction(msg, '\N{BLACK HEART SUIT}')

# butter
if bool(re.search(r'\bbutter\b', msg.content, re.IGNORECASE)):
yield from client.add_reaction(msg, '\N{PERSON WITH FOLDED HANDS}')

# egg
if bool(re.search(r'\begg\b', msg.content, re.IGNORECASE)):
yield from client.add_reaction(msg, '\N{AUBERGINE}')
# react to stuff
yield from makireacts(client, msg)

# check for commands
if msg.content.startswith(prefix):


+ 1
- 1
common.py Parādīt failu

@@ -13,7 +13,7 @@ import json


# bot version
version = "v1.0.1"
version = "v1.0.2"


# TODO: generate this on the fly and make it look acceptable


+ 18
- 1
helpers.py Parādīt failu

@@ -11,6 +11,7 @@ import asyncio
import discord
import logging
import datetime
import re

# LOCAL IMPORTS
from common import *
@@ -65,4 +66,20 @@ def discord_typing(client, message):
else:
break
else:
print('ERROR: Failed to send typing signal to discord after 5 attempts')
print('ERROR: Failed to send typing signal to discord after 5 attempts')


# Maki Reacts to...
@asyncio.coroutine
def makireacts(client, msg):
# TODO: track down the person(s) responsible for naming emoji
reactions = {
r"\bmaki\b": "\N{BLACK HEART SUIT}",
r"\bbutter\b": "\N{PERSON WITH FOLDED HANDS}",
r"\begg\b": "\N{AUBERGINE}",
r"\bproblematic\b": "\N{EYEGLASSES}",
}

for i in reactions:
if bool(re.search(i, msg.content, re.IGNORECASE)):
yield from client.add_reaction(msg, reactions[i])

Notiek ielāde…
Atcelt
Saglabāt