예제 #1
0
    def add_users(self, client: LINE, group_id: str, mid: str or list,
                  into: str, **kwg) -> bool:
        """
		use this method to insert some user to DataBase
		@client: class<linepy.LINE.client>
		@group_id: undefined mid of group as string
		@mid: undefined mid of user pass string or list
		@into: pass a specified role for user e.g: blacklist,whitelist whatever you want
		@kwg: pass another argument as dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            u = client.getContacts(mid)
            for i in u:
                data.add_users(mid=i.mid,
                               into=into,
                               name=i.displayName,
                               at_group=group_id,
                               globals=True)
        else:
            p = client.getContact(mid)
            data.add_users(mid=p.mid,
                           into=into,
                           name=p.displayName,
                           at_group=group_id,
                           globals=True)
        return True
예제 #2
0
    def add_group(self, client: LINE, mid: str or list, **kwg) -> bool:
        """
		Use this method to add Group to database
		@client: class<linepy.LINE.Client>
		@mid: undefined string of Group mid, pass a string or list
		@kwg: other argument for include to your db e.g: grop.name pass a dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            g = client.getGroups(mid)
            for i in g:
                data.add_group(i.mid,
                               name=i.name,
                               picture=self.img_url + i.pictureStatus,
                               create=g.createdTime,
                               creator=dict(id=i.creator.id,
                                            name=i.creator.displayName))
        else:
            g = client.getGroup(mid)
            data.add_group(mid,
                           name=g.name,
                           picture=self.img_url + g.pictureStatus,
                           create=g.createdTime,
                           creator=dict(id=g.creator.mid,
                                        name=g.creator.displayName))
        return True
예제 #3
0
	def __init__(self,
					token: str = None,
					email: str = None,
					passwd: str = None,
					):
		self.message_handlers: Union[list] = []
		self.list_bots: Union[list] = []
		
		if token and not passwd:
			self.line = LINE(token)
		if email and passwd:
			self.line = LINE(email, passwd)
		if not (token or email and passwd):
			self.line = LINE()
		
		self.poll = OEPoll(self.line)
예제 #4
0
class Main:
    def __init__(self):
        self.msgcmd = MessageFunction(self)
        self.action = OperationFunction(self)
        self.ops = Operation(self)
        self.sakura = LINE()
        self.mid = self.sakura.profile.mid
        self.sett = self.sakura.getSettings()
        self.help = """mid
>>>個人アカウントのid
gid
>>>グループのid
leave
>>>グループから抜ける
curl
>>>グループうらる拒否
ourl
>>>グループうらる許可
ginfo
>>>グループ情報
gcreator
>>>グループ作成者
setpoint
>>>既読ポイント設置
delpoint
>>>既読ポイント破棄
checkread
>>>既読確認
help
>>>helpを表示
url
>>>追加URLを発行
mid @
>>>メンションした人のmid確認"""
        self.poll = OEPoll(self.sakura)
        self.timesleep = {}
        self.checkread = {}

    def running(self):
        while True:
            try:
                ops = self.poll.singleTrace(count=50)
                if ops:
                    for op in ops:
                        self.poll.setRevision(op.revision)
                        self.ops.getOperation(op)
            except Exception as e:
                print(e)

    def check_time(self, to):
        if to in self.timesleep:
            if time.time() - self.timesleep[to] < 3:
                return False
            else:
                self.timesleep[to] = time.time()
                return True
예제 #5
0
    def add_admin(self, client: LINE, mid: str or list, **kwg) -> bool:
        """
		Use this method to add Admin to database
		@client: class<linepy.LINE.Client>
		@mid: unidefined string of user mid, pass a string or list
		@kwg: other argument for include to your db e.g: user.displayName pass a dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            c = client.getContacts(mid)
            for i in c:
                id = i.mid
                name = i.displayName
                data.add_admin(id, name=name)
        else:
            c = client.getContact(mid)
            data.add_admin(mid, name=c.displayName)
        return True
예제 #6
0
    def __init__(self):
        self.msgcmd = MessageFunction(self)
        self.action = OperationFunction(self)
        self.ops = Operation(self)
        self.sakura = LINE()
        self.mid = self.sakura.profile.mid
        self.sett = self.sakura.getSettings()
        self.help = """mid
