Exemplo n.º 1
0
 def cinema(status):
     account = status["account"]
     content = Re1.text(status["content"])
     gameIn = ("(劇場|げきじょう|[Cc]inema|シネマ)(ゲーム|げーむ)[::]"+
               "<br />【(.+)】<br />起[::](.+)<br />承[::](.+)<br />転[::](.+)<br />結[::](.+)")
     gameOut = "(劇場|げきじょう|[Cc]inema|シネマ)(ゲーム|げーむ)"+".*(ひとつ|おねが[いひ]|お願[いひ]|[11一]つ)"
     if re.compile(gameIn).search(content):
         print("○hitしました♪")
         word = re.search(gameIn+"<br />.*", str(content))
         sekuhara = bot.block01(status)
         if sekuhara:
             bot.rets(5, "٩(๑`^´๑)۶えっちなのはよくない!!!!", "public")
         else:
             Title = word.group(3)
             Ki = word.group(4)
             Sho = word.group(5)
             Ten = word.group(6)
             Kets = word.group(7)
             if len(Ki) > 80 or len(Sho) > 80 or len(Ten) > 80 or len(Kets) > 80 or len(Title) > 60:
                 bot.rets(5, "٩(๑`^´๑)۶長い!!!!!!", "public")
                 pass
             else:
                 f = codecs.open('game\\cinema_word.txt', 'a', 'UTF-8')
                 f.write(Title+">>"+Ki+">>"+Sho+">>"+Ten+">>"+Kets+">>"+account["acct"]+"\r\n" )
                 f.close()
                 v = threading.Timer(5, game.fav, [status["id"]])
                 v.start()
                 print("◆ 成功しました(∩´∀`)∩ ◆")
         return
     elif re.compile("ももな.*"+gameOut).search(content):
         if account["acct"] != "JC":
             f = codecs.open('game\\cinema_word.txt', 'r', 'utf-8')
             word1 = []
             for x in f:
                 word1.append(x.rstrip("\r\n").replace('\\n', '\n'))
             f.close()
             m = len(word1)
             word2 = []
             name = []
             for x in range(5):
                 s = random.randint(0, m-1)
                 word2.append((word1[s]).split('>>'))
             c0 = word2[0]
             c1 = word2[1]
             c2 = word2[2]
             c3 = word2[3]
             c4 = word2[4]
             c5 = [c0[5],c1[5],c2[5],c3[5],c4[5]]
             cast = list(set(c5[1:]))
             toot_now = ("【タイトル】\n"+unesc(c0[0])+"\n\n【あらすじ】\n"+unesc(c1[1])+
                         "\n"+unesc(c2[2])+"\n"+unesc(c3[3])+"\n"+unesc(c4[4])+"\n\n"
                         "【スタッフ】\n監督::@"+c0[5]+":\n主演キャスト::@"+str("::@".join(cast)))+ ":\n#劇場げーむ"
             spo = ":@" + account["acct"] + ":さんに上映開始のお知らせ"
             return bot.rets(6, toot_now, "public", None, spo)
Exemplo n.º 2
0
 def on_notification(self, notification):
     try:
         print("===通知が来ました===", "タイプ:" + str(notification["type"]))
         if notification["type"] == "mention":
             status = notification["status"]
             account = status["account"]
             mentions = status["mentions"]
             content = unesc(Re1.text(status["content"]))
             log = threading.Thread(Log(status).read())
             log.run()
             men = threading.Thread(JC.MEN(status))
             men.run()
             bot.thank(account, 64)  # 好感度が上がります
         elif notification["type"] == "favourite":
             account = notification["account"]
             non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1),
                                         0xfffd)
             print(
                 str(account["display_name"]).translate(non_bmp_map) + "@" +
                 str(account["acct"]) + "からニコってくれたよ₍₍ ◝(●˙꒳˙●)◜ ₎₎")
             bot.thank(account, 32)  # 好感度が上がります
         pass
     except Exception as e:
         print("エラー情報\n" + traceback.format_exc())
         with open('error.log', 'a') as f:
             traceback.print_exc(file=f)
         pass
     print("   ")
