d-dd / yukari Goto Github PK
View Code? Open in Web Editor NEWA Cytube bot written in Twisted (Python)
A Cytube bot written in Twisted (Python)
You're welcome.
??
Should only respond to specific args such as "you." and "you %s" % name
[IrcClient] Connection Lost to IRC. Reason: [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion.
with textbelt.com
weekly reminder
$sms phonenumber
Display message when:
-video gets blacklisted
-a blacklisted video is added (removed).
The IRC usercount slowly creeps up.
There is something else that should be decreasing the count other than leave and quit. Maybe netsplits, but those should count as quits.
99 % of them won't become available ever anyway.
Since youtube blocks a lot of videos in the US now, add a requirement that video must be viewable in US (can add region codes in settings).
Might be v2 still
Saw an answer before the prompt yesterday on irc
[question] Yes.
$ask question.
I think it tally's non-replay polls too (polls other people made) and somehow tries to count the results of those.
Sets media to replay (once) mode.
When it finishes it will be played again.
Trying to 'jumpTo' before changeMedia by estimating remaining runtime is too unreliable. Waiting for changeMedia is better, but remaining time still needs to be monitored to differentiate between user initiated changeMedia (which replay will be cancelled) or a natural changeMedia (will be replayed).
Also if changeMedia is 'correct' (someone sets it for us), then replay will be cancelled.
What would be easier is to queue two videos, but channels disallow duplicate media by default.
Another workaround is to move the media down after it finished playing, so it would replay after one video. But that's not really the same.
Looks like IRC is the problem this time.
Yukari was excess flood kicked... The now playing and status messages probably count against the anti-flood.
--- ---
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
why = selectable.doRead()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 214, in doRead
return self._dataReceived(data)
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/twisted/internet/tcp.py", line 220, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 96, in dataReceived
self._dataReceived(data)
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1328, in _dataReceived
self.consumeData()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1344, in consumeData
while self.processData() and self.state != WebSocketProtocol.STATE_CLOSED:
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1503, in processData
return self.processDataHybi()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1817, in processDataHybi
fr = self.onFrameEnd()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 1947, in onFrameEnd
self._onMessageEnd()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 132, in _onMessageEnd
self.onMessageEnd()
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/websocket/protocol.py", line 743, in onMessageEnd
self._onMessage(payload, self.message_is_binary)
File "/home/dd/.virtualenvs/yuka/local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 136, in _onMessage
self.onMessage(payload, isBinary)
File "/home/dd/mikumonday/Yukari/connections/cytube/cyClient.py", line 245, in onMessage
self.processFrame(fdict)
File "/home/dd/mikumonday/Yukari/connections/cytube/cyClient.py", line 299, in processFrame
thunk(fdict)
File "/home/dd/mikumonday/Yukari/connections/cytube/cyClient.py", line 383, in _cyCall_chatMsg
self.factory.handle.recCyMsg('chat', username, msg, False, action)
File "yukari.py", line 193, in recCyMsg
self.sendToIrc(cleanMsg)
File "yukari.py", line 251, in sendToIrc
self.ircFactory.prot.sendChat(msg, action)
exceptions.AttributeError: IrcFactory instance has no attribute 'prot'
line 419, in _likeMedia
qid = self.playlist[i]['qid']
exceptions.KeyError: 'qid'
"Z:\dev\Yukari\connections\cytube\cyClient.py", line 1187, in sustainQueue mType, mId = self.queueMediaList.popleft() exceptions.IndexError: pop from an empty deque
The stop condition is being checked on the instance-wide name, which can lead to race condition.
Yukari/connections/cytube/cyClient.py
Line 1191 in 7569c60
Ignore or maybe PM the user back.
Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure <class 'OpenSSL.SSL.Error'>>]
Maybe poor handling of failures.
If a connection drops abnormally Yukari might never be notified so we should poll the server.
Quick!
With maybe a text file that needs to be updated each commit, or something automatic that shows the git hash.
This is to check which version is running, so we know if we already restarted Yukari or not after a git pull.
Some encoding error, need to reproduce again for error message.
At least the most recent announcement needs to be saved somewhere in order to avoid repeating on rejoin.
It doesn't set replay after poll is over.
-double check ratios and boolean flag.
-Also some cases:
1)When Yukari opens the poll, but during the poll someone sets $replay
a)In this case, it should close the poll.
2) When someone closes the poll, "disregard message" appears - is this cancelling the replay? Clearing 1a should resolve this.
check: $vote replay errors when it is already set to replay (pretty sure it already does)
In a moderated IRC channel, Yukari could post messages about now playing media.
username has added next (10): title!
10th time this has been queued.
Not by user, just in general.
Oh, also put a tiny delay so queues can be collected:
username has added 5 videos!
; etc.
Maybe I should set up a local Cytube server
check points for $bye; think of something for > 5000 points, also add $goodnight.
during spam yukari had database write errors
I think it was "cannot have null for userid" or something close to it. Possibly there was another error before that that caused a restart, and a lot of spam when she joins causes this error.
Line 73 in d92365d
Word wrap IRC messages instead of breaking up characters mid-word.
a very long IRC chat message should break off [..]
like this.
We call it when we shut down, and it is also called in the reconnect portion of cytube factory.
Luckily the assert statement was raised and data was never double logged.
The issue with $add right now is that it:
It would be better if $add -n 5
would always add 5 videos to the list.
Sometimes (especially when we do specific searches) we have to repeat the $add
command, because the RNG may keep selecting videos that are already in the playlist. It's probably a bad idea to filter the actual SQL with media id's that are already in the playlist. It's also a bad idea to select everything before filtering it out in Python, unless the result is small.
File "/home/pi/venv/local/lib/python2.7/site-packages/autobahn/twisted/websocket.py", line 138, in _onMessage
self.onMessage(payload, isBinary)
File "/home/pi/mikumonday/Yukari/connections/cytube/cyClient.py", line 138, in onMessage
self.processFrame(fdict)
File "/home/pi/mikumonday/Yukari/connections/cytube/cyClient.py", line 185, in processFrame
thunk(fdict)
File "/home/pi/mikumonday/Yukari/connections/cytube/cyClient.py", line 1344, in _cyCall_changeMedia
self.doClosePoll()
File "/home/pi/mikumonday/Yukari/connections/cytube/cyClient.py", line 527, in doClosePoll
self.sendf({'name': 'closePoll'})
File "/home/pi/mikumonday/Yukari/connections/cytube/cyClient.py", line 145, in sendf
l = '["%s",%s]' % (fdict["name"], json.dumps(fdict["args"]).encode('utf8'))
exceptions.KeyError: 'args'
The adbapi only uses one thread so it never locks itself, but if something else is using it (reading table with sqlite3), it can sometimes lock.
$profile words, url
... maaaaybeDemocracy!!!
Makes polls.
$vote replay #14
$vote shuffle
$vote leader (?)
$vote kick (?)
$vote lock/unlock (?)
$vote anything else?
mmods can retire soon~ (actually they have to type the $vote command)
Each poll type has a ratio which must be satisfied for the event to occur (e.g. 3:1 votes for a replay).
Each poll will have a timer. It will be controlled by Yukari instead of the Cytube server. This leaves us the option to add more time if necessary.
An option (maybe -s) is available to limit Yukari to just making the poll, and nothing more (not even ending the poll).
I think anything that doesn't return a smid dl link just disables $reprint right now:
Catch some exceptions such as:
-deleted video
-bad id
etc...
It reconnects twice a lot
"status": {
"uploadStatus": "rejected",
"rejectionReason": "uploaderAccountSuspended",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}
Similar to now playing IRC channel, channel-status
channel will be moderated (+m) and no users except Yukari will have voice. This is meant to be used with a script so there isn't a big focus on message readability.
Yukari will announce:
user part
user join
full userlist*
This channel might be used for other status messages in the future.
*When yukari joins channel, when IRC gets throttled, when Cytube is under spam and commands are ignored
Clients are responsible for differentiating cytube and irc names and handling name clashes.
For the time being Yukari will use the same nickname as main chat/ now playing.
IRC command (no PM's) that PM's caller with the last 15 lines of chat history.
Yukari assumes each video is unique, so videos are often searched by (type, id). Since playlist is a list it probably searches for the first match, and selects that video.
Look for places where this may be problematic on channels that allow duplicates and fix them.
IRC character limit per line is greater than Cytube character limit. When someone types a long line in IRC Yukari should split it as necessary.
Add an argument for $add that lets users adds old videos (last queue > 6 months, biased towards older videos) that a user liked/queued/added in the past.
Good morning, hello, good afternoon, good evening, hello.
$settz -9
Don't worry about daylight saving.
Title
$omit [type, id]
could use some feedback. Currently you can only check if it was successfully omitted when the video is playing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.