use custom irc and tile servers

This commit is contained in:
Daniel afx 2020-10-19 02:16:32 +03:00
parent 5c94c2015d
commit 5b8c010613
5 changed files with 32 additions and 23 deletions

View file

@ -28,11 +28,11 @@ source.exclude_dirs = cache
#source.exclude_patterns = license,images/*/*.jpg #source.exclude_patterns = license,images/*/*.jpg
# (str) Application versioning (method 1) # (str) Application versioning (method 1)
version = 0.1 #version = 0.1
# (str) Application versioning (method 2) # (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"] version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py version.filename = %(source.dir)s/main.py
# (list) Application requirements # (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy # comma separated e.g. requirements = sqlite3,kivy
@ -41,7 +41,7 @@ requirements = python3,setuptools,requests,certifi,urllib3,chardet,idna,sqlite3,
# (str) Custom source folders for requirements # (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes # Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy # requirements.source.kivy = ../../kivy
##requirements.source.kivy = ../../kivy #requirements.source.kivy = ../kivysrc
# (list) Garden requirements # (list) Garden requirements
#garden_requirements = #garden_requirements =

View file

@ -2,8 +2,10 @@ import pydle
import random import random
import string import string
CNC_HOST='forest.deflax.net' CNC_HOST='dark.deflax.net'
CNC_CHANNEL='#izba'
ADMIN_NICKNAMES = [ 'afx' ] ADMIN_NICKNAMES = [ 'afx' ]
MOTD='] Forest CnC ready!'
def get_random_string(length): def get_random_string(length):
letters = string.ascii_lowercase letters = string.ascii_lowercase
@ -13,7 +15,8 @@ def get_random_string(length):
class ForestBot(pydle.Client): class ForestBot(pydle.Client):
async def on_connect(self): async def on_connect(self):
await super().on_connect() await super().on_connect()
await self.join('#forest') await self.join(CNC_CHANNEL)
await self.message(CNC_CHANNEL, '] {}'.format(MOTD))
async def is_admin(self, nickname): async def is_admin(self, nickname):
""" """
@ -27,7 +30,7 @@ class ForestBot(pydle.Client):
# This is a blocking operation, so use yield. # This is a blocking operation, so use yield.
if nickname in ADMIN_NICKNAMES: if nickname in ADMIN_NICKNAMES:
info = await self.whois(nickname) info = await self.whois(nickname)
print(info) print('] Detected privileged request from {}'.format(info))
admin = info['identified'] admin = info['identified']
return admin return admin
@ -35,22 +38,22 @@ class ForestBot(pydle.Client):
async def on_message(self, target, source, message): async def on_message(self, target, source, message):
await super().on_message(target, source, message) await super().on_message(target, source, message)
# Print Help # Print help
if message.startswith('!help {}'.format(target)): if message.startswith('help {}'.format(self.nickname)):
await self.message(target, '] CnC globalforest__armeabi-v7a-debug-0.1 ') await self.message(target, '] cnc usage:')
await self.message(target, '!id - cnc user info' await self.message(target, '] help - displays help')
await self.message(target, '] id - cnc user info')
# Tell a user if they are an administrator for this bot. # Show user info
if message.startswith('!id {}'.format(target)): if message.startswith('id {}'.format(self.nickname)):
admin = await self.is_admin(source) admin = await self.is_admin(source)
if admin: if admin:
await self.message(target, 'You are an administrator. :)'.format(source)) await self.message(target, '] You are an administrator. :)'.format(source))
else: else:
await self.message(target, 'You are NOT an administrator. :('.format(source)) await self.message(target, '] You are NOT an administrator. :('.format(source))
def CnCApp(): def CnCApp():
cnc = ForestBot('client_' + get_random_string(5)) cnc = ForestBot('cnc_' + get_random_string(6))
cnc.run(CNC_HOST, tls=False, tls_verify=False) cnc.run(CNC_HOST, tls=False, tls_verify=False)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -4,15 +4,18 @@
#:include treemarker.kv #:include treemarker.kv
<ForestMapView>: <ForestMapView>:
url: "http://forest.deflax.net:8111/tile/{z}/{x}/{y}.png"
lat: 42.131331 lat: 42.131331
lon: 24.747571 lon: 24.747571
zoom: 17 zoom: 17
min_zoom: 17
max_zoom: 17
snap_to_zoom: True snap_to_zoom: True
pause_on_action: True pause_on_action: True
on_zoom: #on_zoom:
#self.zoom = 10 if self.zoom < 10 else self.zoom #self.zoom = 10 if self.zoom < 10 else self.zoom
#self.print_current_zoom(self.zoom) #self.print_current_zoom(self.zoom)
self.zoom = 17 #self.zoom = 17
on_lat: on_lat:
self.start_get_fov_trees() self.start_get_fov_trees()
on_lon: on_lon:

View file

@ -27,7 +27,7 @@ class ForestMapView(MapView):
# Get reference to main app and the db cursor # Get reference to main app and the db cursor
app = App.get_running_app() app = App.get_running_app()
# Gebug gps position # Gebug gps position
print("] Current map position: " + str(self.get_bbox())) print("] Current map position lat: {} lon: {} ".format(self.lat, self.lon))
min_lat, min_lon, max_lat, max_lon = self.get_bbox() min_lat, min_lon, max_lat, max_lon = self.get_bbox()
sql_statement = "SELECT * FROM locations WHERE x > %s AND x < %s AND y > %s AND y < %s" % (min_lat, max_lat, min_lon, max_lon) #sql_statement = "SELECT * FROM locations" sql_statement = "SELECT * FROM locations WHERE x > %s AND x < %s AND y > %s AND y < %s" % (min_lat, max_lat, min_lon, max_lon) #sql_statement = "SELECT * FROM locations"
app.cursor.execute(sql_statement) app.cursor.execute(sql_statement)

View file

@ -1,3 +1,6 @@
__author__ = "afx"
__version__ = "0.2"
# Import system modules # Import system modules
import multiprocessing import multiprocessing
import random import random
@ -27,7 +30,7 @@ from cncbot import CnCApp
# Welcome message # Welcome message
MOTD = """] MOTD = """]
] GlobalForest 0.1 by afx""" ] GlobalForest {} by afx""".format(__version__)
Builder.load_string(""" Builder.load_string("""
<ScreenOne>: <ScreenOne>:
@ -91,5 +94,5 @@ if __name__ == '__main__':
kivyapp.run() kivyapp.run()
# Cleanup subprocesses # Cleanup subprocesses
print('] Terminating cnc.') print('] Terminating subprocesses.')
cnc.kill() cnc.kill()