Exemplo n.º 3
0
 def __init__(self, status):
     self.account = status["account"]
     self.mentions = status["mentions"]
     self.content = Re1.text(status["content"])
     self.content = unesc(self.content)
     self.non_bmp_map = Re1.non_bmp_map()
     self.visibility = status["visibility"]
 def on_update(self, status):
     try:
         account = status["account"]
         path = '\\thank\\' + account["acct"] + '.txt'
         if os.path.exists(path):
             f = open(
                 os.path.abspath(os.path.dirname(__file__)) + path, 'r')
             x = f.read()
             f.close()
         else:
             x = 0
         if int(x) >= -10:
             mentions = Re1.text(status["mentions"])
             content = unesc(Re1.text(status["content"]))
             non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1),
                                         0x0000)
             """
             print((re.sub("<p>|</p>", "", str(account["display_name"]).translate(non_bmp_map)+ "@" + str(account["acct"]).translate(non_bmp_map)))) 
             print(content.translate(non_bmp_map))
             print(mentions.translate(non_bmp_map))
             print("   ")
             """
             del_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1),
                                     0x0000)
             text = (re.sub('\fffd|@.+ |https://.+($| )', '', str(content)))
             f = codecs.open('log\\' + 'log_' + nowing + '.txt', 'a',
                             'UTF-8')
             f.write(
                 unesc(
                     re.sub('<br />', '\\n', str(text)) + ',<acct="' +
                     account["acct"] + '">\r\n'))
             f.close()
     except:
         print("エラー情報\n" + traceback.format_exc())
         with open('error_03.log', 'a') as f:
             traceback.print_exc(file=f)
         pass
