What's on Your Mind?

Stravinsk

Composer and Artist on Flat Earth
Joined
Jan 4, 2016
Messages
4,562
Gender
Male
Religious Affiliation
Deist
Political Affiliation
Conservative
Marital Status
Widow/Widower
Acceptance of the Trinity & Nicene Creed
No
Another night shift over. A small mistake. A huge explosion of grumpiness and curses from the grumpy lady who is always grumpy that comes in to replace me. Another day to remain calm, speak softly and wish her well. Another opportunity to say a prayer for her.
 
Joined
Jul 14, 2015
Messages
3
Age
64
Location
Wisconsin
Gender
Female
Religious Affiliation
Christian
Political Affiliation
Conservative
Marital Status
Single
A new day that I am thankful I woke up, to meet new challenges; glad I am alive and have the love of the Lord plus devoted loved ones.
 

psalms 91

Well-known member
Moderator
Valued Contributor
Supporting Member
Joined
Jun 22, 2015
Messages
15,282
Age
75
Location
Pa
Gender
Male
Religious Affiliation
Charismatic
Political Affiliation
Conservative
Marital Status
Married
Yes a great day to be thankful
 

Ruth

Well-known member
Joined
Jun 13, 2015
Messages
4,632
Location
Midwest
Gender
Female
Religious Affiliation
Catholic
Political Affiliation
Moderate
Acceptance of the Trinity & Nicene Creed
Yes
Hi Romanos!
 

Rens

Well-known member
Joined
Sep 11, 2015
Messages
4,754
Age
54
Gender
Female
Religious Affiliation
Pentecostal
Political Affiliation
Conservative
Marital Status
In Relationship
It's been too much the nasty attacks. Feel like I want to go to heaven now and get away here. Must be Jezebell Jinglebell attacking me with her scorceries. I'll have a heavenly cooky instead and destroy her.
 

psalms 91

Well-known member
Moderator
Valued Contributor
Supporting Member
Joined
Jun 22, 2015
Messages
15,282
Age
75
Location
Pa
Gender
Male
Religious Affiliation
Charismatic
Political Affiliation
Conservative
Marital Status
Married
Good for you Messy, if you went I would miss you terribly
 

MoreCoffee

Well-known member
Valued Contributor
Joined
Jul 13, 2015
Messages
19,194
Location
Western Australia
Gender
Male
Religious Affiliation
Catholic
Political Affiliation
Moderate
Marital Status
Single
Acceptance of the Trinity & Nicene Creed
Yes
I am thinking that I ought to get on with writing my Python irc bot :p

I have a good portion of it done.

It is intended to replace a bot that I wrote in 2003, 13 years ago, in Java and then modified with a Jython coating to make configuring it easier.

Now it is time to do a new one because I want to refresh my Python programming knowledge. It's been five years or so since last I did any programming.
 

psalms 91

Well-known member
Moderator
Valued Contributor
Supporting Member
Joined
Jun 22, 2015
Messages
15,282
Age
75
Location
Pa
Gender
Male
Religious Affiliation
Charismatic
Political Affiliation
Conservative
Marital Status
Married
you are talented
 

MoreCoffee

Well-known member
Valued Contributor
Joined
Jul 13, 2015
Messages
19,194
Location
Western Australia
Gender
Male
Religious Affiliation
Catholic
Political Affiliation
Moderate
Marital Status
Single
Acceptance of the Trinity & Nicene Creed
Yes
It's all quite easy if you're used to writing instructions that others are to carry out in exactly the way and order in which you write them. Here's an example.

Code:
###
# Name: getBook method
# Description: Gets a book from the resources subdirectory
# Returns: OrderedDict containing the book or an entry for key 'error'
###
def getBook(name):
	fileName = folderName + name + '.properties'
	d = OrderedDict()
	try:
		f = open(fileName,'r')
		for l in f:
			p = l.split('=')
			k = p[0]
			v = (p[1][:-1]).strip()
			d[k] = v
		f.close()
		return d
	except IOError:
		d['error'] = "The " + name + " is not available"
		return d
 

psalms 91

Well-known member
Moderator
Valued Contributor
Supporting Member
Joined
Jun 22, 2015
Messages
15,282
Age
75
Location
Pa
Gender
Male
Religious Affiliation
Charismatic
Political Affiliation
Conservative
Marital Status
Married

