質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Pythonista

Pythonistaは、iOS上でPythonプログラミングができる開発アプリです。さらに、Pythonの関数・変数などを自動で補完する便利なコードエディタや、PythonスクリプトをiOS上で多様な形で機能させる各種機能も内包しています。

Q&A

0回答

257閲覧

UIをでボタンなどを使って設定できるようにしたい

zakorin

総合スコア0

Pythonista

Pythonistaは、iOS上でPythonプログラミングができる開発アプリです。さらに、Pythonの関数・変数などを自動で補完する便利なコードエディタや、PythonスクリプトをiOS上で多様な形で機能させる各種機能も内包しています。

0グッド

0クリップ

投稿2021/06/21 21:05

import notification
import clipboard
import keyboard
import datetime
import calendar
import tweepy
import base64
import json
import time
import glob
import os
import sys
import re
import random
import console

"""
---初期設定---

①コードの貼り付けができたら自身のTwitterID入力をします。

例 : ID が @Twitter_1234 の場合
TwitterID = "@XXXX" を
TwitterID = "@Twitter_1234" に変更

②右上の▷を押すと、数字が出てきます、
その数字と ①で書き込んだTwitterID の2つをDMで伝えてください。

③数字と引き換えにこちらがIDを渡しますので、AutoIDを35行目にコピーして貼り付けてください

"""

Twitter_ID = "@"

0000を消した後 貰ったIDを=の後にそのまま貼り付けてください

Auto_ID = 0000

"""

   ---使用設定部分---

パスツイ  21:30
ルーム番号 567

の場合
↓↓↓↓↓↓↓↓

pass_tweet_time = "30"
room_id = "5"

  このように下を書き換えます。 
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

"""

pass_tweet_time = "29"
room_id = "1862"

"""
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
⚠️以下書き換えると動作しなくなります
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
"""

flags = 0
flag = 0
password = ""

CK = b'MkwxMGgwWkdTQU9KOFV4amk3dEVSZzhxdg=='
CKS = b'VndsSW9KWnFmTzNYTkgzeWcxMGZaWnBERUZLNXhmTlJZbGltZFI1U2FVRXRVYWlZNU8='
AT = "1298991741651963913-BHfO45amr4jygNDRp800J5ZXR1mf0p"
ATS = "rxcIKtcmmBWbt32Tox4JirrpbZn9dpG5fEeIVM7ZDy5e5"

basenumber = "0123456789"

font_item = ["⓪①②③④⑤⑥⑦⑧⑨",
"⓿❶❷❸❹❺❻❼❽❾",
"0123456789",
"????????????????????????????????????????",]

itemlist1 = ["@[a-zA-Z0-9_]+",
"[0-9]{1,2}:[0-5][0-9]",
"[0-9]{1,2}時[0-59]分",
"([0-9]|[0-2][0-9])時",
"[0-5][0-9]分",
"[1-9]{1,2}/[0-9]{1,2}",]

itemlist2 = [" "," ",]

message = {
"no_update":"パスツイ取得中",
"code_notification":"この数字と入力したTwitterIDをDMで伝えてください:",
"copy_error":"Twitterリンクのコピー又はフルアクセスの許可をしてください",
"pass_notfound":"パスワードが取得できませんでした",
"waiting_passtweet":"からのパスツイ待機中... ",
"success":"ID認証成功",
"fail":"認証失敗:"
}

Xcode = ["\x207\x204\x208\x209\x400\x102",
"207\x200\x208\x209\x400\x109" ,
"207\x204\x208\x209\x400\x102" ,
"207\x204\x208\x209\x400\x102" ,]

"""
関数
"""
def login(CK,CKS,AT,ATS):
CK = base64.b64decode(CK.decode())
CKS = base64.b64decode(CKS.decode())
auth = tweepy.OAuthHandler(str(CK).split("'")[1],str(CKS).split("'")[1])
auth.set_access_token(AT,ATS)
API = tweepy.API(auth)
return API