Exemplo n.º 5
0
 def text(text):
     text = re.sub('<br />', '\n', str(text))
     text = re.sub(
         '<p>|</p>|<a.+"tag">|<a.+"_blank">|<a.+mention">|<'
         'span>|</span>|</a>|<span class="[a-z-]+">', "", text)
     return unesc(text, {"&apos;": "'", '&quot;': '"'})
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def senryu(status):
     account = status["account"]
     content = Re1.text(status["content"])
     if account["acct"] == "twotwo":
         if re.compile("トゥートゥートゥートゥ[::]<br />(.+)<br />(.+)<br />(.+)").search(content):
             poes = re.search("(トゥートゥー)(トhuゥートゥ)[::]<br />(.+)<br />(.+)<br />(.+)", str(content))
             sen1 = poes.group(3)
             sen2 = poes.group(4)
             sen3 = poes.group(5)
             if len(sen1) > 6 or len(sen2) > 8 or len(sen3) > 6:
                 pass
             else:
                 f = codecs.open('game\\senryu_word.txt', 'a', 'UTF-8')
                 f.write(unesc(sen1) + ">>>" + unesc(sen2) + ">>>" +
                         unesc(sen3) + ">>>" + account["acct"] + "\r\n" )
                 f.close()
                 v = threading.Timer(5, game.fav, [status["id"]])
                 v.start()
         elif re.compile("トゥトゥトゥ-トゥートゥ!").search(content):
             f = codecs.open('game\\senryu_word.txt', 'r', 'utf-8')
             word1 = []
             for x in f:
                 word1.append(x.rstrip("\r\n").replace('\\n', '\n'))
             f.close()
             m = len(word1)
             word2 = []
             for x in range(4):
                 s = random.randint(0, m-1)
                 word2.append((word1[s]).split('>>>'))
             h0 = word2[0]
             h1 = word2[1]
             h2 = word2[2]
             h3 = word2[3]
             toot_now = (h0[0] + "\n" + h1[1] + "\n" + h2[2] +"\n(作者::@" +
                         h3[3] + ":)\n:@" + account["acct"] +":トゥートゥトゥトゥートゥ❤\n#川柳げーむ")
             g_vis = "public"
             bot.rets(6, toot_now, g_vis)
     else:
         if re.compile("(せんりゅう|川柳)(ゲーム|げーむ)[::]<br />(.+)<br />(.+)<br />(.+)").search(content):
             poes = re.search("(せんりゅう|川柳)(ゲーム|げーむ)[::]<br />(.+)<br />(.+)<br />(.+)", str(content))
             sen1 = poes.group(3)
             sen2 = poes.group(4)
             sen3 = poes.group(5)
             sekuhara = bot.block01(status)
             if sekuhara:
                 toot_now = "٩(๑`^´๑)۶えっちなのはよくない!!!!"
                 g_vis = "public"
                 bot.rets(5, toot_now, g_vis)
             if len(sen1) > 6 or len(sen2) > 8 or len(sen3) > 6:
                 pass
             else:
                 f = codecs.open('game\\senryu_word.txt', 'a', 'UTF-8')
                 f.write(str(sen1) + ">>>" + str(sen2) + ">>>" +
                         str(sen3) + ">>>" + account["acct"] + "\r\n" )
                 f.close()
                 v = threading.Timer(5, game.fav, [status["id"]])
                 v.start()
         elif re.compile("ももな.*(せんりゅう|川柳)(ゲーム|げーむ).*(一句|ひとつ|おねがい|お願い|一つ|1つ)").search(content):
             if account["acct"] != "JC":
                 f = codecs.open('game\\senryu_word.txt', 'r', 'utf-8')
                 word1 = []
                 for x in f:
                     word1.append(x.rstrip("\r\n").replace('\\n', '\n'))
                 f.close()
                 m = len(word1)
                 word2 = []
                 for x in range(4):
                     s = random.randint(0, m-1)
                     word2.append((word1[s]).split('>>>'))
                 h0 = word2[0]
                 h1 = word2[1]
                 h2 = word2[2]
                 h3 = word2[3]
                 toot_now = (h0[0] + "\n" + h1[1] + "\n" + h2[2] + "\n(作者::@" +
                             h3[3] + ":)\n:@" + account["acct"] +":からのリクエストでした❤\n#川柳げーむ")
                 g_vis = "public"
                 bot.rets(6, toot_now, g_vis)
     pass
