diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5e21743 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +#Dockerfile, Image, Container +FROM python:3.10 + +WORKDIR /sbsheriff-app + +COPY requirements.txt . + +RUN pip install -r requirements.txt + +COPY ./app . + +CMD [ "python","./main.py" ] diff --git a/__pycache__/botOptions.cpython-310.pyc b/__pycache__/botOptions.cpython-310.pyc index 7992a3f..38ead00 100644 Binary files a/__pycache__/botOptions.cpython-310.pyc and b/__pycache__/botOptions.cpython-310.pyc differ diff --git a/__pycache__/embed_factory.cpython-310.pyc b/__pycache__/embed_factory.cpython-310.pyc index e5e79ff..89a045c 100644 Binary files a/__pycache__/embed_factory.cpython-310.pyc and b/__pycache__/embed_factory.cpython-310.pyc differ diff --git a/__pycache__/helpers.cpython-310.pyc b/__pycache__/helpers.cpython-310.pyc index b1012c3..c7d909a 100644 Binary files a/__pycache__/helpers.cpython-310.pyc and b/__pycache__/helpers.cpython-310.pyc differ diff --git a/__pycache__/modals.cpython-310.pyc b/__pycache__/modals.cpython-310.pyc index 8204475..f04530a 100644 Binary files a/__pycache__/modals.cpython-310.pyc and b/__pycache__/modals.cpython-310.pyc differ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..4b7c926 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +botOptions.py \ No newline at end of file diff --git a/Roboto-Bold.ttf b/app/Roboto-Bold.ttf similarity index 100% rename from Roboto-Bold.ttf rename to app/Roboto-Bold.ttf diff --git a/StormBrigade_White.png b/app/StormBrigade_White.png similarity index 100% rename from StormBrigade_White.png rename to app/StormBrigade_White.png diff --git a/app/__pycache__/bingo.cpython-310.pyc b/app/__pycache__/bingo.cpython-310.pyc new file mode 100644 index 0000000..6cbe8fc Binary files /dev/null and b/app/__pycache__/bingo.cpython-310.pyc differ diff --git a/app/__pycache__/botOptions.cpython-310.pyc b/app/__pycache__/botOptions.cpython-310.pyc new file mode 100644 index 0000000..207a44e Binary files /dev/null and b/app/__pycache__/botOptions.cpython-310.pyc differ diff --git a/app/__pycache__/embed_factory.cpython-310.pyc b/app/__pycache__/embed_factory.cpython-310.pyc new file mode 100644 index 0000000..135f6be Binary files /dev/null and b/app/__pycache__/embed_factory.cpython-310.pyc differ diff --git a/app/__pycache__/helpers.cpython-310.pyc b/app/__pycache__/helpers.cpython-310.pyc new file mode 100644 index 0000000..be3c7aa Binary files /dev/null and b/app/__pycache__/helpers.cpython-310.pyc differ diff --git a/app/__pycache__/modals.cpython-310.pyc b/app/__pycache__/modals.cpython-310.pyc new file mode 100644 index 0000000..af102ed Binary files /dev/null and b/app/__pycache__/modals.cpython-310.pyc differ diff --git a/app/__pycache__/sbclasses.cpython-310.pyc b/app/__pycache__/sbclasses.cpython-310.pyc new file mode 100644 index 0000000..b92f89f Binary files /dev/null and b/app/__pycache__/sbclasses.cpython-310.pyc differ diff --git a/background.png b/app/background.png similarity index 100% rename from background.png rename to app/background.png diff --git a/bingo.py b/app/bingo.py similarity index 100% rename from bingo.py rename to app/bingo.py diff --git a/dot.png b/app/dot.png similarity index 100% rename from dot.png rename to app/dot.png diff --git a/app/embed_factory.py b/app/embed_factory.py new file mode 100644 index 0000000..fc8e8ce --- /dev/null +++ b/app/embed_factory.py @@ -0,0 +1,240 @@ +from sqlite3 import adapt +from attr import asdict +import disnake +import requests +import datetime +import time +import helpers +import botOptions +import json +from helpers import sql_get +def lfll(parent): + embed = disnake.Embed(title="Looking for Liege Lords") + embed.description = "List of people looking for LL, use /LL anywhere you you have access to add to this list!\n **Open the thread below and ✅ the requests that you fulfill**" + requests = sql_get("SELECT * FROM llrequests WHERE parentID = {parentID} AND fulfilled = '0'".format(parentID=parent)) + if len(requests) > 0: + users = {} + userCP = {} + for entries in requests: + if entries[7] in users.keys(): + if entries[4] > userCP[entries[7]]: + userCP[entries[7]] = entries[4] + users[entries[7]].append(entries[2]) + else: + users[entries[7]] = [entries[2]] + userCP[entries[7]] = entries[4] + for name,user in users.items(): + field_body = "" + for villa in user: + field_body += ">{villa}\n".format(villa=villa) + embed.add_field(name="{name} CP:{cp}".format(name=name,cp=userCP[name]),value=field_body) + + return embed + +def vm_advert(gID = None): + embed = disnake.Embed(title="VM tracker",description = "Players currently on VM") + embed.set_author(name='Storm Brigade',icon_url='https://i.imgur.com/Opk3fCq.png') + if gID == None: + return embed + #Cleanup expired vm's + exired_vms = helpers.sql_get('SELECT name,added FROM vm_entries WHERE gID = {gID} AND added < unixepoch("now","-15 days") AND finished IS NULL'.format(gID=gID)) + vm_length = 1296000 + if len(exired_vms) > 0: + for vm in exired_vms: + helpers.sql_set("UPDATE vm_entries SET finished = ? WHERE gID = ? AND name = ? AND added = ?",(vm[1]+vm_length,gID,vm[0],vm[1])) + + #print(exired_vms) + from_date = int(datetime.datetime.fromisoformat("{YYYY}-01-01".format(YYYY=datetime.date.today().year)).timestamp()) + to_date = int(datetime.datetime.fromisoformat("{YYYY}-12-31".format(YYYY=datetime.date.today().year)).timestamp()) + #print("SELECT vm_entries.name,vm_entries.added,house.house FROM vm_entries INNER JOIN house ON vm_entries.name = house.username WHERE vm_entries.added BETWEEN {start} AND {end} AND vm_entries.finished IS NULL".format(start=from_date,end=to_date)) + query_result = helpers.sql_get("SELECT vm_entries.name,vm_entries.added,house.house FROM vm_entries INNER JOIN house ON vm_entries.name = house.username WHERE vm_entries.added BETWEEN {start} AND {end} AND vm_entries.finished IS NULL ORDER BY added ASC".format(start=from_date,end=to_date),True) + house_json = json.loads(helpers.sql_get("SELECT relationships FROM guild WHERE gID = {gID}".format(gID = gID))[0][0]) + if len(query_result) > 0: + vm_entries = [] + for entry in query_result: + vm_num = '' + emojis = '' + if str(entry['house']) in house_json.keys(): + emojis += botOptions.relationshipEmojis[house_json[str(entry['house'])]] + if entry['house'] != None: + emojis += botOptions.houseEmojis[entry['house']] + vm_entries.append( "{num}{emojis}{name}:\n".format(num=vm_num,emojis=emojis,name=entry['name'],time_remaining=entry['added']+vm_length)) + temp_value = '' + for vm_entry in vm_entries: + if len(temp_value)+len(vm_entry) > 1024: + if len(embed)+len(temp_value) > 6000: + print("embed is going to be too large lol") + break + embed.add_field(name='\u200b',value=temp_value,inline=False) + temp_value = '' + temp_value += vm_entry + embed.add_field(name='\u200b',value=temp_value,inline=False) + #print(len(embed)) + return embed + +def check_player(user:str,gID:int): + #print("SELECT status,peace FROM players WHERE LOWER(name) = LOWER('{user}' AND gID = {gID})".format(user=user,gID = gID)) + activity = requests.get('https://shk.azure-api.net/shkinfo/v1/UserActivity?world=World%202&username={user}&Key=5E78CFC8-1FFA-4036-8427-D94ED6E1A45B&subscription-key=ff2e578e119348ea8b48a2acd2f5a48d'.format(user=user)) + banStatus = requests.get('http://login.strongholdkingdoms.com/ajaxphp/username_search.php?term={user}'.format(user=user)) + shield = requests.get('https://login.strongholdkingdoms.com/ajaxphp/get_shield_url.php?username={user}&transparent=1'.format(user=user)) + house = helpers.sql_get('SELECT house FROM house WHERE LOWER(username) = LOWER("{user}") AND date > unixepoch("now","-6 hours")'.format(user=user)) + wins = helpers.sql_get('SELECT world,age,rank FROM hallofheroes WHERE LOWER(name) LIKE LOWER("{user}")'.format(user=user)) + query = helpers.sql_get("SELECT status,peace FROM players WHERE LOWER(name) = LOWER('{user}') AND gID = {gID}".format(user=user,gID = gID),True) + from_date = int(datetime.datetime.fromisoformat("{YYYY}-01-01".format(YYYY=datetime.date.today().year)).timestamp()) + to_date = int(datetime.datetime.fromisoformat("{YYYY}-12-31".format(YYYY=datetime.date.today().year)).timestamp()) + vm_info = helpers.sql_get(f"SELECT added FROM vm_entries WHERE LOWER(name) = LOWER('{user}') AND added BETWEEN {from_date} AND {to_date}") + #print(vm_info) + vm_this_year = 0 + vm_active = '' + if len(vm_info) > 0: + vm_this_year = len(vm_info) + vm_active_check = helpers.sql_get(f"SELECT added FROM vm_entries WHERE LOWER(name) = LOWER('{user}') AND finished IS NULL") + if len(vm_active_check) > 0: + vm_active = f"On VM out in:" + #print(query) + member_wins = '' + officer_wins = '' + leader_wins = '' + marshal_wins = '' + status = '' + peace = '' + status_c = '' + peace_c = '' + house_status = "" + houseNum = 0 + if len(query) > 0: + status_c = query[0]['status'] + peace_c = query[0]['peace'] + if status_c != "" and status_c != 'None': + status = status_c + if peace_c == "True": + peace = "<:Faction_ally:947479253157560320>" + if peace_c == "False": + peace = "<:Enemy_house_faction:947479557982781460>" + #print(banStatus.encoding,shield.text) + if len(wins) > 0: + for win in wins: + match win[2]: + case 'Member': + member_wins += win[0]+'-A{age}\n'.format(age=win[1]) + case 'Officer': + officer_wins += win[0]+'-A{age}\n'.format(age=win[1]) + case 'Leader': + leader_wins += win[0]+'-A{age}\n'.format(age=win[1]) + case 'Marshall': + marshal_wins += win[0]+'-A{age}\n'.format(age=win[1]) + if len(house) > 0: + houseNum = int(house[0][0]) + house = "{houseEmoji}{house}".format(house=house[0][0],houseEmoji=botOptions.houseEmojis[int(house[0][0])]) + #print("Found Player") + else: + house = "Neutral" + if houseNum > 0: + house_json = json.loads(helpers.sql_get("SELECT relationships FROM guild WHERE gID = {gID}".format(gID = gID))[0][0]) + if str(houseNum) in house_json: + house_status = botOptions.relationshipEmojis[house_json[str(houseNum)]] + #print(banStatus.text) + banned = "Account is **BANNED**" + banBool = True + act = "Error" + shieldURL='' + known = False + if 'error' not in shield.json().keys(): + shieldURL = shield.json()['url'] + known = True + if len(banStatus.text) == 2: + banned = "Account is **BANNED**" + if not known: + banned = "Account is unknown, typo?" + + else: + result = banStatus.json() + check = user.lower() + #print('Checking if {x} is banned, comparing to {y}'.format(x=check,y=result)) + if check in (string.lower() for string in result): + banned = "**NOT** Banned" + banBool = False + if activity.text == '01/Jan/0001 00:00:00': + #print("Unknown player") + act = "-No W2 Data-" + else: + date = datetime.datetime.strptime(activity.text,'%d/%b/%Y %H:%M:%S') + #print(date) + act = ''.format(t1=int(date.timestamp())) + embed = disnake.Embed(title="{peace}<<{user}>>{status}".format(user=user.capitalize(),peace = peace,status = status)) + embed.description = "Generated \nCurrent avaliable info is:".format(user=user,t1=int(time.time())) + embed.add_field(name="Last Activity",value = act) + embed.add_field(name="Ban Status",value=banned) + embed.add_field(name="House",value=house_status+house) + if vm_this_year > 0: + embed.add_field(name='Vacation',value=f"{vm_this_year} VM's this year\n"+vm_active) + if marshal_wins != '': + embed.add_field(name="Marshall Wins",value=marshal_wins) + if leader_wins != '': + embed.add_field(name="Leader Wins",value=leader_wins) + if officer_wins != '': + embed.add_field(name="Officer Wins",value=officer_wins) + if member_wins != '': + embed.add_field(name="Member Wins",value=member_wins) + + + if user.lower() == 'amber_rose': + shieldURL = 'https://i.imgur.com/F6ywbGx.png' + if shieldURL == '': + embed.set_thumbnail(file=disnake.File('StormBrigade_White.png')) + else: + #print(banBool,type(houseNum),houseNum) + if banBool and houseNum == 13: + embed.set_thumbnail(file=disnake.File('lol.gif')) + else: + embed.set_thumbnail(url=shieldURL) + return embed + +def show_castle_designs(gID,name,page=1): + #print(name,page) + filepaths = list(json.loads(helpers.sql_get(f"SELECT castle_designs FROM players WHERE LOWER(name) = LOWER('{name}') and gID = {gID}")[0][0]).keys()) + #print(filepaths) + embed = disnake.Embed() + embed.set_image(file=disnake.File('images\\{file}'.format(file=filepaths[page-1]))) + embed.title = f"{name} >|< Page {page}" + embed.description = f"Castle design {page} of {len(filepaths)}" + return embed + +def timed_attack(mID = None): + if mID is None: return + target = sql_get("SELECT target,duration FROM attack_targets WHERE mID = {mID}".format(mID=mID),True) + target_id = target[0]['target'] + embed = disnake.Embed() + print(mID) + attacks = sql_get("SELECT (times.seconds/times.multi)-times.modifier AS attack_time,times.modifier,times.name, user.d_name FROM times INNER JOIN user ON times.dID = user.dID WHERE target_mID = {t_mID} ORDER BY d_name,attack_time DESC".format(t_mID=mID),True) + if len(attacks) == 0: + embed.title = "Timed attack on: {tar}".format(tar=target_id) + embed.description= "No attacks added, use buttons below to start" + helpers.sql_set("UPDATE attack_targets SET update_time = 0 WHERE mID = {mID}".format(mID=mID)) + return embed + longest_attack_query = sql_get('SELECT MAX((seconds/multi)-modifier) FROM times WHERE target_mID = {mID}'.format(mID=mID)) + longest_attack = longest_attack_query[0][0] + field_text_content = "" + last_d_name = attacks[0]['d_name'] + for attack in attacks: + if attack['d_name'] != last_d_name: + embed.add_field(name = "__{name}__".format(name = last_d_name),value = field_text_content,inline=True) + last_d_name = attack['d_name'] + field_text_content = "" + print("**New Field**") + + #Prepping Phase + field_text_content += '**{name}**: {t}\n'.format(t=str(datetime.timedelta(seconds=attack['attack_time'])),name=attack['name']) + embed.add_field(name = "__{name}__".format(name = last_d_name),value = field_text_content,inline=True) + countdown_string = '' + + embed.title = "Timed attack on ID: {targetID} - Longest attack: {t} {cd}".format(cd = countdown_string, targetID = target_id,t=str(datetime.timedelta(seconds=longest_attack))) + embed.description = "To participate add your times using the buttons below, or create check times with /calc_times and add them from there.\nAfter you click start there is a 10 seconds countdown before first attack is launched" + embed.set_author(name='Storm Brigade',icon_url='https://i.imgur.com/Opk3fCq.png') + if target[0]['duration'] != None: + #Do logic to set next update time + print('Waaa') + else: + #Finished updating, wait for changes + helpers.sql_set("UPDATE attack_targets SET update_time = 0 WHERE mID = {mID}".format(mID=mID)) + return embed \ No newline at end of file diff --git a/app/helpers.py b/app/helpers.py new file mode 100644 index 0000000..e786177 --- /dev/null +++ b/app/helpers.py @@ -0,0 +1,106 @@ +import sqlite3 +import re +from sqlite3 import Cursor, Error +import time +import datetime +def sql_set(query = None,data = None): + if query == None: return + try: + con = sqlite3.connect('sbsheriff.sqlite') + cur = con.cursor() + if data != None: + cur.execute(query,data) + else: + cur.execute(query) + cur.close() + con.commit() + con.close() + + except Error as e: + print("Sql set error",e) + return Error + +def sql_del(query = None): + if query == None: return + try: + con = sqlite3.connect('sbsheriff.sqlite') + cur = con.cursor() + cur.execute(query) + cur.close() + con.commit() + con.close() + + except Error as e: + print(e) + return Error + +def sql_get(query = None,rfac = False): + if query == None: return + try: + con = sqlite3.connect('sbsheriff.sqlite') + if rfac: + con.row_factory = sqlite3.Row + cur = con.cursor() + cur.execute(query) + re = cur.fetchall() + cur.close() + con.close() + return re + + except Error as e: + print(e) + return Error + + if query == None: return + try: + con = sqlite3.connect('sbsheriff.sqlite') + cur = con.cursor() + cur.execute(query) + re = cur.fetchall() + cur.close() + con.close() + return re + + except Error as e: + print(e) + return Error + +def calc_times(times,multi:int): + #Split times + timeList = re.split(',| ',times) + time_tuples = [] + for num,time_ in enumerate(timeList): + if time_ == '': + continue + #Try and idiotproof some edge cases + if time_.startswith((':',';','.')): + temp_time = time_[1:] + else: + temp_time = time_ + modifier = 0 + if '|' in time_: + temp = time_.split('|') + name = temp[0] + if name.startswith('>') or name.lower() == 'breaker': + #Breaker + if name.startswith('>'): name = name[1:] + modifier = 10 + temp_time = temp[1] + else: + name = '{x}'.format(x = num+1) + time_components = [int(s) for s in re.split('\:|\;|\.',temp_time)] + time_components.reverse() + seconds = 0 + for n,t in enumerate(time_components): + seconds += t*60**n + time_tuples.append((name,seconds,multi,modifier)) + time_tuples.sort(key=lambda y: y[1]) + time_tuples.reverse() + textContent = "**Modifying times to {times}x:**\n".format(times=multi) + for tt in time_tuples: + emoji = '<:Captain:947543163608924181>' + if tt[3] > 0: + emoji = '<:Breaker:947543175025819709>' + textContent += "{emoji}**{vil}**:{t} -{card}x-> {t1}\n".format(vil=tt[0],t=datetime.timedelta(seconds=tt[1]),t1=datetime.timedelta(seconds=int(tt[1]/tt[2])),card=tt[2],emoji=emoji) + textContent += "This message will selfdestruct in ".format(t=int(time.time())+540) + return (textContent,time_tuples) diff --git a/app/images/1010586680291500263.png b/app/images/1010586680291500263.png new file mode 100644 index 0000000..25ff5ce Binary files /dev/null and b/app/images/1010586680291500263.png differ diff --git a/app/images/1010587040141811762.png b/app/images/1010587040141811762.png new file mode 100644 index 0000000..0cbf0d0 Binary files /dev/null and b/app/images/1010587040141811762.png differ diff --git a/app/images/1010588276689752195.png b/app/images/1010588276689752195.png new file mode 100644 index 0000000..c80955e Binary files /dev/null and b/app/images/1010588276689752195.png differ diff --git a/app/images/1010588388556021810.jpg b/app/images/1010588388556021810.jpg new file mode 100644 index 0000000..12f2e08 Binary files /dev/null and b/app/images/1010588388556021810.jpg differ diff --git a/app/images/1010588755385663518.png b/app/images/1010588755385663518.png new file mode 100644 index 0000000..7f37d04 Binary files /dev/null and b/app/images/1010588755385663518.png differ diff --git a/app/images/1010589789147381850.png b/app/images/1010589789147381850.png new file mode 100644 index 0000000..df8793d Binary files /dev/null and b/app/images/1010589789147381850.png differ diff --git a/app/images/1010589836933083186.jpg b/app/images/1010589836933083186.jpg new file mode 100644 index 0000000..b515269 Binary files /dev/null and b/app/images/1010589836933083186.jpg differ diff --git a/app/images/1010590092458475640.jpg b/app/images/1010590092458475640.jpg new file mode 100644 index 0000000..25783ee Binary files /dev/null and b/app/images/1010590092458475640.jpg differ diff --git a/app/images/1010590421577109545.jpg b/app/images/1010590421577109545.jpg new file mode 100644 index 0000000..b8692e9 Binary files /dev/null and b/app/images/1010590421577109545.jpg differ diff --git a/app/images/1010590999665442837.jpg b/app/images/1010590999665442837.jpg new file mode 100644 index 0000000..75a600c Binary files /dev/null and b/app/images/1010590999665442837.jpg differ diff --git a/app/images/1010591448040734830.jpg b/app/images/1010591448040734830.jpg new file mode 100644 index 0000000..2b4911a Binary files /dev/null and b/app/images/1010591448040734830.jpg differ diff --git a/app/images/1010591828044697600.png b/app/images/1010591828044697600.png new file mode 100644 index 0000000..6571099 Binary files /dev/null and b/app/images/1010591828044697600.png differ diff --git a/app/images/1010592006923366521.jpg b/app/images/1010592006923366521.jpg new file mode 100644 index 0000000..63210d4 Binary files /dev/null and b/app/images/1010592006923366521.jpg differ diff --git a/app/images/1010592356468273232.png b/app/images/1010592356468273232.png new file mode 100644 index 0000000..929f721 Binary files /dev/null and b/app/images/1010592356468273232.png differ diff --git a/app/images/1010592558122008646.png b/app/images/1010592558122008646.png new file mode 100644 index 0000000..d602afe Binary files /dev/null and b/app/images/1010592558122008646.png differ diff --git a/app/images/1010592710979231804.png b/app/images/1010592710979231804.png new file mode 100644 index 0000000..80d1505 Binary files /dev/null and b/app/images/1010592710979231804.png differ diff --git a/app/images/1010592873453994004.png b/app/images/1010592873453994004.png new file mode 100644 index 0000000..78a7369 Binary files /dev/null and b/app/images/1010592873453994004.png differ diff --git a/app/images/1010592930894970951.png b/app/images/1010592930894970951.png new file mode 100644 index 0000000..71c0e2f Binary files /dev/null and b/app/images/1010592930894970951.png differ diff --git a/app/images/1010593130036347022.png b/app/images/1010593130036347022.png new file mode 100644 index 0000000..7364fd2 Binary files /dev/null and b/app/images/1010593130036347022.png differ diff --git a/app/images/1010593215482703902.png b/app/images/1010593215482703902.png new file mode 100644 index 0000000..a936970 Binary files /dev/null and b/app/images/1010593215482703902.png differ diff --git a/app/images/1010593457196257330.png b/app/images/1010593457196257330.png new file mode 100644 index 0000000..85b5581 Binary files /dev/null and b/app/images/1010593457196257330.png differ diff --git a/app/images/1010593589463634051.png b/app/images/1010593589463634051.png new file mode 100644 index 0000000..2906024 Binary files /dev/null and b/app/images/1010593589463634051.png differ diff --git a/app/images/1010593713304633384.png b/app/images/1010593713304633384.png new file mode 100644 index 0000000..2482803 Binary files /dev/null and b/app/images/1010593713304633384.png differ diff --git a/app/images/1010593852618440865.png b/app/images/1010593852618440865.png new file mode 100644 index 0000000..6d22c0c Binary files /dev/null and b/app/images/1010593852618440865.png differ diff --git a/app/images/1010593991433134151.png b/app/images/1010593991433134151.png new file mode 100644 index 0000000..56417d2 Binary files /dev/null and b/app/images/1010593991433134151.png differ diff --git a/app/images/1010594090217390120.png b/app/images/1010594090217390120.png new file mode 100644 index 0000000..6658628 Binary files /dev/null and b/app/images/1010594090217390120.png differ diff --git a/app/images/1010594802406006794.png b/app/images/1010594802406006794.png new file mode 100644 index 0000000..0a34aa7 Binary files /dev/null and b/app/images/1010594802406006794.png differ diff --git a/app/images/1010595011928281259.png b/app/images/1010595011928281259.png new file mode 100644 index 0000000..a51f9cc Binary files /dev/null and b/app/images/1010595011928281259.png differ diff --git a/app/images/1010595373724733450.png b/app/images/1010595373724733450.png new file mode 100644 index 0000000..4712ca4 Binary files /dev/null and b/app/images/1010595373724733450.png differ diff --git a/app/images/1010595559742115920.jpg b/app/images/1010595559742115920.jpg new file mode 100644 index 0000000..4fe7bc1 Binary files /dev/null and b/app/images/1010595559742115920.jpg differ diff --git a/app/images/1010598642668806144.png b/app/images/1010598642668806144.png new file mode 100644 index 0000000..6223a3d Binary files /dev/null and b/app/images/1010598642668806144.png differ diff --git a/app/images/1010599022165229568.png b/app/images/1010599022165229568.png new file mode 100644 index 0000000..802b7bb Binary files /dev/null and b/app/images/1010599022165229568.png differ diff --git a/app/images/1010599950033362984.png b/app/images/1010599950033362984.png new file mode 100644 index 0000000..a959200 Binary files /dev/null and b/app/images/1010599950033362984.png differ diff --git a/app/images/1010600727502147584.png b/app/images/1010600727502147584.png new file mode 100644 index 0000000..3305d41 Binary files /dev/null and b/app/images/1010600727502147584.png differ diff --git a/app/images/1010601590438232104.png b/app/images/1010601590438232104.png new file mode 100644 index 0000000..cf6fdab Binary files /dev/null and b/app/images/1010601590438232104.png differ diff --git a/app/images/1010603066946506772.png b/app/images/1010603066946506772.png new file mode 100644 index 0000000..8be3ace Binary files /dev/null and b/app/images/1010603066946506772.png differ diff --git a/app/images/1010604209231634472.png b/app/images/1010604209231634472.png new file mode 100644 index 0000000..250b8ff Binary files /dev/null and b/app/images/1010604209231634472.png differ diff --git a/app/images/1010609149459058758.png b/app/images/1010609149459058758.png new file mode 100644 index 0000000..7928507 Binary files /dev/null and b/app/images/1010609149459058758.png differ diff --git a/app/images/1010611947353419849.png b/app/images/1010611947353419849.png new file mode 100644 index 0000000..fd26a0c Binary files /dev/null and b/app/images/1010611947353419849.png differ diff --git a/app/images/1010612534946045992.png b/app/images/1010612534946045992.png new file mode 100644 index 0000000..5ee9472 Binary files /dev/null and b/app/images/1010612534946045992.png differ diff --git a/app/images/1010612938102542486.png b/app/images/1010612938102542486.png new file mode 100644 index 0000000..5ee9472 Binary files /dev/null and b/app/images/1010612938102542486.png differ diff --git a/app/images/1010620568304898129.png b/app/images/1010620568304898129.png new file mode 100644 index 0000000..4df1713 Binary files /dev/null and b/app/images/1010620568304898129.png differ diff --git a/app/images/1010620696390537236.png b/app/images/1010620696390537236.png new file mode 100644 index 0000000..e467bd8 Binary files /dev/null and b/app/images/1010620696390537236.png differ diff --git a/app/images/1010631750105432164.png b/app/images/1010631750105432164.png new file mode 100644 index 0000000..f54fe1a Binary files /dev/null and b/app/images/1010631750105432164.png differ diff --git a/app/images/1010645515798597752.png b/app/images/1010645515798597752.png new file mode 100644 index 0000000..a2740ca Binary files /dev/null and b/app/images/1010645515798597752.png differ diff --git a/app/images/1010652989427564584.png b/app/images/1010652989427564584.png new file mode 100644 index 0000000..c5a6ebd Binary files /dev/null and b/app/images/1010652989427564584.png differ diff --git a/app/images/1010660399798042624.png b/app/images/1010660399798042624.png new file mode 100644 index 0000000..4a68c8a Binary files /dev/null and b/app/images/1010660399798042624.png differ diff --git a/app/images/1010660514969419937.png b/app/images/1010660514969419937.png new file mode 100644 index 0000000..f311b6f Binary files /dev/null and b/app/images/1010660514969419937.png differ diff --git a/app/images/1010660899767455854.png b/app/images/1010660899767455854.png new file mode 100644 index 0000000..e7bb4f0 Binary files /dev/null and b/app/images/1010660899767455854.png differ diff --git a/app/images/1010661077937303573.png b/app/images/1010661077937303573.png new file mode 100644 index 0000000..c17fc64 Binary files /dev/null and b/app/images/1010661077937303573.png differ diff --git a/app/images/1010806342098886676.png b/app/images/1010806342098886676.png new file mode 100644 index 0000000..54a766f Binary files /dev/null and b/app/images/1010806342098886676.png differ diff --git a/app/images/1010839153375727666.png b/app/images/1010839153375727666.png new file mode 100644 index 0000000..7a633d3 Binary files /dev/null and b/app/images/1010839153375727666.png differ diff --git a/app/images/1010839192676352030.png b/app/images/1010839192676352030.png new file mode 100644 index 0000000..7a633d3 Binary files /dev/null and b/app/images/1010839192676352030.png differ diff --git a/app/images/1010840414082830386.png b/app/images/1010840414082830386.png new file mode 100644 index 0000000..e1a168b Binary files /dev/null and b/app/images/1010840414082830386.png differ diff --git a/app/images/1010867516257603715.png b/app/images/1010867516257603715.png new file mode 100644 index 0000000..4346a02 Binary files /dev/null and b/app/images/1010867516257603715.png differ diff --git a/app/images/1010867795866697789.png b/app/images/1010867795866697789.png new file mode 100644 index 0000000..9fe5e55 Binary files /dev/null and b/app/images/1010867795866697789.png differ diff --git a/app/images/1010883151943434270.png b/app/images/1010883151943434270.png new file mode 100644 index 0000000..775bd10 Binary files /dev/null and b/app/images/1010883151943434270.png differ diff --git a/app/images/1010883260282314752.png b/app/images/1010883260282314752.png new file mode 100644 index 0000000..802f140 Binary files /dev/null and b/app/images/1010883260282314752.png differ diff --git a/app/images/1010997671386943539.png b/app/images/1010997671386943539.png new file mode 100644 index 0000000..2405fa1 Binary files /dev/null and b/app/images/1010997671386943539.png differ diff --git a/app/images/1010997977466290378.png b/app/images/1010997977466290378.png new file mode 100644 index 0000000..d9de05b Binary files /dev/null and b/app/images/1010997977466290378.png differ diff --git a/app/images/1010998259289968830.png b/app/images/1010998259289968830.png new file mode 100644 index 0000000..6e735e2 Binary files /dev/null and b/app/images/1010998259289968830.png differ diff --git a/app/images/1010998428035186718.png b/app/images/1010998428035186718.png new file mode 100644 index 0000000..5abf605 Binary files /dev/null and b/app/images/1010998428035186718.png differ diff --git a/app/images/1010998553180639252.png b/app/images/1010998553180639252.png new file mode 100644 index 0000000..85740b0 Binary files /dev/null and b/app/images/1010998553180639252.png differ diff --git a/app/images/1010998808693456977.png b/app/images/1010998808693456977.png new file mode 100644 index 0000000..d09ba2a Binary files /dev/null and b/app/images/1010998808693456977.png differ diff --git a/app/images/1010998984984240188.png b/app/images/1010998984984240188.png new file mode 100644 index 0000000..871b62b Binary files /dev/null and b/app/images/1010998984984240188.png differ diff --git a/app/images/1010999170179539125.png b/app/images/1010999170179539125.png new file mode 100644 index 0000000..44eee38 Binary files /dev/null and b/app/images/1010999170179539125.png differ diff --git a/app/images/1010999574254600202.png b/app/images/1010999574254600202.png new file mode 100644 index 0000000..f8ce23f Binary files /dev/null and b/app/images/1010999574254600202.png differ diff --git a/app/images/1010999642336526367.png b/app/images/1010999642336526367.png new file mode 100644 index 0000000..9c4bc69 Binary files /dev/null and b/app/images/1010999642336526367.png differ diff --git a/app/images/1011005499359105034.png b/app/images/1011005499359105034.png new file mode 100644 index 0000000..c9cddc1 Binary files /dev/null and b/app/images/1011005499359105034.png differ diff --git a/app/images/1011014560225964122.png b/app/images/1011014560225964122.png new file mode 100644 index 0000000..3ee31e8 Binary files /dev/null and b/app/images/1011014560225964122.png differ diff --git a/app/images/1011014653733785760.png b/app/images/1011014653733785760.png new file mode 100644 index 0000000..3dbc66d Binary files /dev/null and b/app/images/1011014653733785760.png differ diff --git a/app/images/1011181657065259049.png b/app/images/1011181657065259049.png new file mode 100644 index 0000000..53371f1 Binary files /dev/null and b/app/images/1011181657065259049.png differ diff --git a/app/lol.gif b/app/lol.gif new file mode 100644 index 0000000..b9991d7 Binary files /dev/null and b/app/lol.gif differ diff --git a/midground.png b/app/midground.png similarity index 100% rename from midground.png rename to app/midground.png diff --git a/app/modals.py b/app/modals.py new file mode 100644 index 0000000..afa8b08 --- /dev/null +++ b/app/modals.py @@ -0,0 +1,293 @@ +from datetime import datetime +from typing import Text +import disnake +from disnake import TextInputStyle +import helpers +import json +import embed_factory +import time +import requests +class LLModal(disnake.ui.Modal): + def __init__(self,cp,pike=0,archer=0): + components = [ + disnake.ui.TextInput( + label="Enter CP Rank if number below is wrong", + placeholder="Last CP was: {cp}".format(cp=cp), + custom_id="cp", + style=TextInputStyle.short, + max_length=5, + required=False, + value = cp, + ), + disnake.ui.TextInput( + label="Villa ID's seperate with space", + placeholder="1234 4352 54234 ...etc", + custom_id="villa_ids", + style=TextInputStyle.short, + ), + disnake.ui.TextInput( + label="How many Archers?", + placeholder="200", + custom_id="archers", + value=pike, + style=TextInputStyle.short, + ), + disnake.ui.TextInput( + label="How many Pikes?", + placeholder="300", + custom_id="pikes", + value=archer, + style=TextInputStyle.short, + ), + ] + super().__init__( + title="Liege Lord Request Form", + custom_id="submit_ll", + components=components + ) + + async def callback(self,inter: disnake.ModalInteraction): + await inter.response.defer(ephemeral=True) + playerCP = inter.text_values['cp'] + prefArchers = inter.text_values['archers'] + prefPikes = inter.text_values['pikes'] + print("{player} is cp {cp} and input: {villaids}".format(player=inter.author.display_name,cp=playerCP,villaids=inter.text_values['villa_ids'])) + helpers.sql_set("INSERT INTO user(dID,d_name,cp,gID,prefArchers,prefPikes) VALUES(?,?,?,?,?,?) ON CONFLICT(dID) DO UPDATE SET cp = excluded.cp,prefArchers = excluded.prefArchers,prefPikes = excluded.prefPikes",(inter.author.id,inter.author.display_name,playerCP,inter.guild_id,prefArchers,prefPikes)) + result = json.loads(helpers.sql_get("SELECT advert_data FROM guild WHERE gID = {gID}".format(gID = inter.guild.id))[0][0]) + + if 'll' not in result.keys(): + await inter.response.send_message(content="Failed, no thread open", ephemeral=True) + return + thread = inter.guild.get_channel_or_thread(result['ll'][1]) + + if ',' in inter.text_values['villa_ids']: + villa_ids = [villa for villa in inter.text_values['villa_ids'].split(',')] + else: + villa_ids = [villa for villa in inter.text_values['villa_ids'].split()] + if len(villa_ids): + for villa in villa_ids: + button_done = disnake.ui.Button(emoji='✅',custom_id='llcheck') + #button_done.callback = sbComponents.ll_button_callback + embed = disnake.Embed(title="LL Request - {id} from {name} CP: {cp}".format(id=villa,cp=playerCP,name=inter.author.display_name)) + embed.description = "{name} is looking for a LL for {id}, if you fulfill this request, or have gotten a LL click the ✅ below to remove it from the list".format(name=inter.author.display_name,id=villa) + embed.add_field(name="Archers",value=prefArchers,inline=True) + embed.add_field(name="Pikes",value=prefPikes,inline=True) + view = disnake.ui.View() + view.add_item(button_done) + msg = await thread.send(embed=embed,view=view) + helpers.sql_set("INSERT INTO llrequests(parentID,villaID,ownerID,ownerCP,fulfilled,messageID,displayName) VALUES(?,?,?,?,?,?,?)",(thread.id,villa,inter.author.id,playerCP,0,msg.id,inter.author.display_name)) + channel = inter.guild.get_channel_or_thread(result['ll'][0]) + message = await channel.fetch_message(result['ll'][1]) + button_r_ll = disnake.ui.Button(emoji='<:LiegeLord:1003401484295213066>',custom_id='request_ll',label="Click here to request a Liege Lord") + embed_view = disnake.ui.View() + embed_view.add_item(button_r_ll) + await message.edit(embed=embed_factory.lfll(result['ll'][1]),view=embed_view) + await channel.send(content="Request has been added!",delete_after=30) + await inter.followup.send(content="Done! Should be listed here: <#{id}>".format(id=channel.id)) + return + +class timesModal(disnake.ui.Modal): + def __init__(self,multi=4): + components = [ + disnake.ui.TextInput( + label="name|hh:mm:ss or hh:mm:ss can add multiple", + placeholder="Times to convert", + custom_id="times", + required=True, + ), + disnake.ui.TextInput( + label="Time multiplier", + placeholder="4", + custom_id="multi_value", + style= TextInputStyle.short, + max_length=1, + value = multi, + ), + ] + super().__init__( + title="Calculate attack times", + custom_id="submit_calc", + components=components + ) + async def callback(self, interaction: disnake.ModalInteraction): + await interaction.response.defer() + times = interaction.text_values['times'] + multi = int(interaction.text_values['multi_value']) + #do tests on times: + response = helpers.calc_times(times,multi) + view = disnake.ui.View() + add_to_attack = disnake.ui.Button(emoji='<:Captain_blue:947543163608924181>',custom_id='add_to_attack',label='Copy to timed attack') + view.add_item(add_to_attack) + message:disnake.Message = await interaction.followup.send(view = view,content=response[0],delete_after=540) + for time in response[1]: + helpers.sql_set("INSERT INTO times(dID,mID,gID,seconds,name,multi,modifier) VALUES(?,?,?,?,?,?,?)",(interaction.author.id,message.id,interaction.guild_id,time[1],time[0],time[2],time[3])) + return +################################################ +# Remember to mirror changes in the main!! # +################################################ + +class timed_add(disnake.ui.Modal): + def __init__(self): + components = [ + disnake.ui.TextInput( + label="name|hh:mm:ss or hh:mm:ss can add multiple", + placeholder="Times to add", + custom_id="times", + required=True, + ), + disnake.ui.TextInput( + label="Time multiplier", + value=1, + custom_id="multi_value", + style= TextInputStyle.short, + max_length=1, + ), + disnake.ui.TextInput( + label="Help", + style=TextInputStyle.paragraph, + placeholder="Attacks named Breaker or starts with a > will have 10 seconds removed from them", + custom_id="help_line", + required=False, + ), + disnake.ui.TextInput( + label=" ", + style=TextInputStyle.paragraph, + placeholder="Changing time multi alters time entered", + custom_id="help_line2", + required=False, + ), + ] + super().__init__( + title="Add times to attack", + custom_id="submit_timed_add", + components=components + ) + async def callback(self, interaction: disnake.ModalInteraction): + await interaction.response.defer(ephemeral=True) + current_time = int(time.time()) + times = interaction.text_values['times'] + multi = int(interaction.text_values['multi_value']) + #do tests on times: + response = helpers.calc_times(times,multi) + for atk_time in response[1]: + helpers.sql_set("INSERT INTO times(dID,gID,seconds,name,multi,modifier,target_mID,mID) VALUES(?,?,?,?,?,?,?,0)",(interaction.author.id,interaction.guild_id,atk_time[1],atk_time[0],atk_time[2],atk_time[3],interaction.message.id)) + helpers.sql_set("UPDATE attack_targets SET update_time = {cur_time} WHERE mID = {mID}".format(cur_time = current_time,mID = interaction.message.id)) + await interaction.followup.send(content="done",delete_after=1) + return + +#class add_attack_modal(disnake.ui.Modal): +# def __init__(self,target): +# return + +class add_vm(disnake.ui.Modal): + def __init__(self): + components = [ + disnake.ui.TextInput( + label="Name", + placeholder="Check spelling!", + custom_id="user", + required=True, + ), + ] + super().__init__( + title="Report VM", + custom_id="add_vm", + components=components + ) + async def callback(self, interaction: disnake.ModalInteraction): + await interaction.response.defer(ephemeral=True) + user = interaction.text_values['user'] + shield = requests.get('https://login.strongholdkingdoms.com/ajaxphp/get_shield_url.php?username={user}&transparent=1'.format(user=user)) + if 'error' in shield.json().keys(): + await interaction.response.send_message("Unknown player are you sure you typed correctly? - "+user) + return + else: + query_response = helpers.sql_get("SELECT * FROM vm_entries WHERE name = '{user}' AND finished IS NULL".format(user=user),True) + if len(query_response) > 0: + await interaction.response.send_message("This player is already marked as on VM") + return + #TODO addbutton + helpers.sql_set("INSERT INTO vm_entries(gID,name,added) VALUES(?,?,?)",(interaction.guild_id,user,int(time.time()))) + advert_result = json.loads(helpers.sql_get("SELECT advert_data FROM guild WHERE gID = {gID}".format(gID = interaction.guild.id))[0][0]) + channel = interaction.guild.get_channel_or_thread(advert_result['vm'][0]) + message = await channel.fetch_message(advert_result['vm'][1]) + button_add_vm = disnake.ui.Button(emoji='➕',custom_id='add_vm',label="Report VM") + button_rem_vm = disnake.ui.Button(emoji="➖",custom_id="rem_vm",label="Remove VM") + embed_view = disnake.ui.View() + embed_view.add_item(button_add_vm) + embed_view.add_item(button_rem_vm) + await message.edit(view=embed_view,embed=embed_factory.vm_advert(interaction.guild_id)) + await interaction.followup.send(ephemeral=True,content="{user} added to list".format(user=user)) + +class rem_vm(disnake.ui.Modal): + def __init__(self,candidates1:list,candidates2:list): + components = [ + disnake.ui.TextInput( + placeholder="Check spelling!", + custom_id="user", + required=True, + label="Name" + ), + ] + super().__init__( + title="Remove VM", + custom_id="rem_vm", + components=components + ) + async def callback(self, interaction: disnake.ModalInteraction): + await interaction.response.defer(ephemeral=True) + user = interaction.text_values['user'] + query_result = helpers.sql_get("SELECT name,added FROM vm_entries WHERE name = '{user}' AND gID = {gID} AND finished IS NULL".format(user=user,gID=interaction.guild_id)) + if len(query_result) == 0: + await interaction.followup.send(ephemeral=True,content="Not found or already ended") + return + helpers.sql_set("UPDATE vm_entries SET finished = ? WHERE gID = ? AND name = ? AND added = ?",(int(time.time()),interaction.guild_id,query_result[0][0],query_result[0][1])) + advert_result = json.loads(helpers.sql_get("SELECT advert_data FROM guild WHERE gID = {gID}".format(gID = interaction.guild.id))[0][0]) + channel = interaction.guild.get_channel_or_thread(advert_result['vm'][0]) + message = await channel.fetch_message(advert_result['vm'][1]) + button_add_vm = disnake.ui.Button(emoji='➕',custom_id='add_vm',label="Report VM") + button_rem_vm = disnake.ui.Button(emoji='➖',custom_id="rem_vm",label="Remove VM") + embed_view = disnake.ui.View() + embed_view.add_item(button_add_vm) + embed_view.add_item(button_rem_vm) + await message.edit(view=embed_view,embed=embed_factory.vm_advert(interaction.guild_id)) + await interaction.followup.send(ephemeral=True,content="{user} removed from the list".format(user=user)) + +class capture_castle(disnake.ui.Modal): + def __init__(self,user,filename): + components = [ + disnake.ui.TextInput( + placeholder="Who's castle is this?", + custom_id="user", + required=True, + label="Castle Owner", + value=user, + style=TextInputStyle.multi_line + ), + disnake.ui.TextInput( + placeholder="If you see this abort", + custom_id="image_id", + required=True, + label="Don't Touch!", + value=filename + ), + ] + super().__init__( + title="Capture Castle", + custom_id="capture_castle", + components=components + ) + async def callback(self, interaction: disnake.ModalInteraction): + await interaction.response.defer(ephemeral=True) + shield = requests.get('https://login.strongholdkingdoms.com/ajaxphp/get_shield_url.php?username={user}&transparent=1'.format(user=interaction.text_values['user'])) + if 'error' in shield.json().keys(): + await interaction.response.send_message("Unknown player are you sure you typed correctly? - "+interaction.text_values['user']) + return + query_response=helpers.sql_get("SELECT castle_designs FROM players WHERE gID = {gID} AND LOWER(name) = LOWER('{user}')".format(gID = interaction.guild_id,user=interaction.text_values['user'])) + if len(query_response) > 0: + json_object = json.loads(query_response[0][0]) + else: + json_object = {} + json_object[interaction.text_values['image_id']] = interaction.text_values['image_id'] + helpers.sql_set("INSERT INTO players(gID,name,castle_designs) VALUES(?,?,?) ON CONFLICT(name) DO UPDATE SET castle_designs = excluded.castle_designs",(interaction.guild_id,interaction.text_values['user'].lower(),json.dumps(json_object))) + await interaction.followup.send(ephemeral=True,content="Nom nom, thats {num} images for {user}".format(user=interaction.text_values['user'],num=len(json_object))) \ No newline at end of file diff --git a/options.py b/app/options.py similarity index 100% rename from options.py rename to app/options.py diff --git a/resources/100kpitch.png b/app/resources/100kpitch.png similarity index 100% rename from resources/100kpitch.png rename to app/resources/100kpitch.png diff --git a/resources/1kcat.png b/app/resources/1kcat.png similarity index 100% rename from resources/1kcat.png rename to app/resources/1kcat.png diff --git a/resources/1kweps.png b/app/resources/1kweps.png similarity index 100% rename from resources/1kweps.png rename to app/resources/1kweps.png diff --git a/resources/1mgold.png b/app/resources/1mgold.png similarity index 100% rename from resources/1mgold.png rename to app/resources/1mgold.png diff --git a/resources/250cat.png b/app/resources/250cat.png similarity index 100% rename from resources/250cat.png rename to app/resources/250cat.png diff --git a/resources/250kGold.png b/app/resources/250kGold.png similarity index 100% rename from resources/250kGold.png rename to app/resources/250kGold.png diff --git a/resources/2kweps.png b/app/resources/2kweps.png similarity index 100% rename from resources/2kweps.png rename to app/resources/2kweps.png diff --git a/resources/3kweps.png b/app/resources/3kweps.png similarity index 100% rename from resources/3kweps.png rename to app/resources/3kweps.png diff --git a/resources/500cat.png b/app/resources/500cat.png similarity index 100% rename from resources/500cat.png rename to app/resources/500cat.png diff --git a/resources/500kgold.png b/app/resources/500kgold.png similarity index 100% rename from resources/500kgold.png rename to app/resources/500kgold.png diff --git a/resources/5crowns.png b/app/resources/5crowns.png similarity index 100% rename from resources/5crowns.png rename to app/resources/5crowns.png diff --git a/resources/fullbanquet.png b/app/resources/fullbanquet.png similarity index 100% rename from resources/fullbanquet.png rename to app/resources/fullbanquet.png diff --git a/resources/t2.png b/app/resources/t2.png similarity index 100% rename from resources/t2.png rename to app/resources/t2.png diff --git a/resources/t3.png b/app/resources/t3.png similarity index 100% rename from resources/t3.png rename to app/resources/t3.png diff --git a/sbclasses.py b/app/sbclasses.py similarity index 97% rename from sbclasses.py rename to app/sbclasses.py index 6917151..17a352f 100644 --- a/sbclasses.py +++ b/app/sbclasses.py @@ -90,7 +90,7 @@ class TimedAttack: #embed.add_field(name = 'Strix',value='VilA:\nVilA:'.format(t1=int(time.time()+random.random()*360),t2=int(time.time()+random.random()*360)),inline=True) - embed.set_author(name='Storm Brigade',icon_url='https://media.disnakeapp.net/attachments/947633992688103424/947805799231660032/StormBrigade_White.png') + embed.set_author(name='Storm Brigade',icon_url='https://i.imgur.com/Opk3fCq.png') return embed diff --git a/sbingo2.sqlite b/app/sbingo2.sqlite similarity index 100% rename from sbingo2.sqlite rename to app/sbingo2.sqlite diff --git a/app/sbsheriff.sqlite b/app/sbsheriff.sqlite new file mode 100644 index 0000000..4a3020d Binary files /dev/null and b/app/sbsheriff.sqlite differ diff --git a/botOptions.py b/botOptions.py deleted file mode 100644 index ec37139..0000000 --- a/botOptions.py +++ /dev/null @@ -1,134 +0,0 @@ -verifiedUsers = [194754951547715585,273918567018397697,140988518515212288] -prefix = '%' - -alternatives = [ -"Kill an AI in a parish you do not own", -"Raze a village off a player in H13 Bravo", -"Raze a village off a player in Green Machine", -"Raze a village off a player in League of Nations", -"Raze a village off a player in Brothers of the Knighthood", -"Raze a village off a player in The Irish Knights", -"Raze a village off a player in Band of the Red Hand", -"Raze a village off a player in THE PINK FLUFFY UNICORNS", -"Raze a village off a player in THE PINK FLUFFY UNICORNS INC", -"Raze a village off a player in prisoners of war", -"Raze a village off a player in Wind of the Iron Fists", -"Raze a village off a player in The Unforgiven", -"Raze a village off a player in Godz", -"Raze a village off a player in Royal FLush", -"Raze a village off a player in THE RIZEN", -"Raze a village off a player in The Insane Squirrels", -"Raze a village off a player in The Loyal Ones", -"Raze a village off a player in DYWIZION 303", -"Raze H3 HM Lord Perrin", -"Raze H10 HM KingJohn1743", -"Raze H13 HM Amber_Rose", -"Raze H14 HM War_Ghost", -"Raze H17 HM Tasakpol", -"Raze H4 HM richardhood", -"Raze H3 FG Lord Perrin", -"Raze H3 FG bigbucki", -"Raze H3 FG sir william 2", -"Raze H10 FG BlaCK-NeKR", -"Raze H10 FG KingJohn1743", -"Raze H10 FG andracoz", -"Raze H14 FG Lord Darko900", -"Raze H14 FG War_Ghost", -"Raze H14 FG Lady Carl", -"Raze H17 FG Tasakpol", -"Raze H17 FG Peps", -"Raze H17 FG johndex", -"Raze H13 FG Amber_Rose", -"Raze H13 FG Sweet69", -"Raze H13 FG Dovis7", -"Raze H4 FG richardhood", -"Raze H4 FG mcguyber Ill", -"Raze local dumbass WinNytHepOOh89", -"Raze a pot monster (150 pots minimum)", -"Absolve a teammate", -"Flip an enemy county neutral", -"Flip a parish from enemy to ally", -"Send 100 salt to german71", -"Send or participate in a bomb base on a target", -"Raze a village with at least 3 vassals", -"Capture an enemy village with a fully loaded vassal", -"Kill 5 irish rats", -"Kill 5 english rats", -"Kill 5 welsh rats", -"Receive A County Proclamation", -"Message an SB player you have never talked to before", -"Heal 200 disease not in your own parish", -"Send 150 Catapult reinforcements to an allied breaker seat", -"Fill one empty vassal to 500 troops", -"Successfully scout a spice stash", -"Call out an H13/H4 player not sitting on ID", -"Call out an H3/10/14 player not sitting on ID", -"Call out an H17 player not sitting on ID", -"Fulfill a request in Ask and Give", -"Make a request in Ask and Give channel", -"Unlock an achievement", -"Collect 3 treasure-castle chests", -"Raze an H13 village", -"Raze an H4 village", -"Raze an H3 village", -"Raze an H10 village", -"Raze an H14 village", -"Raze an H17 village", -"Capture an H3 village", -"Capture an H10 village", -"Capture an H14 village", -"Capture an H17 village", -"Capture an H13 village", -"Capture an H4 village", -"Successfully defend against an H13/4 attack", -"Successfully defend against an H3/10/14 attack", -"Successfully defend against an H17 attack", -"Post your castle in Castle-Designs on Discord", -"Add a friend on Discord", -"Spot marksdad talking about apples", -"Successfully scout a fish stash", -"Experience Heavy Rain -24", -"Experience Sunny Spells +12", -"Upgrade a parish building", -"Talk to someone in voice chat on Discord", -"Get a gold (or rarer) daily card", -"Get a CASTLE daily card", -"Get an ARMY daily card", -"Get a BANQUETING GOODS Daily Card", -"Get an SPECIALIST daily card", -"Get a FOOD based daily card", -"Lose a vassal", -"Get a RESOURCES daily card", -"LL someone on our Discord", -"Complete a quest", -"Approach someone in SB w/Wolf-castle & offer to remove it- remove it", -"Send some interdiction to an SB vassal hub", -"Turn tax to 9x and leave it on", -"Send Bglizard (at least) 2000 fish", -"Ask your FG what you can do to help", -"Experience someone scouting your stash before you do", -"Play Improved Guardhouses and put troops up in your towns", -"Get a WEAPONS daily card", -"Spot more than 40 people online at once on Discord", -"1-shot a Wolf AI", -"Lose a tower to AI attack", -"Rank up without losing any LL", -"Experience someone killing Rat AI in your parish", -"Experience someone killing Paladin AI in your parish", -"Experience someone killing Snake AI in your parish", -"Talk to someone in a different house on your Discord", -"Someone from a different house on Discord talks to you" -] - - -circleColors = [ - (15,159,251), - (36,139,205), - (4,100,161), - (68,182,254), - (0,180,255), - (0,97,159), - (62,120,180), - (149,195,242) -] - diff --git a/embed_factory.py b/embed_factory.py deleted file mode 100644 index a3196f6..0000000 --- a/embed_factory.py +++ /dev/null @@ -1,66 +0,0 @@ -import disnake -import requests -import datetime -import time -from helpers import sql_get -def lfll(parent): - embed = disnake.Embed(title="Looking for Liege Lords") - embed.description = "List of people looking for LL, use /LL anywhere you you have access to add to this list!\n **Open the thread below and ✅ the requests that you fulfill**" - requests = sql_get("SELECT * FROM llrequests WHERE parentID = {parentID} AND fulfilled = '0'".format(parentID=parent)) - if len(requests) > 0: - users = {} - userCP = {} - for entries in requests: - if entries[7] in users.keys(): - if entries[4] > userCP[entries[7]]: - userCP[entries[7]] = entries[4] - users[entries[7]].append(entries[2]) - else: - users[entries[7]] = [entries[2]] - userCP[entries[7]] = entries[4] - for name,user in users.items(): - field_body = "" - for villa in user: - field_body += ">{villa}\n".format(villa=villa) - embed.add_field(name="{name} CP:{cp}".format(name=name,cp=userCP[name]),value=field_body) - - return embed - -def check_player(user): - activity = requests.get('https://shk.azure-api.net/shkinfo/v1/UserActivity?world=World%202&username={user}&Key=5E78CFC8-1FFA-4036-8427-D94ED6E1A45B&subscription-key=ff2e578e119348ea8b48a2acd2f5a48d'.format(user=user)) - banStatus = requests.get('http://login.strongholdkingdoms.com/ajaxphp/username_search.php?term={user}'.format(user=user)) - shield = requests.get('https://login.strongholdkingdoms.com/ajaxphp/get_shield_url.php?username={user}&transparent=1'.format(user=user)) - print(banStatus.text) - banned = "Account is **BANNED**" - act = "Error" - shieldURL='' - known = False - if 'error' not in shield.json().keys(): - shieldURL = shield.json()['url'] - known = True - if len(banStatus.text) == 2: - banned = "Account is **BANNED**" - if not known: - banned = "Account is unknown, typo?" - - else: - result = banStatus.json() - check = user.lower() - if check in (string.lower() for string in result): - banned = "**NOT** Banned" - if activity.text == '01/Jan/0001 00:00:00': - print("Unknown player") - act = "-No W2 Data-" - else: - date = datetime.datetime.strptime(activity.text,'%d/%b/%Y %H:%M:%S') - print(date) - act = ''.format(t1=int(date.timestamp())) - embed = disnake.Embed(title="{user}'s info".format(user=user)) - embed.description = "Generated \nCurrent avaliable info is:".format(user=user,t1=int(time.time())) - embed.add_field(name="Last Activity",value = act) - embed.add_field(name="Status",value=banned) - if shieldURL == '': - embed.set_thumbnail(file=disnake.File('StormBrigade_White.png')) - else: - embed.set_thumbnail(url=shieldURL) - return embed \ No newline at end of file diff --git a/helpers.py b/helpers.py deleted file mode 100644 index b7afde6..0000000 --- a/helpers.py +++ /dev/null @@ -1,30 +0,0 @@ -import sqlite3 -from sqlite3 import Cursor, Error -def sql_set(query = None,data = None): - if query == None: return - try: - con = sqlite3.connect('sbsheriff.sqlite') - cur = con.cursor() - cur.execute(query,data) - cur.close() - con.commit() - con.close() - - except Error as e: - print(e) - return Error - -def sql_get(query = None): - if query == None: return - try: - con = sqlite3.connect('sbsheriff.sqlite') - cur = con.cursor() - cur.execute(query) - re = cur.fetchall() - cur.close() - con.close() - return re - - except Error as e: - print(e) - return Error diff --git a/main.py b/main.py deleted file mode 100644 index 23c7385..0000000 --- a/main.py +++ /dev/null @@ -1,426 +0,0 @@ -import disnake -from disnake.ext import commands -import json -import modals -import helpers -import time -import embed_factory -from disnake.ext import tasks -import sqlite3 -from sqlite3 import Cursor, Error -import asyncio -import botOptions -import bingo -import random -import math -import os -from datetime import datetime,timezone -import datetime -import sbclasses -import requests - -intents = disnake.Intents().all() - -bot = commands.Bot( - command_preifx='%', - sync_commands_debug=False, - intents=intents -) - - -@bot.event -async def on_ready(): - print('Logged In') - -@bot.slash_command(description='List some villages in need of LL') -async def ll(inter:disnake.ApplicationCommandInteraction): - playerCP = helpers.sql_get("SELECT cp,prefPikes,prefArchers FROM user WHERE dID = {dID}".format(dID=inter.author.id)) - print(playerCP) - cp = 0 - prefArcher = 300 - prefPikes = 200 - if len(playerCP): - cp = int(playerCP[0][0]) - if playerCP[0][1] != None: - prefArcher = int(playerCP[0][2]) - prefPikes = int(playerCP[0][1]) - await inter.response.send_modal(modal=modals.LLModal(cp=cp,pike=prefPikes,archer=prefArcher)) - -@bot.event -async def on_guild_available(guild): - helpers.sql_set('INSERT INTO guild(gID,name) VALUES(?,?) ON CONFLICT DO NOTHING',(guild.id,guild.name)) - -typeList = ['ll'] -@bot.slash_command(description='set LL advert channel') -async def create_advert(inter:disnake.ApplicationCommandInteraction,advert_type:str = commands.Param(description='What type=',choices=typeList), target: disnake.abc.GuildChannel = commands.Param(description='Channel override, optional')): - embed = disnake.Embed(title='Looking for Liege Lords') - result = json.loads(helpers.sql_get("SELECT lldata FROM guild WHERE gID = {gID}".format(gID = inter.guild.id))[0][0]) - if advert_type not in result: - message = await target.send(embed=embed) - await message.create_thread(name="Requests") - result[advert_type] = (message.channel.id,message.id) - helpers.sql_set("INSERT INTO guild(gID,lldata) VALUES(?,?) ON CONFLICT DO UPDATE SET lldata = excluded.lldata",(message.guild.id,json.dumps(result))) - else: - await inter.response.send_message(content="Already set",ephemeral=True) - -@bot.slash_command(description="List some info about target") -async def check_player(inter:disnake.ApplicationCommandInteraction,user:str = commands.Param(description='Player Name')): - embed = embed_factory.check_player(user) - await inter.response.send_message(embed=embed) - - -@bot.event -async def on_message_interaction(inter:disnake.MessageInteraction): - if inter.component.custom_id == 'llcheck' and not inter.response.is_done(): - await inter.response.defer(ephemeral=True) - inter.component.disabled = True - ll_data_dict = json.loads(helpers.sql_get("SELECT lldata FROM guild WHERE gID = {gid}".format(gid=inter.guild.id))[0][0]) - ll_channel = inter.guild.get_channel_or_thread(ll_data_dict['ll'][0]) - ll_thread_message = await ll_channel.fetch_message(ll_data_dict['ll'][1]) - helpers.sql_set("UPDATE llrequests SET fulfilled = ? WHERE messageID = ?",(time.time(),inter.message.id)) - await ll_thread_message.edit(embed= embed_factory.lfll(ll_data_dict['ll'][1])) - - message = await inter.message.delete() - - - return - - - - -timedAttacks = {} -timesMessages = {} - - -def sql_connection(): - try: - - con = sqlite3.connect('sbingo2.sqlite') - - return con - - except Error: - - print(Error) - -def sql_setSeed(con,entry): - cursorObj = con.cursor() - cursorObj.execute('INSERT INTO overrides(dID,seed) VALUES(?,?) ON CONFLICT(dID) DO UPDATE SET seed = excluded.seed',entry) - cursorObj.close() - con.commit() - -def sql_setCard(con,entry): - cursorObj = con.cursor() - cursorObj.execute('INSERT INTO defaultCard(dID,speed) VALUES(?,?) ON CONFLICT(dID) DO UPDATE SET speed = excluded.speed',entry) - cursorObj.close() - con.commit() - -def sql_getCard(con,id): - cursorObj = con.cursor() - query = 'SELECT speed FROM defaultCard WHERE dID = '+str(id) - cursorObj.execute(query) - result = cursorObj.fetchall() - cursorObj.close() - if len(result) == 1: - return result[0][0] - return result - -def sql_addVM(con,name,dateTime): - ok = True - data = (name.lower(),dateTime) - cursorObj = con.cursor() - try: - cursorObj.execute('INSERT INTO vecations(name,date) VALUES(?,?)',data) - except Error: - ok = False - cursorObj.close() - con.commit() - return ok - -def sql_getVM(con): - cursorObj = con.cursor() - cursorObj.execute('SELECT * FROM vecations where date > unixepoch("now","-14 days");') - result = cursorObj.fetchall() - cursorObj.close() - return result - -def sql_getSeed(con,id): - cursorObj = con.cursor() - query = 'SELECT dID, seed FROM overrides WHERE dID = '+str(id) - cursorObj.execute(query) - result = cursorObj.fetchall() - cursorObj.close() - return result - -def generateBingoCard(display_name, id): - bingoimg = bingo.generate_bingo(display_name,id) - bingoimg.save(display_name+'.png') - -@bot.event -async def on_message(message): - if message.author == bot.user: - return - - if message.content.startswith(botOptions.prefix): - #Potential command - command = message.content.lower().split()[0][1:] or None - args = message.content.split()[1:] or [None] - match command: - case 'spin': - random.seed(time.time()) - response = bingo.generate_gif_test(str(message.id),1) - await message.channel.send(content='Spinning the wheel for: '+message.author.display_name,file=disnake.File(str(message.id)+".gif")) - if response == 'T2': - await asyncio.sleep(4) - response = bingo.generate_gif_test(str(message.id),2) - await message.channel.send(content='LUCKY! You won another spin!',file=disnake.File(str(message.id)+".gif")) - if response == 'T3': - await asyncio.sleep(4) - response = bingo.generate_gif_test(str(message.id),3) - await message.channel.send(content='SPINTASTIC!!! Max level spin achieved',file=disnake.File(str(message.id)+".gif")) - await asyncio.sleep(4) - await message.channel.send('Congratulations! You won: '+response) - os.remove(str(message.id)+".gif") - case 'bingo': - seed = sql_getSeed(con,message.author.id) - if seed: - generateBingoCard(message.author.display_name,seed[0][1]) - else: - generateBingoCard(message.author.display_name,message.author.id) - await message.channel.send(content='Here is your bingo card, if you find something impossible ask for an override!',file=disnake.File(message.author.display_name+".png")) - os.remove(message.author.display_name+".png") - case 'reroll': - if message.author.id in botOptions.verifiedUsers: - if len(args) != 1: - await message.channel.send('Expecting an user ID') - elif not args[0].isnumeric(): - await message.channel.send('The argument needs to be the user ID') - else: - target = message.guild.get_member(int(args[0])) - print(args) - print(message.guild) - print(target) - if target == None: - await message.channel.send("Can't find the user in this disnake") - await message.delete() - return - newRandom = math.floor(random.random()*100000000000) - sql_setSeed(con,(target.id,newRandom)) - generateBingoCard(target.display_name,newRandom) - await message.channel.send('New seed set!',file=disnake.File(target.display_name+".png")) - os.remove(target.display_name+".png") - case 'vm': - if len(args) < 1 or args[0] == 'list': - vms = sql_getVM(con) - print(datetime.fromtimestamp(vms[0][1],timezone.utc)) - vmList = 'Players potentially still on VM:' - if len(vms) == 0: - vmList += '\n-None' - else: - for player in vms: - vmList += '\n'+player[0]+' - ' - await message.channel.send(vmList) - if len(args) == 1: - if sql_addVM(con,args[0],message.created_at.replace(tzinfo=timezone.utc).timestamp()): - await message.channel.send(args[0]+' Added to VM list!') - else: - await message.channel.send(args[0]+' Is already on the list') - case 'test': - editAttack = timedAttacks[args[0]] - editAttack.setMark(time.time()) - - case ('timed'|'attack'|'countdown'): - #validate args - if len(args) <= 1: - if args[0] == 'help' or args[0] == None: - embed = disnake.Embed(color=0x5eb4ee,title="<:SB:947837030782615613> Sheriff Timed Attacks for dummies!"\ - ,description="The SB Sheriff can keep track of your times and participating villas!\nThis can be used to keep track of targets and work out what to set the timer to,\n but it can also show a countdown for each attack \ - Granted this can be a bit slow, and inconvenient for some, but on large timed operations or keeping track of multiple attacks it can be quite useful!\n\n \ - The only command needed is: **{prefix}timed