def get_username():
user_name = clipboard.get()
if("https" in user_name):
user_name = user_name.split("/")
user_name = user_name[3].split("?")
user_name = user_name[0]
return user_name
else:
print(message["copy_error"])
sys.exit()

def ACencrtrpt(a):
c = str(a)
c = base64.b64encode(c.encode())
return c

def Test(c,d):
if c == d:
return True
else:
key = glob.glob("*.pwd")
key = key[0].split(".")[0]
print(message["code_notification"]+key)
sys.exit()

def check():
file = glob.glob("*.pwd")
i = 0
if not file:
key = int(random.uniform(1,99))*int(random.uniform(99,999))*int(random.uniform(1,9))
key = str(key)
with open(key+".pwd" , mode="w") as f:
f.write("")
notification.schedule(message["code_notification"]+key)
print(message["code_notification"]+key)
sys.exit()
else:
code = file[0].split(".")[0]
return code,i

def tweet_filter(Tweettext):
for i in range(10):
if(font_item[0][i] in Tweettext):
Tweettext = Tweettext.replace(font_item[0][i],basenumber[i])
for j in range(10):
if(font_item[1][j] in Tweettext):
Tweettext = Tweettext.replace(font_item[1][j],basenumber[j])
for k in range(10):
if(font_item[2][k] in Tweettext):
Tweettext = Tweettext.replace(font_item[2][k],basenumber[k])
for l in range(10):
if(font_item[3][l] in Tweettext):
Tweettext = Tweettext.replace(font_item[3][l],basenumber[l])
return Tweettext

def tweet_trim(tweet):
tweet = tweet_filter(tweet)
for i in itemlist1:
tweet = re.sub(i,"",tweet)
for j in itemlist2:
tweet = tweet.replace(j,"")
tweet = re.findall(r"\d+",tweet)
return tweet

def get_time_now():
now_time = datetime.datetime.now()
now_time = str(now_time).split(" ")[1]
now_time = now_time.split(":")
now_time_minute = now_time[1]
now_time_seconds = now_time[2].split(".")[0]
return now_time_minute,now_time_seconds

API = login(CK,CKS,AT,ATS)

user_name = get_username()

print("@"+user_name+message["waiting_passtweet"])

if(pass_tweet_time == "00"):
passTb = "59"
else:
passTb = str(int(pass_tweet_time)-1)

while True:
now_time_minute , now_time_seconds = get_time_now()
if(now_time_minute == passTb and now_time_seconds == "58"):
break
elif(now_time_minute == passTb and now_time_seconds == "59"):
break
elif(now_time_minute == pass_tweet_time):
break
time.sleep(0.01)

while True:
tweet = API.user_timeline(user_name,count = 1)
for i in tweet:
tweet = i.text
tweet_time = i.created_at

tweet_time = re.findall(r"\d+",str(tweet_time)) tweet_time_minute = tweet_time[4] tweet_time_second = tweet_time[5] if(pass_tweet_time == "00"): pass_tweet_time_ = "59" else: pass_tweet_time_ = str(int(pass_tweet_time)-1) if(len(pass_tweet_time_) == 1): pass_tweet_time_ = "0" + pass_tweet_time_ for i in range(57,60): if(pass_tweet_time_ == tweet_time_minute and str(i) == tweet_time_second): flag = 1 if(pass_tweet_time == tweet_time_minute): flag = 1 if(flag == 1): break #else: #console.clear() #print(message["no_update"]+" ["+str(datetime.datetime.now()).split(" ")[1]+"]") time.sleep(0.0000001)

tweet = tweet_trim(tweet)

if(room_id in tweet):
room_id_index = tweet.index(room_id)
if(room_id_index == 0):
password = str(tweet[1])
elif(room_id_index == 1):
password = str(tweet[0])
elif(len(tweet) >= 1):
password = str(tweet[0])
else:
password = tweet[0]

keyboard.insert_text(password)
keyboard.insert_text("\n")
notification.schedule(password)
print("password:"+password)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問