Exemplo n.º 8
0
 def poem(status):
     account = status["account"]
     content = Re1.text(status["content"])
     if account["acct"] == "twotwo":
         if re.compile("トゥトゥトゥトゥートゥ[::]").search(content):
             poes = re.search("(トゥトゥトゥ)(トゥートゥ)[::]<br />(.*)", str(content))
             Poe = poes.group(3)
             if len(content) > 60:
                 toot_now = "٩(๑`^´๑)۶トゥトゥ!!!!!!"
                 g_vis = "public"
                 bot.rets(5, toot_now, g_vis)
             else:
                 Poe = re.sub("<br />", "\\n", Poe)
                 f = codecs.open('game\\poem_word.txt', 'a', 'UTF-8')
                 f.write(str(Poe) + " &,@" + account["acct"] + "\r\n" )
                 f.close()
                 v = threading.Timer(5, game.fav, [status["id"]])
                 v.start()
         elif re.compile("トゥトゥトゥトゥートゥトゥ!").search(content):
             f = codecs.open('game\\poem_word.txt', 'r', 'utf-8')
             word1 = []
             for x in f:
                 word1.append(x.rstrip("\r\n").replace('\\n', '\n'))
             f.close()
             m = len(word1)
             word2 = []
             for x in range(5):
                 s = random.randint(0, m-1)
                 word2.append((word1[s]).split(' &,@'))
             poe0 = unesc(word2[0])
             poe1 = unesc(word2[1])
             poe2 = unesc(word2[2])
             poe3 = unesc(word2[3])
             poe4 = unesc(word2[4])
             toot_now = poe0[0] + "\n" + poe1[0] + "\n" + poe2[0] + "\n" + poe3[
                 0] + "\n" + poe4[0] + "\n(by:@" + poe0[1] + ":-:@" + poe1[1] + ":-:@" + poe2[
                     1] + ":-:@" + poe3[1] + ":-:@"+poe4[1] + ":)\n#ぽえむげーむ"
             g_vis = "public"
             spo = ":@" + account["acct"] + ":トゥートゥー♪♪"
             bot.rets(6, toot_now, g_vis, None, spo)
     else:
         if re.compile("(ぽえむ|ポエム)(ゲーム|げーむ)[::]").search(content):
             poes = re.search("(ぽえむ|ポエム)(ゲーム|げーむ)[::]<br />(.*)", str(content))
             Poe = poes.group(3)
             Poe = unesc(Poe)
             sekuhara = bot.block01(status)
             if sekuhara:
                 toot_now = "٩(๑`^´๑)۶えっちなのはよくない!!!!"
                 g_vis = "public"
                 bot.rets(5, toot_now, g_vis)
             if len(content) > 60:
                 toot_now = "٩(๑`^´๑)۶長い!!!!!!"
                 g_vis = "public"
                 bot.rets(5, toot_now, g_vis)
             else:
                 Poe = re.sub("<br />", "\\\\n", Poe)
                 f = codecs.open('game\\poem_word.txt', 'a', 'UTF-8')
                 f.write(str(Poe) + " &,@" + account["acct"] + "\r\n" )
                 f.close()
                 v = threading.Timer(5, game.fav, [status["id"]])
                 v.start()
         elif re.compile("ももな.*(ぽえむ|ポエム)(ゲーム|げーむ).*(ひとつ|おねがい|お願い|1つ|一つ)").search(content):
             if account["acct"] != "JC":
                 f = codecs.open('game\\poem_word.txt', 'r', 'utf-8')
                 word1 = []
                 for x in f:
                     word1.append(x.rstrip("\r\n").replace('\\n', '\n'))
                 f.close()
                 m = len(word1)
                 word2 = []
                 for x in range(5):
                     s = random.randint(0, m-1)
                     word2.append((word1[s]).split(' &,@'))
                 poe0 = word2[0]
                 poe1 = word2[1]
                 poe2 = word2[2]
                 poe3 = word2[3]
                 poe4 = word2[4]
                 toot_now = poe0[0] + "\n" + poe1[0] + "\n" + poe2[0] + "\n" + poe3[
                     0] + "\n" + poe4[0] + "\n(by:@" + poe0[1] + ":-:@" + poe1[1] + ":-:@" + poe2[
                         1] + ":-:@" + poe3[1] + ":-:@"+poe4[1] + ":)\n#ぽえむげーむ"
                 g_vis = "public"
                 spo = ":@" + account["acct"] + ":にぽえむ♪♪"
                 bot.rets(6, toot_now, g_vis, None, spo)