Rens

Well-known member
Joined
Sep 11, 2015
Messages
4,754
Age
54
Gender
Female
Religious Affiliation
Pentecostal
Political Affiliation
Conservative
Marital Status
In Relationship
It's all quite easy if you're used to writing instructions that others are to carry out in exactly the way and order in which you write them. Here's an example.

Code:
###
# Name: getBook method
# Description: Gets a book from the resources subdirectory
# Returns: OrderedDict containing the book or an entry for key 'error'
###
def getBook(name):
	fileName = folderName + name + '.properties'
	d = OrderedDict()
	try:
		f = open(fileName,'r')
		for l in f:
			p = l.split('=')
			k = p[0]
			v = (p[1][:-1]).strip()
			d[k] = v
		f.close()
		return d
	except IOError:
		d['error'] = "The " + name + " is not available"
		return d

Oh easy peasy.
Lol I had to program with Pascal once for a study. If you did one " wrong the whole thing didn't work. Luckily my brother in law helped me out and wrote the whole thing. I work with GIs, ArcmAP and now they have programmed it all so well that I just can click some buttons or do a very simple expression. It's nice, they now have ArcGIS online and you can make story maps with it. Really simple. I made a map with windmills and then at the left you can type text and put pictures there. I love my job. I can draw which was always my hobby as a kid and get paid for it.
And I almost never have to work which is the best part.

https://m.youtube.com/watch?v=65XMnoYhgVw
 
Last edited:

Stravinsk

Composer and Artist on Flat Earth
Joined
Jan 4, 2016
Messages
4,562
Gender
Male
Religious Affiliation
Deist
Political Affiliation
Conservative
Marital Status
Widow/Widower
Acceptance of the Trinity & Nicene Creed
No
Bump - *blows dust off thread*