>>>個人アカウントのid
gid
>>>グループのid
leave
>>>グループから抜ける
curl
>>>グループうらる拒否
ourl
>>>グループうらる許可
ginfo
>>>グループ情報
gcreator
>>>グループ作成者
setpoint
>>>既読ポイント設置
delpoint
>>>既読ポイント破棄
checkread
>>>既読確認
help
>>>helpを表示
url
>>>追加URLを発行
mid @
>>>メンションした人のmid確認"""
        self.poll = OEPoll(self.sakura)
        self.timesleep = {}
        self.checkread = {}
예제 #7
0
    def __init__(
        self,
        token: str = None,
        email: str = None,
        passwd: str = None,
    ):
        self.list_bots: list = []
        if token and not passwd:
            self.line = LINE(token)
        if email and passwd:
            self.line = LINE(email, passwd)
        if not (token or email and passwd):
            self.line = LINE()

        self.prefix = [".", "/", ">", ""]
        self.img_url = "http://dl.profile.line-cdn.net/"
        self.poll = OEPoll(self.line)
        self.db = DataBase()
        self.db.add_bot(self.line.getProfile().mid, instance=str(self.line))
예제 #8
0
class MainBots(object):
    def __init__(
        self,
        token: str = None,
        email: str = None,
        passwd: str = None,
    ):
        self.list_bots: list = []
        if token and not passwd:
            self.line = LINE(token)
        if email and passwd:
            self.line = LINE(email, passwd)
        if not (token or email and passwd):
            self.line = LINE()

        self.prefix = [".", "/", ">", ""]
        self.img_url = "http://dl.profile.line-cdn.net/"
        self.poll = OEPoll(self.line)
        self.db = DataBase()
        self.db.add_bot(self.line.getProfile().mid, instance=str(self.line))

    def runs(self):
        self.poll.run()

    def run(self, handler: dict or set = {}) -> dict:
        self.poll.addOpInterruptWithDict(handler)
        while True:
            self.poll.trace()

    def log(self, logger):
        def decorator(func):
            def wraper(*arg, **kwg):
                try:
                    func(*arg, **kwg)
                except Exception as e:
                    print(logger.format_exc())

            return wraper

        return decorator

    def reply(self, client, message, text):
        """
		Use this method to Reply message to user
		@client: class<linepy.LINE.client>
		@message: class <akad.ttypes.Message>
		@text: pass a string of text you want to send
		exampe:
		client.reply(client=client, message=message, text='hallo')
		"""
        g = message.id
        return client.sendReplyMessage(g, message.to, text)

    def at_getMid(self, message: Message):
        """
		Use this method to get Mid from user using @Mention
		@message: class<akad.ttypes.Message>
		
		example:
		init.at_getMid(message)
		
		:Return: string or list of mid from target
		"""
        key = eval(message.contentMetadata["MENTION"])
        key["MENTIONEES"][0]["M"]
        if len(key["MENTIONEES"]) <= 1:
            return key["MENTIONEES"][0]["M"]
        else:
            lists = []
            for i in key["MENTIONEES"]:
                lists.append(i["M"])
            return lists

    def add_users(self, client: LINE, group_id: str, mid: str or list,
                  into: str, **kwg) -> bool:
        """
		use this method to insert some user to DataBase
		@client: class<linepy.LINE.client>
		@group_id: undefined mid of group as string
		@mid: undefined mid of user pass string or list
		@into: pass a specified role for user e.g: blacklist,whitelist whatever you want
		@kwg: pass another argument as dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            u = client.getContacts(mid)
            for i in u:
                data.add_users(mid=i.mid,
                               into=into,
                               name=i.displayName,
                               at_group=group_id,
                               globals=True)
        else:
            p = client.getContact(mid)
            data.add_users(mid=p.mid,
                           into=into,
                           name=p.displayName,
                           at_group=group_id,
                           globals=True)
        return True

    @Filters.is_admin()
    def add_group(self, client: LINE, mid: str or list, **kwg) -> bool:
        """
		Use this method to add Group to database
		@client: class<linepy.LINE.Client>
		@mid: undefined string of Group mid, pass a string or list
		@kwg: other argument for include to your db e.g: grop.name pass a dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            g = client.getGroups(mid)
            for i in g:
                data.add_group(i.mid,
                               name=i.name,
                               picture=self.img_url + i.pictureStatus,
                               create=g.createdTime,
                               creator=dict(id=i.creator.id,
                                            name=i.creator.displayName))
        else:
            g = client.getGroup(mid)
            data.add_group(mid,
                           name=g.name,
                           picture=self.img_url + g.pictureStatus,
                           create=g.createdTime,
                           creator=dict(id=g.creator.mid,
                                        name=g.creator.displayName))
        return True

    @Filters.is_admin()
    def add_admin(self, client: LINE, mid: str or list, **kwg) -> bool:
        """
		Use this method to add Admin to database
		@client: class<linepy.LINE.Client>
		@mid: unidefined string of user mid, pass a string or list
		@kwg: other argument for include to your db e.g: user.displayName pass a dict
		
		:Return: True if success false otherwise
		"""
        data = self.db
        if isinstance(mid, list):
            c = client.getContacts(mid)
            for i in c:
                id = i.mid
                name = i.displayName
                data.add_admin(id, name=name)
        else:
            c = client.getContact(mid)
            data.add_admin(mid, name=c.displayName)
        return True
예제 #9
0
"""Made by arsybai"""
from linepy import LINE, OEPoll, Filters
import sys, requests, json, os

ars = LINE("EHgjs44uMOn2yrF9Tka0.IVHnuwLwofRntI40OTeoma.jv92Tt5Typy9VleiyGLkLztZixF8Oa1dVm4oYR7kYJ4=")
route = OEPoll(ars)
print("logged")

# DATABASE
db = {
	'set':{
	'kick':[],
	'invite':[],
	'update':[]
	},
	'user':[]
}

@route.handler(26, Filters.text & Filters.group)
#use Filters.both for use in privatechat too
def linke_Starto(op):
	msg = op.message
	to = msg.to if msg.toType == 2 else msg._from
	text = msg.text.lower()
	if text == 'hi':ars.reply(msg,'hello')
	if text == 'me':ars.reply(msg,str(msg._from))
	if text == ".exit":ars.sendMessage(to,'Shuting Down...');sys.exit("bye")
	if text == '.reboot':ars.sendMessage(to,'Done Qmack');python = sys.executable;os.execl(python, python, *sys.argv)
	if text == '.set':db['set']['kick'].append(to) if to not in db['set']['kick'] else print('yep');db['set']['invite'].append(to) if to not in db['set']['invite'] else print('yep');db['set']['update'].append(to) if to not in db['set']['update'] else print('yep');ars.reply(msg,'OK')
	if text == '.unset':db['set']['kick'].remove(to) if to in db['set']['kick'] else print('yep');db['set']['invite'].remove(to) if to in db['set']['invite'] else print('yep');db['set']['update'].remove(to) if to in db['set']['update'] else print('yep');ars.reply(msg,'OK')
	
예제 #10
0
파일: free.py 프로젝트: TeamMusiBat/japan5
# coding: utf-8
from linepy import LINE, OEPoll
import random
import requests
import shutil
import codecs
import json
import random
import os
yukino_1 = LINE()
yukino_2 = LINE()
yukino_3 = LINE()
tracer = OEPoll(yukino_1)
bots = [yukino_1, yukino_2, yukino_3]
kickers = [yukino_2, yukino_3]
yukino_1Mid = yukino_1.getProfile().mid
kickerMids = [yukino_2.getProfile().mid, yukino_3.getProfile().mid]
botMids = [yukino_1.getProfile().mid, yukino_2.getProfile().mid, yukino_3.getProfile().mid]
yukino_2Mid = yukino_2.getProfile().mid
yukino_3Mid = yukino_3.getProfile().mid
protect = {
    'kickGroup': {}, 
    'normalProtect': {},
    'groupName': {},
    'groupPicture': {},
    'groupUrl': {},
    'blackUsers': {},
    'whiteUsers': {}
}
admins = ["",""]
readData = codecs.open('blackUsers.json', 'r', 'utf-8')
예제 #11
0
import requests

clientFileLocation = 'settings.json'
clientSettingsLoad = codecs.open(clientFileLocation, 'r', 'utf-8')
clientSettings = json.load(clientSettingsLoad)
if "startTime" not in clientSettings:
    clientSettings["startTime"] = time.time()
if "mimic" not in clientSettings:
    clientSettings["mimic"] = {}
if "spamGroupProtect" not in clientSettings:
    clientSettings["spamGroupProtect"] = {}
clientStartTime = clientSettings["startTime"]

try:
    client = CLIENT(clientSettings["authToken"],
                    appName=clientSettings["appName"],
                    showQr=True)
except:
    client = CLIENT(appName=clientSettings["appName"], showQr=True)

clientMid = client.profile.mid
clientPoll = OEPoll(client)
clientErrorOrNewPatch = []

listHelpMessage = {
    "รายละเอียดบัญชี": "ftitle",
    "ชื่อผู้ใช้งาน: {dp}": "dtail",
    "เวลาทำงาน: {rt}": "dtail",
    "ไอดี: {mid}": "dtail",
    "คำสั่งทั่วไป": "title",
    "โปรไฟล์": "profile (@)",
예제 #12
0
from newqr import NewQRLogin
from linepy import LINE

# HEADER must be same as config.py

newqr = NewQRLogin()

print("Headers: %s" % (", ".join(newqr.HEADERS)))
header = input("Header: ")

method = newqr.loginQRWithWebPinCode
token, cert = newqr.parseLogin(method(header))

client = LINE(token)
예제 #13
0
import json
import os
import threading
from dotenv import load_dotenv
from linepy import (LINE, Channel, OEPoll, OpType)

# Auth
load_dotenv()
try:
    if (id_ := os.getenv("EMAIL_ID")) and (pwd := os.getenv("PASSWORD")):
        client = LINE(id_, pwd)
    elif token := os.getenv("TOKEN"):
        client = LINE(idOrAuthToken=token)
    else:
        client = LINE(showQr=True)
except Exception as e:
    print("Failed to authenticate")
    print(e)
    exit(1)

ops = OEPoll(client)
whitelist = [client.profile.mid, client, ]

while True:
    try:
        Operation = ops.singleTrace(count=50)
        if Operation is not None:
            for op in Operation:
                ops.setRevision(op.revision)
                # self.OpInterrupt[op.type], args=(op,)
                thread1 = threading.Thread(target=LINE_OP_TYPE, args=(op,))
예제 #14
0
def botCore(op):
    if op.type == 26:
        msg = op.message
        receiver = msg.to
        if msg.toType == 2:
            if msg.contentType == 0:
                if msg.text == "速度测量仪表":
                    start = time.time()
                    with concurrent.futures.ProcessPoolExecutor(max_workers=4) as excuter:
                        excuter.map(send(receiver))
                    stop = time.time()
                    bot.sendMessage(receiver,"result: " + str(stop - start))

def botOEupdater(oePoll):
    for i in loop:
        try:
            ops = oePoll.singleTrace(count=50)
            if ops is not None:
                for op in ops:
                    botCore(op)
                    oePoll.setRevision(op.revision)
                    loop.append(i + 1)
        except Exception as oeUpdaterError:
            bot.log(oeUpdaterError)

if __name__ == "__main__":
    loop = [0]
    bot = LINE("","")
    print(bot.authToken)
    botOE = OEPoll(bot)
    botOEupdater(botOE)
예제 #15
0
import traceback, sys, time


def jnt(op):

    if op.type == 25:

        if op.message.text == 'hi':
            client.sendMessage(op.message.to, 'Hi too !! How are you ?')
        if op.message.text == "sp":
            st = time.time()
            client.getProfile()
            client.sendMessage(op.message.to, "%s" % (time.time() - st))


client = LINE()
oepoll = OEPoll(client)
print(client.authToken)

while True:
    try:
        ops = oepoll.singleTrace(count=50)
        if ops:
            for op in ops:
                try:
                    jnt(op)
                except Exception:
                    traceback.print_exc()
                oepoll.setRevision(op.revision)
    except Exception:
        traceback.print_exc()
예제 #16
0
from linepy import LINE, OEPoll, Filters
import time

line = LINE("YOUR TOKEN")
"""
now you can disable notice after login
pass Flase for display_notice inside LINE e.g LINE(display_notice=False)
pass without any argument for login use QrCode -> LINE()
"""

route = OEPoll(line)
"""
args route:
	wrokers: <int> some workers for do action if threaded is True
	threaded: <bool> pass True if you want this Threaded, False otherwise
