Esempio n. 1
0
    def y(status):
        content = conv.text(status["content"])
        account = status["account"]
        if count.y == True:
            if re.compile("こおり.*ねじりサーチ.*[OoOo][FfFf][FfFf]").search(
                    status['content']):
                if account["acct"] == "y" or account["acct"] == "0":
                    count.y = False
                    return toot.toot_res("ねじりサーチ、終了しました。", sec=3)
            elif re.compile("ねじりわさび|ねじり|わさび|ねじわさ|[Kk]nzk[Aa]pp|神崎丼アプリ")\
                    .search(status['content']):  # 抜き出し
                if account["acct"] is not "y" or account[
                        "acct"] is not "1":  # 自分とねじりわさびさんを感知しないように
                    yuzu = re.search(
                        "(ねじりわさび|ねじり|わさび|ねじわさ|[Kk]nzk[Aa]pp|神崎丼アプリ)", content)
                    post = ("@y {}を感知しました。").format(str(yuzu.group(1)))
                    return toot.toot(mastodon, post, "direct", status["id"],
                                     None, None)

        else:
            if account["acct"] == "y" or account["acct"] == "0":
                if re.compile("こおり.*ねじりサーチ.*[OoOo][NnNn]").search(
                        status['content']):
                    count.y = True
                    return toot.toot_res("ねじりサーチ、スタートです!", sec=3)
Esempio n. 2
0
 def res03(status):  # 該当する文字があるとメディアをアップロードしてトゥートしてくれます。
     content = conv.text(status["content"])
     with codecs.open('bot\\reply_media.csv', 'r', "UTF-8", "ignore") as f:
         for row in csv.reader(f):
             if re.compile(row[2]).search(re.sub("<p>|</p>", "", content)):
                 print("◇Hit")
                 l = []
                 with codecs.open('bot\\res\\' + row[1] + '.txt', 'r',
                                  'utf-8') as f:
                     for x in f:
                         l.append(
                             x.rstrip("\r\n|\ufeff").replace('\\n', '\n'))
                 m = len(l)
                 s = random.randint(1, m)
                 post = l[s - 1]
                 with codecs.open('bot\\res_med\\' + row[3] + '.txt', 'r',
                                  'utf-8') as f:
                     j = []
                     for x in f:
                         j.append(x.rstrip("\r\n").replace('\\n', '\n'))
                 xxx = re.sub("(.*)\.", "", j[s - 1])
                 media_files = [
                     mastodon.media_post("bot\\media\\" + j[s - 1])
                 ]
                 print("◇メディア選択しました")
                 print(j[s - 1])
                 toot.toot_res(mastodon, post, "public", None, media_files,
                               None, int(row[0]))
                 return
Esempio n. 3
0
def __init__(self):
    self.status = status
    self.content = conv.text(status["content"])
    self.account = status["account"]
    self.g_vis = "public"
    self.in_reply_to_id = None
    self.media_files = None
Esempio n. 4
0
 def res05(status):
     content = conv.text(status["content"])
     if re.compile("こおり(.*)\d+[dD]\d+").search(content):
         print("○hitしました♪")
         account = status["account"]
         post = "@" + str(account["acct"]) + "\n" + game.dice(content)
         toot.toot_res(mastodon, post, status["visibility"], None, None,
                       "サイコロ振りますね。", 3)
Esempio n. 5
0
 def res02(status):  # 該当するセリフからランダムtootが選ばれてトゥートします。
     content = conv.text(status["content"])
     with codecs.open('bot\\reply_random.csv', 'r', "UTF-8", "ignore") as f:
         for row in csv.reader(f):
             if re.compile(row[2]).search(re.sub("<p>|</p>", "", content)):
                 print("◇Hit")
                 post = conv.rand_w('bot\\res\\' + row[1] + '.txt')
                 toot.toot_res(mastodon, post, "public", sec=int(row[0]))
                 return
Esempio n. 6
0
 def omikuji(status):
     account = status["account"]
     content = conv.text(status["content"])
     koori = ('こおり(.*)みくじ(.*)(おねが(.*)い|お願(.*)い|[引ひ]([きく]|いて)|'
              'や[りる]|ください|ちょうだい|(宜|よろ)しく|ひとつ|し(て|たい))')
     if re.compile(koori).search(content):
         if account['acct'] != "1":
             post = omikuji(status)
             if post:
                 return toot.toot_res(mastodon, post, "public", sec=6)
Esempio n. 7
0
 def land(status):
     content = conv.text(status["content"])
     if re.compile("(.+)(開園)$").search(content):
         print("◇Hit")
         acc = status['account']
         if acc['acct'] != "1":
             com = re.search("(.+)(開園)", content)
             post = re.sub('<span class="">', '', com.group(1)) + "閉園"
             ba = threading.Timer(5, toot.toot,
                                  [post, "public", None, None, None])
             ba.start()