Nice to be asked that question (don't ask) - I have a feeling it's for someone else, someone specific - I don't think it will go anywhere, but it is nice to be asked. Purposely vague, for a public mb.

Feeling strange sort of peace tonight. Sad, but not entirely sure why. A mixture of stuff. A pictured scenario -that will never happen. That's part of it. The question and the concern - that's part of it too. A slight despair at the conclusion of both - yes that's part of it too.

So quiet. Nothing demanding my attention. Not seeking information or entertainment of any kind. Just listening to the silence and feeling - the sadness with the slight ache in my heart. Not pushing it away, not for the moment.
 

MoreCoffee

Well-known member
Valued Contributor
Joined
Jul 13, 2015
Messages
19,194
Location
Western Australia
Gender
Male
Religious Affiliation
Catholic
Political Affiliation
Moderate
Marital Status
Single
Acceptance of the Trinity & Nicene Creed
Yes
I did finish writing my Python IRC bot. It is running on four networks now. Busy little thing.

Code:
__module_name__,__module_version__=("BOT","1.0.0")
__module_description__="Bible bot for displaying and searching bible texts"
print("\0034"+__module_name__+" "+__module_version__+" loaded\003")
import collections,re,string,threading,time,xchat
###
# module variables
###
cmdc=";"
fileName="/home/philip/.config/hexchat/addons/Apologia/resources/<n>.properties"
split,strip,upper=(str.split,str.strip,str.upper)
OrderedDict=collections.OrderedDict
join,lower,replace=(str.join,str.lower,str.replace)
bold,red,underline=("","\0034","\010") # bold ="\002"
versions={}
###
# get bible book names and then version names
###
bookName,versionName=(OrderedDict(),OrderedDict())
bn=replace(fileName,"<n>","Biblebooks")
with open(bn,"r") as booksFile:
	for line in booksFile:
		k,n=split(line,"=")
		n=replace((replace(n,"\r","")),"\n","")
		bookName[k]=n
vn=replace(fileName,"<n>","BibleVersions")
with open(vn,"r") as versionsFile:
	for line in versionsFile:
		k,n=split(line,"=")
		n=replace((replace(n,"\r","")),"\n","")
		versionName[k]=n
###
# helper functions
###
def displayPassage(version,book,ref,xcContext):
	'''
	display a passage from a selected bible in the current hexchat context.
	'''
	reflist=decodeRef(ref)
	chapter=reflist[0]
	first,last=(0,0)
	try:
		if len(reflist)==2: first,last=(int(reflist[1]),int(reflist[1]))
		elif len(reflist)==3: 
			first,last=(int(reflist[1]),int(reflist[2]))
			if last<=first: last=first
		else:
			say("passage reference: "+bold+ref+bold+" is incorrect",xcContext)
			return 
	except:
		say("passage reference: "+bold+ref+bold+" is incorrect",xcContext)
		return
	keylist=[]
	if lower(book) in ["ccc","cct"]: last=first # allow only one CCC verse
	if (last-first)>3: last=first+3
	for i in range(first,last+1):
		s=book+chapter+"_"+str(i)
		keylist.append(s)
	verses=versions[version]
	for k in keylist:
		try:
			ref=refExpander(k)
			say(bold+ref+bold+" "+verses[k],xcContext)
		except:
			say("I could not find "+bold+refExpander(k)+bold,xcContext)
def searchVersion(version,phrase,xcContext):
	'''
	search a bible for a phrase or for a set of words enclosed in [],(), or {}
	(technically the enclosure need not be closed with a ],),or })
	and display the search results in the current hexchat context.
	'''
	ss=""
	verses,foundVerses=(versions[version],OrderedDict())
	i,max=(0,30)
	# search by set of words
	if (strip(phrase)[0]) in ("[","{","("):
		s,b=("[{()}]","      ")
		table=string.maketrans(s,b)
		sp=strip(string.translate(phrase,table))
		sp=lower(sp.translate(string.maketrans("",""),string.punctuation))
		swords=set(split(sp," "))
		wc=len(swords)
		for k in verses:
			verse=lower(verses[k].translate(string.maketrans("",""),string.punctuation))
			vwords=set(split(strip(verse)))
			if swords.issubset(vwords):
				i=i+1
				if i>max: break # stop reading verses
				foundVerses[k]=verses[k]
				ref=refExpander(k)
				if i==1: ss="found in "+version+": "+ref
				else: ss=ss+", "+ref
	# search by phrase
	else:
		rePhrase=r"\b"+lower(phrase)+r"\b"
		for k in verses:
			verse=verses[k]
			foundlist=re.findall(rePhrase,lower(verse.translate(string.maketrans("",""),string.punctuation)))
			if len(foundlist)>0:
				foundVerses[k]=verses[k]
				i=i+1
				if i>max: break # stop reading verses
				ref=refExpander(k)
				if i==1: ss="found in "+version+": "+ref
				else: ss=ss+", "+ref
	# send search information back to the context from which the request came
	if i>max: 
		say(ss+" ... more than "+str(max)+" found",xcContext)
		return 
	if i==0: 
		say("I did not find any occurence of: '"
		+bold+phrase+bold+"' in version: "+version,xcContext)
		return 
	say(ss,xcContext) # say what was found
	if i<5: # say the results if 4 or less were found
		for fk in foundVerses: 
			say(bold+refExpander(fk)+bold+" "+foundVerses[fk],xcContext)
			if lower(version) in ["ccc","cct"]: 
				say(red+"because "+version
				+" sections are large only one is displayed",xcContext)
				break
###
# utility functions
###
def decodeRef(ref):
	'''
	decode a book, chapter, and verse (or verses) reference.
	'''
	s=".,:;-_"
	b="      "
	table=string.maketrans(s,b)
	r=string.translate(ref,table)
	return split(r)
def getVersion(version):
	'''
	get a bible using its key (usually a three letter abbreviation) as recorded
	in file "BibleVersions.properties"
	'''
	bv=OrderedDict()
	bn=replace(fileName,"<n>",strip(version))
	try:
		with open(bn,"r") as properties:
			for line in properties:
				v=split(line,"=")
				k=strip(v[0])
				t=replace(v[1],"\r","")
				t=replace(t,"\n","")
				bv[k]=strip(t)
			return bv
	except:
		bv["error"]="I could not find version "+bold+version+bold
		return bv
def refExpander(ref):
	'''
	separate a reference into book, chapter, and verse components. 
	book is the first 3 characters, chapter is the token before a "_",
	and verse is the token after "_".
	'''
	book=ref[:3]
	bName=bookName[book]
	chapter=split(ref[3:],"_")[0]+":"
	verse=split(ref[4:],"_")[1]
	if bName in ["CCC","CCT"]: chapter=""
	r = bName+" "+chapter+verse
	return r
def say(ss,xcContext):
	'''
	send messages back to the IRC server and split them at word boundaries
	if the message text is very long
	'''
	if len(ss)<350: xcContext.command("SAY "+ss)
	else:
		while len(ss)>300:
			pos=ss.find(" ",300,)
			if pos!=-1:
				ssp=ss[:pos]
				ss=ss[pos+1:]
			else:
				ssp=ss[:300]
				ss=ss[300:]
			xcContext.command("SAY "+ssp)
		xcContext.command("SAY "+ss)
###
# callback functions
###
def parseChannelMessage(word,word_eol,userdata):
	'''
	parses a message that starts with cmdc (command character)
	to see if it is a command for this bot or not. If it is
	then formulate a suitable response to the command.
	if it isn't then ignore it.
	'''
	xcContext=xchat.get_context()
	sender,message=(word[0],join(" ",split(word[1])))
	firstchar=message[0]
	if firstchar==cmdc:
		cmd=split(message[1:]," ")
		firstpart=lower(cmd[0])
		if firstpart=="versions":
			ss=""
			for k in versionName:
				ss=ss+bold+k+bold+"("+versionName[k]+") "
			say(ss,xcContext)
			return 
		if firstpart=="help":
			say("To display a passage type "+bold+";rsv John 3:16"+bold
			+" all bible book names are abbreviated to their first 3"
			+" letters, for example 1Kings is 1ki, John is joh, and so forth."
			+" There are exceptions: Judges is "+bold+"jdg,"+bold
			+" Judith is "+bold+"jdt"+bold+", and Philemon is "
			+bold+"phm"+bold,xcContext)
			say("Searching is done by putting a 's' in front of the"
			+" version name like this "+bold+";skjv God so loved"+bold
			+" that will find all the verses in the KJV containing"
			+" 'God so loved'",xcContext)
			say("To display versions type "+bold+";versions"+bold,xcContext)
			return 
		if firstpart[0]=="s": 
			version=upper(firstpart[1:])
			if version not in versionName: return
			phrase=lower(join(" ",cmd[1:]))
			searchVersion(version,phrase,xcContext)
		else:
			if len(cmd)<3:
				if len(cmd)==2:
					if upper(cmd[0]) in ["CCC","CCT"]:
						version=book=upper(cmd[0])
						ref="1_"+cmd[1].translate(string.maketrans("",""),string.punctuation)
						displayPassage(version,book,ref,xcContext)
			elif len(cmd)==3: 
				version=upper(cmd[0])
				if version not in versionName: return
				book=upper(cmd[1])
				if book in ["JUDGES","JUDG"]: book="JDG"
				elif book in ["JUDITH", "JUDI"]: book="JDT"
				elif book in ["PHILEMON","PHL"]: book="PHM"
				elif book in ["RUTH","RUT"]: book="RTH"
				bref=book[:3]
				ref=cmd[2]
				displayPassage(version,bref,ref,xcContext)
###
# load versions
###
for k in versionName: 
	versions[k]=getVersion(k)
###
# hooks
###
xchat.hook_print("Channel Message", parseChannelMessage)
xchat.hook_print("Private Message to Dialog", parseChannelMessage)
 
Last edited:

MarkFL

La Villa Strangiato
Valued Contributor
Joined
May 20, 2015
Messages
3,221
Age
61
Location
St. Augustine, FL.
Gender
Male
Religious Affiliation
Atheist
Political Affiliation
Moderate
Marital Status
In Relationship
I find Python's lack of curly braces to be disconcerting! :scared:
 

MoreCoffee

Well-known member
Valued Contributor
Joined
Jul 13, 2015
Messages
19,194
Location
Western Australia
Gender
Male
Religious Affiliation
Catholic
Political Affiliation
Moderate
Marital Status
Single
Acceptance of the Trinity & Nicene Creed
Yes
I find Python's lack of curly braces to be disconcerting! :scared:

It saves space. The language uses indentation for code blocks. I think it is quite neat and it forces programmers to use a consistent and more-or-less uniform approach to writing code. :)
 