"""


@route.handler(25, Filters.command("speed", prefix="."))
def speed(ops):
    #Fetch speed
    rs = time.time()
    line.sendMessage(ops.message.to, "...")
    line.sendMessage(ops.message.to, f"Fetch; {time.time()-rs}")


route.start()
예제 #17
0
파일: client.py 프로젝트: winnews/selfpy3
import requests

clientFileLocation = 'settings.json'
clientSettingsLoad = codecs.open(clientFileLocation, 'r', 'utf-8')
clientSettings = json.load(clientSettingsLoad)
if "startTime" not in clientSettings:
    clientSettings["startTime"] = time.time()
if "mimic" not in clientSettings:
    clientSettings["mimic"] = {}
if "spamGroupProtect" not in clientSettings:
    clientSettings["spamGroupProtect"] = {}
clientStartTime = clientSettings["startTime"]

try:
    client = CLIENT(clientSettings["authToken"],
                    appName=clientSettings["appName"],
                    showQr=True)
except:
    client = CLIENT(appName=clientSettings["appName"], showQr=True)

clientMid = client.profile.mid
clientPoll = OEPoll(client)
clientErrorOrNewPatch = []

clientHelpMessage = """---------- Details ----------
Username : {dp}
Runtime : {rt}
ID : {mid}

---------- General Commands ----------
- {p}contact (@)