Exemplo n.º 9
0
 def on_notification(self, notification):
     try:
         print("===通知が来ました===")
         non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
         if notification["type"] == "mention":
             status = notification["status"]
             account = status["account"]
             mentions = status["mentions"]
             content = unesc(Re1.text(status["content"]))
             log = threading.Thread(Log(status).read())
             log.run()
             bot.thank(account, 64)
             if mentions:
                 if re.compile("おは|おあひょ").search(content):
                     toot_now = "@" + str(account["acct"]) + " " + "(*'∀'人)おあひょーーーー♪"
                     g_vis = status["visibility"]
                     bot.rets(8, toot_now, g_vis, status['id'])
                 elif re.compile("こんに").search(content):
                     toot_now = "@" + str(account["acct"]) + " " + "(*'∀'人)こんにちはーーーー♪"
                     g_vis = status["visibility"]
                     bot.rets(8, toot_now, g_vis, status['id'])
                 elif re.compile("こんば").search(content):
                     toot_now = "@" + str(account["acct"]) + " " + "(*'∀'人)こんばんはーーーー♪"
                     g_vis = status["visibility"]
                     bot.rets(8, toot_now, g_vis, status['id'])
                 elif re.compile("\d+[dD]\d+").search(content):
                     inp = (re.sub("<span class(.+)</span></a></span>|<p>|</p>", "",
                                   str(status['content']).translate(non_bmp_map)))
                     result = game.dice(inp)
                     g_vis = status["visibility"]
                     toot_now = ":@" + str(account["acct"]) + ": @" + account["acct"] + "\n" + result
                     bot.rets(5, toot_now, g_vis, status['id'])
                 elif re.compile("(アラーム|[Aa][Rr][Aa][Mm])(\d+)").search(content):
                     non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0xfffd)
                     content = str(status['content']).translate(non_bmp_map)
                     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))
                     if re.compile("(アラーム|[Aa][Rr][Aa][Mm])(.*)「(.*)」").search(content):
                         mes = re.search("「(.*)」", content)
                         toot_now = ("@" + account["acct"] + " " + "(*'∀'人)時間だよーー♪♪\n"
                                     "「" + mes.group(1) + "」")
                     else:
                         toot_now = "@" + account["acct"] + " " + "(*'∀'人)時間だよーー♪♪"
                     g_vis = status["visibility"]
                     in_reply_to_id = status["id"]
                     t = threading.Timer(sec, bot.toot, [toot_now, g_vis, status['id']])
                     t.start()
                     #bot.rets(sec,toot_now, g_vis,status['id'] )
                 elif re.compile(
                                 "(フォロー|follow)(して|く[うぅー]*ださ[あぁー]*い|お願[あぁー]*い|"
                                 "おねが[あぁー]*い|頼[むみ]|たの[むみ]|ぷりーず|プリーズ|please)").search(
                                 content):
                     mastodon.account_follow(account["id"])
                     toot_now = "@" + account["acct"] + " " + "(*'∀'人)フォローしました♪♪"
                     g_vis = status["visibility"]
                     in_reply_to_id = status["id"]
                     bot.rets(8, toot_now, g_vis, status['id'])
                 elif re.compile("(こそこそ)<br />(.+)").search(content):  # 悪用されないように変えてます
                     if status["visibility"] == "direct":
                         print("○受け取りました")
                         com = re.search("(こそこそ).*<br />(.+)", str(content))
                         messe = com.group(2)
                         toot_now = messe
                         g_vis = "public"
                         bot.rets(1, toot_now, g_vis)
                 elif re.compile("連想ゲーム開始").search(content):
                     if rensou_time:
                         toot_now = ("@" + account["acct"] + " "
                                     + "(*'∀'人)ごめんね、今開催中なの♪♪")
                         g_vis = status["visibility"]
                         in_reply_to_id = status["id"]
                         bot.rets(5, toot_now, g_vis, status['id'])
                     else:
                         t = threading.Timer(0, game.rensou)
                         t.start()
                         rensou_time = True
                 elif account["acct"] == "twotwo":
                     if re.compile("").search(content):
                         pass
                 else:
                     pass
             v = threading.Timer(5, bot.fav_now,[status["id"]])
             v.start()
         elif notification["type"] == "favourite":
             account = notification["account"]
             print(str(account["display_name"]).translate(non_bmp_map) + "@" + str(
                 account["acct"]) + "からニコってくれたよ₍₍ ◝(●˙꒳˙●)◜ ₎₎")
             print()
             bot.thank(account, 32)
             print("---")
         elif notification["type"] == "reblog":
             account = notification["account"]
             print(str(account["display_name"]).translate(non_bmp_map) + "@" + str(
                 account["acct"]) + "がブーストしてくれたよ(๑˃́ꇴ˂̀๑)")
             print()
             bot.thank(account, 32)
             print("---")
         pass
     except Exception as e:
         print("エラー情報【USER】\n" + traceback.format_exc())
         with open('error.log', 'a') as f:
             traceback.print_exc(file=f)
         pass