Esempio n. 8
0
 def res01(status):  # お返事関数シンプル版。
     content = conv.text(status["content"])
     with codecs.open('bot\\reply.csv', 'r', "UTF-8", "ignore") as f:
         for row in csv.reader(f):
             if re.compile(row[2]).search(content):
                 print("◇Hit")
                 post = row[1].replace('\\n', '\n')
                 toot.toot_res(
                     mastodon,
                     post,
                     "public",
                 )
Esempio n. 9
0
 def EFB(status):
     content = conv.text(status["content"])
     account = status["account"]
     if account["acct"] != "1":
         if re.compile("エターナルフォースブリザード|えたーなるふぉーすぶりざーど").search(content):
             fav = status["id"]
             post = "@" + account["acct"] + " エターナルフォースブリザード……!!"
             in_reply_to_id = status["id"]
             t1 = threading.Timer(
                 3, toot.toot, [post, "public", in_reply_to_id, None, None])
             t1.start()
             t2 = threading.Timer(3, bot.BellBaku, [fav])
             t2.start()
Esempio n. 10
0
 def adana(status):
     account = status["account"]
     content = conv.text(status["content"])
     if re.compile("こおり.*あだ名「(.+)」って呼んで").search(content):
         print("○hitしました♪")
         ad = re.search("こおり.*あだ名「(.+)」って呼んで", content)
         adan = ad.group(1)
         with codecs.open(
                 'data\\dic_time\\adana\\' + account["acct"] + '.txt', 'w',
                 'UTF-8') as f:
             f.write(adan)
         post = "分かりました。\n次からは「{}」ってお呼びしますね。".format(adan)
         toot.toot_res(mastodon, post, status["visibility"], sec=4)
Esempio n. 11
0
 def aram(status):
     content = conv.text(status["content"])
     account = status['account']
     com = re.search("(アラーム|[Aa][Rr][Aa][Mm])(\d+)([秒分]?)", content)
     sec = int(com.group(2))
     clo = com.group(3)
     if clo == "分":
         sec = sec * 60
     else:
         pass
     print(str(sec))
     post = ("@{}\n" + "指定した時間が来たのでお知らせします。").format(account["acct"])
     g_vis = status["visibility"]
     return post, sec
Esempio n. 12
0
 def minder(status):
     account = status["account"]
     content = conv.text(status["content"])
     path = "./minder" + account["acct"]
     if os.path.exists(path):
         if re.compile("こおり.*(ノルマ|minder|マインダー|伝言)「(.+)」").search(
                 status['content']):
             print("○マインダーを受け付けます。")
             pass
             # 記憶させる装置
             # ad = re.search("こおり.*(ノルマ|minder|マインダー|伝言)「(.+)」", content)
             # adan = ad.group(1)
             # with codecs.open('data\\dic_time\\minder\\' + account["acct"] + '.txt', 'w', 'UTF-8') as f:
             #    f.write(adan)
             # 教えるするようにする装置
             # お知らせするようにする装置
         pass
     pass
Esempio n. 13
0
 def check03(status):  # お休みする人を記憶
     account = status["account"]
     content = conv.text(status["content"])
     try:
         with codecs.open(
                 'data\\dic_time\\adana\\' + account["acct"] + '.txt', 'r',
                 'UTF-8') as f:
             display_name = f.read()
     except:
         if account['display_name'] == "":
             display_name = account['acct'] + "さん"
         else:
             display_name = re.sub("@[a-zA-Z0-9]+|\s", "",
                                   account['display_name']) + "さん"
     if account["acct"] != "1":  # 一人遊びで挨拶しないようにっするための処置
         if re.compile("[寝ね](ます|る|マス)([よかぞね…。うぅー~!]*)$|"
                       "[寝ね](ます|る|マス)(.*)[ぽお]や[すし]").search(content):
             print("◇Hit")
             post = display_name + "、" + conv.rand_w('bot\\time\\oya.txt')
             toot.toot_res(mastodon, post, "public", sec=5)
             with codecs.open('data\\oyasumi\\' + account["acct"] + '.txt',
                              'w', 'UTF-8') as f:
                 f.write("good_night")
             try:
                 with codecs.open(
                         'data\\dic_time\\' + account["acct"] + '.json',
                         'r', 'UTF-8') as f:
                     zzz = {}
                     zzz = json.load(f)
             except:
                 zzz = {}
             with codecs.open(
                     'data\\dic_time\\' + account["acct"] + '.json', 'w',
                     'UTF-8') as f:
                 zzz.update({"sleep": str(status["created_at"])})
                 json.dump(zzz, f)
             print("◇寝る人を記憶しました")