MarkFL

La Villa Strangiato
Valued Contributor
Joined
May 20, 2015
Messages
3,221
Age
61
Location
St. Augustine, FL.
Gender
Male
Religious Affiliation
Atheist
Political Affiliation
Moderate
Marital Status
In Relationship
Yes, I'm all for indentation of code for readability, and I use it without fail...however, I expect to see braces as well, and it looks naked without them...but I am sure I could get used to it. :D

I also like line breaks above and below if and looping constructs to set them apart visually.
 

MoreCoffee

Well-known member
Valued Contributor
Joined
Jul 13, 2015
Messages
19,194
Location
Western Australia
Gender
Male
Religious Affiliation
Catholic
Political Affiliation
Moderate
Marital Status
Single
Acceptance of the Trinity & Nicene Creed
Yes
Yes, I'm all for indentation of code for readability, and I use it without fail...however, I expect to see braces as well, and it looks naked without them...but I am sure I could get used to it. :D

I also like line breaks above and below if and looping constructs to set them apart visually.

blank lines are okay in Python. I was a little bit naughty and used absurdly short variable names and squashed together code without any blank lines. I suppose I ought to refactor the variable names and add some blanks to make it easier for a reader :)

I am glad to be rid of braces { and } ... I used to code Java, C, and a little C++ but my last years in work were mainly management and "systems architecture" (a fancy name for designing what software stacks and hardware stacks would be needed to handle large projects).

