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
# (str) Application versioning (method 1)
version = 0.1
#version = 0.1
# (str) Application versioning (method 2)
# version.regex = __version__ = ['"](.*)['"]
# version.filename = %(source.dir)s/main.py
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py
# (list) Application requirements
# 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
# Sets custom source for any requirements with recipes
# requirements.source.kivy = ../../kivy
##requirements.source.kivy = ../../kivy
#requirements.source.kivy = ../kivysrc
# (list) Garden requirements
#garden_requirements =

View file

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

View file

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

View file

@ -27,7 +27,7 @@ class ForestMapView(MapView):
# Get reference to main app and the db cursor
app = App.get_running_app()
# 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()
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)

View file

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