Esempio n. 14
0
 def __init__(self, status):
     self.account = status["account"]
     self.mentions = status["mentions"]
     self.content = unesc(conv.text(status["content"]))
     self.non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1),
                                      0xfffd)
Esempio n. 15
0
 def mention(status):
     account = status["account"]
     mentions = conv.text(status["mentions"])
     content = conv.text(status["content"])
     media_files = None
     if account['acct'] != "1":
         if account['acct'] != "0":
             if re.compile("こおり(.*)([落]ちて|シャットダウン|やすんで|休んで)").search(
                     content):
                 logout()
         elif re.compile("こおり(.*)(ネイティオ|ねいてぃお)(.*)鳴").search(content):
             post = "@" + str(
                 account["acct"]) + " " + "ネイティオさん、私が起きてから" + str(
                     count.twotwo) + "回鳴きました。"
             g_vis = status["visibility"]
             sec = 5
         elif re.compile("トゥートゥートゥー?|トゥートゥートゥー?").search(content):
             post = "@" + str(account["acct"]) + " トゥートゥー、トゥートゥトゥトゥ「" + str(
                 count.twotwo) + "」"
             g_vis = status["visibility"]
             sec = 5
         elif re.compile("\d+[dD]\d+").search(content):
             coro = (re.sub("@1", "", str(content)))
             post = "@" + str(account["acct"]) + "\n" + game.dice(coro)
             g_vis = status["visibility"]
             sec = 5
         elif re.compile("(アラーム|[Aa][Rr][Aa][Mm])(\d+)").search(content):
             post, sec = game.aram(status)
             g_vis = status["visibility"]
         elif re.compile(
                 'みくじ(.*)(おねが(.*)い|お願(.*)い|[引ひ]([きく]|いて)|や[りる]|'
                 'ください|ちょうだい|(宜|よろ)しく|ひとつ|し(て|たい))').search(content):
             if account['acct'] != "1":
                 if re.compile(koori).search(content):
                     if account['acct'] != "1":
                         post = omikuji(status)
                 g_vis = status["visibility"]
                 sec = 5
         elif re.compile(
                 'たこ[焼や]き(.*)([焼や]いて|作って|つくって|['
                 '食た]べたい|おねがい|お願い|ちょ[うー]だい|[欲ほ]しい)').search(content):
             print("◇Hit")
             sleep(5)
             l = []
             with codecs.open('bot\\res\\takoyaki.txt', 'r', 'utf-8') as f:
                 for x in f:
                     l.append(x.rstrip("\r\n|\ufeff").replace('\\n', '\n'))
             m = len(l)
             s = random.randint(1, m)
             post = "@" + str(account["acct"]) + "\n" + l[s - 1]
             with codecs.open('bot\\res_med\\takoyaki.txt', 'r',
                              'utf-8') as f:
                 j = []
                 for x in f:
                     j.append(x.rstrip("\r\n").replace('\\n', '\n'))
             xxx = re.sub("(.*)\.", "", j[s - 1])
             media_files = [
                 mastodon.media_post("bot\\media\\" + j[s - 1],
                                     "image/" + xxx)
             ]
             print("◇メディア選択しました")
             print(j[s - 1])
             g_vis = "public"
             sec = 5
         elif re.compile('デバック|[dD][eE][vV]|でばっく').search(
                 content) and account['acct'] == "0":
             if re.compile('ON|on|おん|オン').search(content):
                 count.dev_mode = True
                 post = "@" + str(account["acct"]) + " " + "デバックモード始めます。"
             elif re.compile('OFF|off|おふ|オフ').search(content):
                 count.dev_mode = False
                 post = "@" + str(account["acct"]) + " " + "デバックモード終わります。"
             g_vis = status["visibility"]
             sec = 2
         else:
             global api_Bot
             url = "https://chatbot-api.userlocal.jp/api/chat"  # 人工知能APIサービス登録してお借りしてます。
             s = requests.session()
             mes = (re.sub("<p>|</p>", "", str(content)))
             params = {
                 'key': api_Bot,  # 登録するとAPIKeyがもらえますのでここに入れます。
                 'message': mes,
             }
             r = s.post(url, params=params)
             ans = json.loads(r.text)
             post = "@" + str(account["acct"]) + " " + ans["result"]
             g_vis = status["visibility"]
             sec = 5
         if post is not None:
             in_reply_to_id = status["id"]
             t = threading.Timer(
                 sec, toot.toot,
                 [post, g_vis, in_reply_to_id, media_files, None])
             t.start()
         else:
             pass