A python sensitive code editor colours the code very nicely. Here's a screen shot of the editor I am using.

attachment.php


Clipboard01.jpg
 
Last edited:

Stravinsk

Composer and Artist on Flat Earth
Joined
Jan 4, 2016
Messages
4,562
Gender
Male
Religious Affiliation
Deist
Political Affiliation
Conservative
Marital Status
Widow/Widower
Acceptance of the Trinity & Nicene Creed
No
On my mind:

Oh, I really can't say. LOL.

I'm in a mood that absolutely requires an alt to articulate what I'm thinking.

Maybe on another website. Not that one, lol. Nor this one.
 

Stravinsk

Composer and Artist on Flat Earth
Joined
Jan 4, 2016
Messages
4,562
Gender
Male
Religious Affiliation
Deist
Political Affiliation
Conservative
Marital Status
Widow/Widower
Acceptance of the Trinity & Nicene Creed
No
No no. I'll say, without delay, but in my way:

Through a broken window, it peeks.
It was Midnight, hours to be waited
12...tick tick tick
Toc
Her, a mirror, you,
reflected surface only can be sought
Alike and not - this is what I caught.
When I looked at her,
and saw you
hiding in time.

Day and night, they are not so different.
But in degrees, they are sought.
The rest are blinded, gazes direct,
It is what they recieve,
For not being elect.

"No", she screamed - "You neither are elect"
Perhaps not, said I
But my gaze was directed, at a time when you'd set.


Lie, lie, lie on those waters.
12 hours was all that was needed.
Lie, lie, lie on those waters.
Morning dew graces flower yet to be seeded.

Day and night, they are not so different.
But in degrees, they are sought.
Alike and not - this is what I caught.
When I looked at her,
and saw you
hiding in time.
 

Stravinsk

Composer and Artist on Flat Earth
Joined
Jan 4, 2016
Messages
4,562
Gender
Male
Religious Affiliation
Deist
Political Affiliation
Conservative
Marital Status
Widow/Widower
Acceptance of the Trinity & Nicene Creed
No
A heavily edited version of what I wrote out in private.

2 dreams this early morning. The first was nice, but it doesn't matter. I completely understand the reason for it.

The second, matters. I shouldn't be having such a dream. It does not belong in my subconscious. And yet it is there. The dream was so nice and I so didn't want it to end. It is also not reflective of any kind of *active* reality. That reality bites. The reality that I see.

I don't believe in coincidences. I don't have powerful dreams like this. But I'm open to the possibility of a fluke. If it was a fluke, then it shouldn't happen again. Especially not when I am aware that such a dream can only mean torture in my waking hours.
 
Top Bottom